lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAd53p7sZL4ppWoXfeM8=N_ucjMUs3vv6-LoyLX4-beYE30fSQ@mail.gmail.com>
Date:   Wed, 23 Feb 2022 11:10:47 +0800
From:   Kai-Heng Feng <kai.heng.feng@...onical.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Lars-Peter Clausen <lars@...afoo.de>,
        Michael Hennerich <Michael.Hennerich@...log.com>,
        Jonathan Cameron <jic23@...nel.org>
Subject: Re: [PATCH v2 1/8] iio: accel: adxl345: Convert to use dev_err_probe()

On Tue, Feb 22, 2022 at 4:59 PM Andy Shevchenko
<andriy.shevchenko@...ux.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@...ux.intel.com>

Tested on ACPI based platform. Hence, for the whole series,

Tested-by: Kai-Heng Feng <kai.heng.feng@...onical.com>

> ---
> 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, &regval);
> -       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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ