[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vf0W9Lge8ycQrx=Y-xKyH4rBr7EVsxLy8gsLZhtE2oqrA@mail.gmail.com>
Date: Sun, 14 Sep 2025 15:21:30 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Petre Rodan <petre.rodan@...dimension.ro>
Cc: Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 10/18] iio: accel: bma220: migrate to regmap API
On Sat, Sep 13, 2025 at 6:40 PM Petre Rodan <petre.rodan@...dimension.ro> wrote:
>
> Switch to regmap API.
...
> #define _BMA220_H
>
> #include <linux/pm.h>
> +#include <linux/regmap.h>
>
> +extern const struct regmap_config bma220_spi_regmap_config;
> extern const struct dev_pm_ops bma220_pm_ops;
> -struct spi_device;
So, you want
struct device;
instead.
> -int bma220_common_probe(struct spi_device *dev);
> +int bma220_common_probe(struct device *dev, struct regmap *regmap, int irq);
>
> #endif
...
> #include <linux/bits.h>
> +#include <linux/bitfield.h>
> +#include <linux/cleanup.h>
> +#include <linux/device.h>
> #include <linux/kernel.h>
> #include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/pm.h>
> +#include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> #include <linux/types.h>
> -#include <linux/spi/spi.h>
...
> +#define BMA220_WDT_MASK GENMASK(2, 1)
> +#define BMA220_WDT_OFF 0x0
> +#define BMA220_WDT_1MS BIT(1)
> +#define BMA220_WDT_10MS GENMASK(1, 0)
These do not look like bitfields, please use plain numbers (0, 2, 3).
I feel like I commented on this previous time and my comment was ignored...
...
> struct bma220_data {
> - struct spi_device *spi_device;
> + struct device *dev;
> + struct regmap *regmap;
Why do you need both? One can be derived from the other.
> struct mutex lock;
> + u8 range_idx;
> struct {
> s8 chans[3];
> /* Ensure timestamp is naturally aligned. */
> aligned_s64 timestamp;
> - } scan;
> - u8 tx_buf[2] __aligned(IIO_DMA_MINALIGN);
> + } scan __aligned(IIO_DMA_MINALIGN);
> };
...
> + struct device *dev = data->dev;
> static const char * const regulator_names[] = { "vddd", "vddio", "vdda" };
>
> - ret = devm_regulator_bulk_get_enable(&spi->dev,
> + ret = devm_regulator_bulk_get_enable(dev,
> ARRAY_SIZE(regulator_names),
> regulator_names);
> if (ret)
> - return dev_err_probe(&spi->dev, ret, "Failed to get regulators\n");
> + return dev_err_probe(dev, ret, "Failed to get regulators\n");
As I said... Do it early and you will have less unneeded churn in the future.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists