From: Jonathan Cameron <jic23@kernel.org>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>
Subject: Re: [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe()
Date: Sat, 26 Feb 2022 19:12:28 +0000 [thread overview]
Message-ID: <20220226191228.2d0eca14@jic23-huawei> (raw)
In-Reply-To: <CAAd53p7sZL4ppWoXfeM8=N_ucjMUs3vv6-LoyLX4-beYE30fSQ@mail.gmail.com>
On Wed, 23 Feb 2022 11:10:47 +0800
Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
> On Tue, Feb 22, 2022 at 4:59 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > It's fine to call dev_err_probe() in ->probe() when error code is known.
> > Convert the driver to use dev_err_probe().
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Tested on ACPI based platform. Hence, for the whole series,
>
> Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Series applied to the togreg branch of iio.git and pushed out as testing
to let 0-day see if it can find anything we missed.
Thanks,
Jonathan
>
> > ---
> > v2: fixed typo (LKP), shorten one line to satisfy checkpatch
> > drivers/iio/accel/adxl345_core.c | 26 +++++++++-----------------
> > drivers/iio/accel/adxl345_i2c.c | 7 ++-----
> > drivers/iio/accel/adxl345_spi.c | 15 +++++----------
> > 3 files changed, 16 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
> > index ef2240e356e0..078e1029e49d 100644
> > --- a/drivers/iio/accel/adxl345_core.c
> > +++ b/drivers/iio/accel/adxl345_core.c
> > @@ -222,16 +222,12 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
> > int ret;
> >
> > ret = regmap_read(regmap, ADXL345_REG_DEVID, ®val);
> > - if (ret < 0) {
> > - dev_err(dev, "Error reading device ID: %d\n", ret);
> > - return ret;
> > - }
> > + if (ret < 0)
> > + return dev_err_probe(dev, ret, "Error reading device ID\n");
> >
> > - if (regval != ADXL345_DEVID) {
> > - dev_err(dev, "Invalid device ID: %x, expected %x\n",
> > - regval, ADXL345_DEVID);
> > - return -ENODEV;
> > - }
> > + if (regval != ADXL345_DEVID)
> > + return dev_err_probe(dev, -ENODEV, "Invalid device ID: %x, expected %x\n",
> > + regval, ADXL345_DEVID);
> >
> > indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > if (!indio_dev)
> > @@ -245,10 +241,8 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
> >
> > ret = regmap_write(data->regmap, ADXL345_REG_DATA_FORMAT,
> > data->data_range);
> > - if (ret < 0) {
> > - dev_err(dev, "Failed to set data range: %d\n", ret);
> > - return ret;
> > - }
> > + if (ret < 0)
> > + return dev_err_probe(dev, ret, "Failed to set data range\n");
> >
> > indio_dev->name = name;
> > indio_dev->info = &adxl345_info;
> > @@ -259,10 +253,8 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
> > /* Enable measurement mode */
> > ret = regmap_write(data->regmap, ADXL345_REG_POWER_CTL,
> > ADXL345_POWER_CTL_MEASURE);
> > - if (ret < 0) {
> > - dev_err(dev, "Failed to enable measurement mode: %d\n", ret);
> > - return ret;
> > - }
> > + if (ret < 0)
> > + return dev_err_probe(dev, ret, "Failed to enable measurement mode\n");
> >
> > ret = devm_add_action_or_reset(dev, adxl345_powerdown, data->regmap);
> > if (ret < 0)
> > diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
> > index 7bc8324c4f07..e3205dce91b8 100644
> > --- a/drivers/iio/accel/adxl345_i2c.c
> > +++ b/drivers/iio/accel/adxl345_i2c.c
> > @@ -28,11 +28,8 @@ static int adxl345_i2c_probe(struct i2c_client *client,
> > return -ENODEV;
> >
> > regmap = devm_regmap_init_i2c(client, &adxl345_i2c_regmap_config);
> > - if (IS_ERR(regmap)) {
> > - dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
> > - PTR_ERR(regmap));
> > - return PTR_ERR(regmap);
> > - }
> > + if (IS_ERR(regmap))
> > + return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
> >
> > return adxl345_core_probe(&client->dev, regmap, id->driver_data,
> > id->name);
> > diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c
> > index c752562c5d3b..9223302fdd46 100644
> > --- a/drivers/iio/accel/adxl345_spi.c
> > +++ b/drivers/iio/accel/adxl345_spi.c
> > @@ -26,18 +26,13 @@ static int adxl345_spi_probe(struct spi_device *spi)
> > struct regmap *regmap;
> >
> > /* Bail out if max_speed_hz exceeds 5 MHz */
> > - if (spi->max_speed_hz > ADXL345_MAX_SPI_FREQ_HZ) {
> > - dev_err(&spi->dev, "SPI CLK, %d Hz exceeds 5 MHz\n",
> > - spi->max_speed_hz);
> > - return -EINVAL;
> > - }
> > + if (spi->max_speed_hz > ADXL345_MAX_SPI_FREQ_HZ)
> > + return dev_err_probe(&spi->dev, -EINVAL, "SPI CLK, %d Hz exceeds 5 MHz\n",
> > + spi->max_speed_hz);
> >
> > regmap = devm_regmap_init_spi(spi, &adxl345_spi_regmap_config);
> > - if (IS_ERR(regmap)) {
> > - dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
> > - PTR_ERR(regmap));
> > - return PTR_ERR(regmap);
> > - }
> > + if (IS_ERR(regmap))
> > + return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n");
> >
> > return adxl345_core_probe(&spi->dev, regmap, id->driver_data, id->name);
> > }
> > --
> > 2.34.1
> >
prev parent reply other threads:[~2022-02-26 19:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 9:00 [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe() Andy Shevchenko
2022-02-22 9:00 ` [PATCH v2 2/8] iio: accel: adxl345: Set driver_data for OF enumeration Andy Shevchenko
2022-02-22 9:00 ` [PATCH v2 3/8] iio: accel: adxl345: Get rid of name parameter in adxl345_core_probe() Andy Shevchenko
2022-02-26 18:54 ` Jonathan Cameron
2022-02-22 9:00 ` [PATCH v2 4/8] iio: accel: adxl345: Make use of device properties Andy Shevchenko
2022-02-26 19:05 ` Jonathan Cameron
2022-02-27 11:22 ` Jonathan Cameron
2022-02-22 9:00 ` [PATCH v2 5/8] iio: accel: adxl345: Add ACPI HID table Andy Shevchenko
2022-02-22 9:00 ` [PATCH v2 6/8] iio: accel: adxl345: Extract adxl345_powerup() helper Andy Shevchenko
2022-02-22 9:00 ` [PATCH v2 7/8] iio: accel: adxl345: Drop comma in terminator entries Andy Shevchenko
2022-02-22 9:00 ` [PATCH v2 8/8] iio: accel: adxl345: Remove unneeded blank lines Andy Shevchenko
2022-02-23 3:10 ` [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe() Kai-Heng Feng
2022-02-26 19:12 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220226191228.2d0eca14@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=kai.heng.feng@canonical.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox