* [PATCH] iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_dev_name
@ 2019-06-06 23:14 Lorenzo Bianconi
2019-06-07 8:55 ` Lorenzo Bianconi
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2019-06-06 23:14 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, lorenzo.bianconi, Vitor.Soares, boris.brezillon
Introduce st_lsm6dsx_dev_name lookup table to get device name. This is
a preliminary patch to add I3C support to st_lsm6dsx since i3c_device_id
data structure does not contain a name field
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +-
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++++++++-
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 3 +--
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 3 +--
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 004a8a1a0027..71627206fc30 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -302,7 +302,7 @@ struct st_lsm6dsx_hw {
static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
-int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
+int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
struct regmap *regmap);
int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor,
bool enable);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index cf82c9049945..339b75040732 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -70,6 +70,18 @@
#define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
#define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
+static const char st_lsm6dsx_dev_name[][32] = {
+ [ST_LSM6DS3_ID] = ST_LSM6DS3_DEV_NAME,
+ [ST_LSM6DS3H_ID] = ST_LSM6DS3H_DEV_NAME,
+ [ST_LSM6DSL_ID] = ST_LSM6DSL_DEV_NAME,
+ [ST_LSM6DSM_ID] = ST_LSM6DSM_DEV_NAME,
+ [ST_ISM330DLC_ID] = ST_ISM330DLC_DEV_NAME,
+ [ST_LSM6DSO_ID] = ST_LSM6DSO_DEV_NAME,
+ [ST_ASM330LHH_ID] = ST_ASM330LHH_DEV_NAME,
+ [ST_LSM6DSOX_ID] = ST_LSM6DSOX_DEV_NAME,
+ [ST_LSM6DSR_ID] = ST_LSM6DSR_DEV_NAME,
+};
+
static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
[ST_LSM6DSX_ID_ACC] = {
.reg = {
@@ -1041,11 +1053,12 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
return iio_dev;
}
-int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
+int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
struct regmap *regmap)
{
const struct st_lsm6dsx_shub_settings *hub_settings;
struct st_lsm6dsx_hw *hw;
+ const char *name;
int i, err;
hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
@@ -1070,6 +1083,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
if (err < 0)
return err;
+ name = st_lsm6dsx_dev_name[hw_id];
for (i = 0; i < ST_LSM6DSX_ID_EXT0; i++) {
hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i, name);
if (!hw->iio_devs[i])
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index f54370196098..47581a4e456e 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -36,8 +36,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client,
return PTR_ERR(regmap);
}
- return st_lsm6dsx_probe(&client->dev, client->irq,
- hw_id, id->name, regmap);
+ return st_lsm6dsx_probe(&client->dev, client->irq, hw_id, regmap);
}
static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index 4a4abb2935da..facf66978a4b 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -36,8 +36,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi)
return PTR_ERR(regmap);
}
- return st_lsm6dsx_probe(&spi->dev, spi->irq,
- hw_id, id->name, regmap);
+ return st_lsm6dsx_probe(&spi->dev, spi->irq, hw_id, regmap);
}
static const struct of_device_id st_lsm6dsx_spi_of_match[] = {
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_dev_name
2019-06-06 23:14 [PATCH] iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_dev_name Lorenzo Bianconi
@ 2019-06-07 8:55 ` Lorenzo Bianconi
0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2019-06-07 8:55 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, lorenzo.bianconi, Vitor.Soares, boris.brezillon
[-- Attachment #1: Type: text/plain, Size: 4452 bytes --]
> Introduce st_lsm6dsx_dev_name lookup table to get device name. This is
> a preliminary patch to add I3C support to st_lsm6dsx since i3c_device_id
> data structure does not contain a name field
>
Hi Jonathan,
please hold on with this patch, I will post a v2 moving device name in
st_lsm6dsx_settings
Regards,
Lorenzo
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +-
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++++++++-
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 3 +--
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 3 +--
> 4 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 004a8a1a0027..71627206fc30 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -302,7 +302,7 @@ struct st_lsm6dsx_hw {
> static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
> extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
>
> -int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
> +int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
> struct regmap *regmap);
> int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor,
> bool enable);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index cf82c9049945..339b75040732 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -70,6 +70,18 @@
> #define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
> #define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
>
> +static const char st_lsm6dsx_dev_name[][32] = {
> + [ST_LSM6DS3_ID] = ST_LSM6DS3_DEV_NAME,
> + [ST_LSM6DS3H_ID] = ST_LSM6DS3H_DEV_NAME,
> + [ST_LSM6DSL_ID] = ST_LSM6DSL_DEV_NAME,
> + [ST_LSM6DSM_ID] = ST_LSM6DSM_DEV_NAME,
> + [ST_ISM330DLC_ID] = ST_ISM330DLC_DEV_NAME,
> + [ST_LSM6DSO_ID] = ST_LSM6DSO_DEV_NAME,
> + [ST_ASM330LHH_ID] = ST_ASM330LHH_DEV_NAME,
> + [ST_LSM6DSOX_ID] = ST_LSM6DSOX_DEV_NAME,
> + [ST_LSM6DSR_ID] = ST_LSM6DSR_DEV_NAME,
> +};
> +
> static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = {
> [ST_LSM6DSX_ID_ACC] = {
> .reg = {
> @@ -1041,11 +1053,12 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
> return iio_dev;
> }
>
> -int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
> +int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
> struct regmap *regmap)
> {
> const struct st_lsm6dsx_shub_settings *hub_settings;
> struct st_lsm6dsx_hw *hw;
> + const char *name;
> int i, err;
>
> hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL);
> @@ -1070,6 +1083,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
> if (err < 0)
> return err;
>
> + name = st_lsm6dsx_dev_name[hw_id];
> for (i = 0; i < ST_LSM6DSX_ID_EXT0; i++) {
> hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i, name);
> if (!hw->iio_devs[i])
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index f54370196098..47581a4e456e 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -36,8 +36,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client,
> return PTR_ERR(regmap);
> }
>
> - return st_lsm6dsx_probe(&client->dev, client->irq,
> - hw_id, id->name, regmap);
> + return st_lsm6dsx_probe(&client->dev, client->irq, hw_id, regmap);
> }
>
> static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index 4a4abb2935da..facf66978a4b 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -36,8 +36,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi)
> return PTR_ERR(regmap);
> }
>
> - return st_lsm6dsx_probe(&spi->dev, spi->irq,
> - hw_id, id->name, regmap);
> + return st_lsm6dsx_probe(&spi->dev, spi->irq, hw_id, regmap);
> }
>
> static const struct of_device_id st_lsm6dsx_spi_of_match[] = {
> --
> 2.21.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-07 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 23:14 [PATCH] iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_dev_name Lorenzo Bianconi
2019-06-07 8:55 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).