Re: [PATCH v2 01/12] iio:dac:ad5755: Switch to generic firmware properties and drop pdata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 4, 2021 at 7:07 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
> Lars pointed out that platform data can also be supported via the
> generic properties interface, so there is no point in continuing to
> support it separately.  Hence squish the linux/platform_data/ad5755.h
> header into the c file and drop accessing the platform data directly.
>
> Done by inspection only.  Mostly completely mechanical with the
> exception of a few places where default value handling is
> cleaner done by first setting the value, then calling the
> firmware reading function but and not checking the return value,
> as opposed to reading firmware then setting the default if an error
> occurs.
>
> Part of general attempt to move all of IIO over to generic
> device properties, both to enable other firmware types and
> to remove drivers that can be the source of of_ specific
> behaviour in new drivers.

...

>  #include <linux/slab.h>
>  #include <linux/sysfs.h>
>  #include <linux/delay.h>
> -#include <linux/of.h>
> +#include <linux/property.h>

I would also add a blank line here.

>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> -#include <linux/platform_data/ad5755.h>

...


> +       const struct ad5755_platform_data *pdata = NULL;
>         struct iio_dev *indio_dev;
>         struct ad5755_state *st;
>         int ret;


> -       if (spi->dev.of_node)
> -               pdata = ad5755_parse_dt(&spi->dev);
> -       else
> -               pdata = spi->dev.platform_data;
> +       if (dev_fwnode(&spi->dev))
> +               pdata = ad5755_parse_fw(&spi->dev);
>
>         if (!pdata) {
> -               dev_warn(&spi->dev, "no platform data? using default\n");
> +               dev_warn(&spi->dev,
> +                        "no firmware provided parameters? using default\n");

It's fine to have it on one line (and not related to the 80 vs 100
case, it's about string literal as the last argument).

>                 pdata = &ad5755_default_pdata;
>         }


Perhaps

    const struct ad5755_platform_data *pdata;
    ...
    if (dev_fwnode(...))
      pdata = ...
    else
      pdata = &_default;
    if (pdata == &_default)
      dev_warn(...);

?

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux