On 28/01/14 20:06, Phoebe Buckheister wrote:
> Since the AT86RF2xy chips are mostly compatible, this is only a small
> change to the actual driver code. The at86rf230 driver already supports the
> RF212 in most places, only three small adjustments are required:
> 
>  * force the initial state after P_ON to FORCE_TRX_OFF to work around a
>    documented erratum
>  * channels_supported depends on the frequency of the transceiver, and
>    thus is_rf212
>  * do early detection of chip version select an appropriate _ops struct
>    based on the chip version.
> 
> Signed-off-by: Phoebe Buckheister <phoebe.buckheis...@itwm.fraunhofer.de>
> ---
>  drivers/net/ieee802154/at86rf230.c |  263 
> ++++++++++++++++++++++++------------
>  1 file changed, 174 insertions(+), 89 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/at86rf230.c 
> b/drivers/net/ieee802154/at86rf230.c
> @@ -244,6 +250,52 @@ struct at86rf230_local {
>  #define STATE_TRANSITION_IN_PROGRESS 0x1F
>  
>  static int
> +__at86rf230_detect_device(struct spi_device *spi, u16 *man_id, u8 *part,
> +             u8 *version)
> +{
> +     u8 data[4];
> +     u8 buf[2];

Never ever put spi transfer buffer onto the stack. It is not dma safe.
Use kmalloc/kzalloc.

> +     int status;
> +     struct spi_message msg;
> +     struct spi_transfer xfer = {
> +             .len    = 2,
> +             .tx_buf = buf,
> +             .rx_buf = buf,
> +     };
> +     u8 reg;
> +
> @@ -520,6 +572,29 @@ at86rf230_stop(struct ieee802154_dev *dev)
>  }
>  
>  static int
> +rf230_channel(struct at86rf230_local *lp, int page, int channel)

at86rf230 please. Let's keep the prefix everywhere.

> +{
> +     return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
> +}
> +
> +static int
> +rf212_channel(struct at86rf230_local *lp, int page, int channel)

at86rf212

> +{
> +     int rc;
> +
> +     if (channel == 0) {

if (page == 0) ?

> +             rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 0);
> +     } else {
> +             rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 1);
> +     }
> +

The rest looks good.

-- 
With best wishes
Dmitry

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to