mbox series

[net-next,v1,0/2] ieee802154: ca8210: Sparse fix and GPIOd conversion

Message ID 20250303150855.1294188-1-andriy.shevchenko@linux.intel.com
Headers show
Series ieee802154: ca8210: Sparse fix and GPIOd conversion | expand

Message

Andy Shevchenko March 3, 2025, 3:07 p.m. UTC
The main part is the patch 2 that converts the driver to GPIO descriptor APIs,
the first one is just an ad-hoc fix WRT sparse complains on the bitwise
types misuse.

Andy Shevchenko (2):
  ieee802154: ca8210: Use proper setter and getters for bitwise types
  ieee802154: ca8210: Switch to using gpiod API

 drivers/net/ieee802154/ca8210.c | 72 ++++++++++++---------------------
 1 file changed, 26 insertions(+), 46 deletions(-)

Comments

Andy Shevchenko March 3, 2025, 4:12 p.m. UTC | #1
On Mon, Mar 03, 2025 at 05:06:32PM +0100, Miquel Raynal wrote:
> On 03/03/2025 at 17:07:39 +02, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Sparse complains that the driver doesn't respect the bitwise types:
> >
> > drivers/net/ieee802154/ca8210.c:1796:27: warning: incorrect type in assignment (different base types)
> > drivers/net/ieee802154/ca8210.c:1796:27:    expected restricted __le16 [addressable] [assigned] [usertype] pan_id
> > drivers/net/ieee802154/ca8210.c:1796:27:    got unsigned short [usertype]
> > drivers/net/ieee802154/ca8210.c:1801:25: warning: incorrect type in assignment (different base types)
> > drivers/net/ieee802154/ca8210.c:1801:25:    expected restricted __le16 [addressable] [assigned] [usertype] pan_id
> > drivers/net/ieee802154/ca8210.c:1801:25:    got unsigned short [usertype]
> > drivers/net/ieee802154/ca8210.c:1928:28: warning: incorrect type in argument 3 (different base types)
> > drivers/net/ieee802154/ca8210.c:1928:28:    expected unsigned short [usertype] dst_pan_id
> > drivers/net/ieee802154/ca8210.c:1928:28:    got restricted __le16 [addressable] [usertype] pan_id
> >
> > Use proper setter and getters for bitwise types.
> >
> > Note, in accordance with [1] the protocol is little endian.
> >
> > Link: https://www.cascoda.com/wp-content/uploads/2018/11/CA-8210_datasheet_0418.pdf [1]
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Looks correct indeed,

TBH, my guts feeling is that this driver was never tested on BE platforms...

> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks for review!
Andy Shevchenko March 3, 2025, 4:28 p.m. UTC | #2
On Mon, Mar 03, 2025 at 05:20:59PM +0100, Miquel Raynal wrote:

...

> > - * @gpio_reset:     gpio number of ca8210 reset line
> > - * @gpio_irq:       gpio number of ca8210 interrupt line
> > + * @reset_gpio:     GPIO of ca8210 reset line
> 
> What about "CA8210 Reset GPIO line"? Or Just "Reset GPIO line"? Or even
> "Reset GPIO descriptor" (whatever).
> 
> > + * @irq_gpio:       GPIO of ca8210 interrupt line
> 
> Same

Sure.

[...]

> > -	int ret;
> > -	struct ca8210_platform_data *pdata = spi->dev.platform_data;
> > +	struct device *dev = &spi->dev;
> > +	struct ca8210_platform_data *pdata = dev_get_platdata(dev);
> 
> Can you either mention the additional cleanup that you do in the commit
> log or split it in a separate commit? (splitting is probably not
> necessary here given that most of the cleanup anyway is related to the
> actual changes.

Do you mean the platform_data accessors? I can actually split it to a separate
change as I had done some of that in the past in other drivers.

...

> > -	ret = gpio_direction_output(pdata->gpio_reset, 1);
> > -	if (ret < 0) {
> > -		dev_crit(
> > -			&spi->dev,
> > -			"Reset GPIO %d did not set to output mode\n",
> > -			pdata->gpio_reset
> > -		);
> > -	}
> > -
> > -	return ret;
> > +	return PTR_ERR_OR_ZERO(pdata->reset_gpio);
> 
> This is not a strong request, but in general I think it is preferred to return
> immediately, so this looks easier to understand:

I used the same logic as in the original flow.

> +	pdata->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
> +	if (IS_ERR(pdata->reset_gpio)) {
> +		dev_crit(dev, "Reset GPIO did not set to output mode\n");
> +                return PTR_ERR(pdata->reset_pgio);
> +       }
> +
> +       return 0;

Sure I can do this in v2.

...

> Otherwise the rest lgtm.

Thank you for the review!