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: <20220226185458.6cd6848a@jic23-huawei>
Date:   Sat, 26 Feb 2022 18:54:58 +0000
From:   Jonathan Cameron <jic23@...nel.org>
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>,
        Kai-Heng Feng <kai.heng.feng@...onical.com>
Subject: Re: [PATCH v2 3/8] iio: accel: adxl345: Get rid of name parameter
 in adxl345_core_probe()

On Tue, 22 Feb 2022 11:00:04 +0200
Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:

> As a preparation to switch to use device properties, get rid of name
> parameter in adxl345_core_probe(). Instead, choose it based on the type.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> v2: no changes
>  drivers/iio/accel/adxl345.h      |  3 +--
>  drivers/iio/accel/adxl345_core.c | 15 +++++++++++++--
>  drivers/iio/accel/adxl345_i2c.c  |  3 +--
>  drivers/iio/accel/adxl345_spi.c  |  2 +-
>  4 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h
> index 5a68d4dac717..9b0d4f487c43 100644
> --- a/drivers/iio/accel/adxl345.h
> +++ b/drivers/iio/accel/adxl345.h
> @@ -13,7 +13,6 @@ enum adxl345_device_type {
>  	ADXL375 = 2,
>  };
>  
> -int adxl345_core_probe(struct device *dev, struct regmap *regmap,
> -		       enum adxl345_device_type type, const char *name);
> +int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type);

Nit picking but I'm not that keen on these lines being so long as it doesn't
really help readability so I'd rather keep them sub 80 chars.

If I'm happy with everything else I might tidy that up whilst applying.

Thanks,

Jonathan



>  
>  #endif /* _ADXL345_H_ */
> diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
> index 078e1029e49d..0f34c349aa1e 100644
> --- a/drivers/iio/accel/adxl345_core.c
> +++ b/drivers/iio/accel/adxl345_core.c
> @@ -213,14 +213,25 @@ static void adxl345_powerdown(void *regmap)
>  	regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY);
>  }
>  
> -int adxl345_core_probe(struct device *dev, struct regmap *regmap,
> -		       enum adxl345_device_type type, const char *name)
> +int adxl345_core_probe(struct device *dev, struct regmap *regmap, enum adxl345_device_type type)
>  {
>  	struct adxl345_data *data;
>  	struct iio_dev *indio_dev;
> +	const char *name;
>  	u32 regval;
>  	int ret;
>  
> +	switch (type) {
> +	case ADXL345:
> +		name = "adxl345";
> +		break;
> +	case ADXL375:
> +		name = "adxl375";
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
>  	ret = regmap_read(regmap, ADXL345_REG_DEVID, &regval);
>  	if (ret < 0)
>  		return dev_err_probe(dev, ret, "Error reading device ID\n");
> diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
> index 4c6efe2eefc1..1e42cf3a2991 100644
> --- a/drivers/iio/accel/adxl345_i2c.c
> +++ b/drivers/iio/accel/adxl345_i2c.c
> @@ -31,8 +31,7 @@ static int adxl345_i2c_probe(struct i2c_client *client,
>  	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);
> +	return adxl345_core_probe(&client->dev, regmap, id->driver_data);
>  }
>  
>  static const struct i2c_device_id adxl345_i2c_id[] = {
> diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c
> index 72550132b1bb..34b7001d519f 100644
> --- a/drivers/iio/accel/adxl345_spi.c
> +++ b/drivers/iio/accel/adxl345_spi.c
> @@ -34,7 +34,7 @@ static int adxl345_spi_probe(struct spi_device *spi)
>  	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);
> +	return adxl345_core_probe(&spi->dev, regmap, id->driver_data);
>  }
>  
>  static const struct spi_device_id adxl345_spi_id[] = {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ