iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer
Subsystems (3)
v8 cover iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer
Hello everyone,
Version 8 for adding support for the kx132-1211 accelerometer
KX132-1211 accelerometer is a sensor which:
- supports G-ranges of (+/-) 2, 4, 8, and 16G
- can be connected to I2C or SPI
- has internal HW FIFO buffer
- supports various ODRs (output data rates)
The KX132-1211 accelerometer is very similar to the KX022A.
One key difference is number of bits to report the number of data bytes that have been stored in the buffer: 8 bits for KX022A vs 10 bits for KX132-1211.
Changes in v8:
- replaced min_t by min and kmalloc by kmalloc_array as suggested by Andy
Changes in v7:
- added a min_t in kx132_get_fifo_bytes to ensure that we don't that the fifo_bytes is never bigger than the
fifo_length * KX022A_FIFO_SAMPLES_SIZE_BYTES - no matter what we read from I2C as suggested by Matti
Changes in v6:
- check for availability of chip_info for the SPI case
- changed the order of elements in the kx022a_data struct to save memory
Changes in v5:
- moved the "kfree" call to match the reverse of what happens in kx022a_fifo_enable() as suggested by Matti and Jonathan
- used min_t, checked for availability of chip_info and moved the position of u16 buf_smp_lvl_mask as suggested by Andy
- introduced buf_smp_lvl_mask in Patch 7 as suggested by Jonathan
Changes in v4:
- moved the allocation of the fifo_buffer to kx022a_fifo_enable and kx022a_fifo_disable
- some fixes to the regmap ranges of kx132-1211
Changes in v3:
- added two new patches by separating the addition of the i2c_device_id table and the removal of blank lines from other unrelated changes
- fixes a warning detected by the kernel test robot
- made all the changes related the chip_info in one patch
Changes in v2:
- added a new patch for warning when the device_id match fails in the probe function
- added a new patch for the function that retrieves the number of bytes in the buffer
- added a change to the Kconfig file in the patch adding the support for the kx132-1211
- various fixes and modifications listed under each patch
Mehdi Djait (7):
dt-bindings: iio: Add KX132-1211 accelerometer
iio: accel: kionix-kx022a: Remove blank lines
iio: accel: kionix-kx022a: Warn on failed matches and assume
compatibility
iio: accel: kionix-kx022a: Add an i2c_device_id table
iio: accel: kionix-kx022a: Refactor driver and add chip_info structure
iio: accel: kionix-kx022a: Add a function to retrieve number of bytes
in buffer
iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer
.../bindings/iio/accel/kionix,kx022a.yaml | 12 +- drivers/iio/accel/Kconfig | 8 +- drivers/iio/accel/kionix-kx022a-i2c.c | 25 +- drivers/iio/accel/kionix-kx022a-spi.c | 15 +- drivers/iio/accel/kionix-kx022a.c | 315 ++++++++++++++---- drivers/iio/accel/kionix-kx022a.h | 110 +++++- 6 files changed, 410 insertions(+), 75 deletions(-)
Signature · 1 line
2.30.2
PATCH v8 1/7 dt-bindings: iio: Add KX132-1211 accelerometer
Extend the kionix,kx022a.yaml file to support the kx132-1211 device
---
v8:
v7:
v6:
v5:
v4:
v3:
- no changes
.../devicetree/bindings/iio/accel/kionix,kx022a.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml +7 -5
@@ -4,19 +4,21 @@ $id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM/Kionix KX022A Accelerometer +title: ROHM/Kionix KX022A and KX132-1211 Accelerometers maintainers: - Matti Vaittinen <[email protected]> description: | - KX022A is a 3-axis accelerometer supporting +/- 2G, 4G, 8G and 16G ranges, - output data-rates from 0.78Hz to 1600Hz and a hardware-fifo buffering. - KX022A can be accessed either via I2C or SPI. + KX022A and KX132-1211 are 3-axis accelerometers supporting +/- 2G, 4G, 8G and + 16G ranges, variable output data-rates and a hardware-fifo buffering. + KX022A and KX132-1211 can be accessed either via I2C or SPI. properties: compatible: - const: kionix,kx022a + enum: + - kionix,kx022a + - kionix,kx132-1211 reg: maxItems: 1
Signature · 1 line
2.30.2
PATCH v8 2/7 iio: accel: kionix-kx022a: Remove blank lines
In reply to Mehdi DjaitRemove blank lines pointed out by the checkpatch script
---
v8:
v7:
v6:
v5:
v4:
- no changes
v3:
- no changes, this patch is introduced in the v2
drivers/iio/accel/kionix-kx022a.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/accel/kionix-kx022a.c +0 -2
@@ -341,7 +341,6 @@ static int kx022a_turn_on_off_unlocked(struct kx022a_data *data, bool on)dev_err (data->dev,"Turn %s fail %d\n" ,str_on_off (on), ret);return ret; - }static int kx022a_turn_off_lock (struct kx022a_data *data)
@@ -1121,7 +1120,6 @@ int kx022a_probe_internal(struct device *dev)if (ret)return dev_err_probe (data->dev, ret,"Could not request IRQ\n" ); - ret =devm_iio_trigger_register (dev, indio_trig);if (ret) return dev_err_probe(data->dev, ret,
Signature · 1 line
2.30.2
Re: [PATCH v8 2/7] iio: accel: kionix-kx022a: Remove blank lines
Quoted 1 line · Mehdi Djait
Remove blank lines pointed out by the checkpatch script
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v8 3/7 iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility
In reply to Mehdi DjaitAvoid error returns on a failure to match and instead just warn with assumption that we have a correct dt-binding telling us that some new device with a different ID is backwards compatible.
---
v8:
v7:
v6:
v5:
v4:
- no changes
v3:
- changed from 'unsupported' to 'unknown'
- removed the opening bracket
v2:
- no changes, this patch is introduced in the v2
drivers/iio/accel/kionix-kx022a.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/accel/kionix-kx022a.c +2 -4
@@ -1036,10 +1036,8 @@ int kx022a_probe_internal(struct device *dev)if (ret)return dev_err_probe (dev, ret,"Failed to access sensor\n" ); -if (chip_id !=KX022A_ID ) { -dev_err (dev,"unsupported device 0x%x\n" , chip_id); -return -EINVAL ; - } +if (chip_id !=KX022A_ID ) +dev_warn (dev,"unknown device 0x%x\n" , chip_id); irq =fwnode_irq_get_byname (fwnode,"INT1" );if (irq >0 ) {
Signature · 1 line
2.30.2
Re: [PATCH v8 3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility
Quoted 3 lines · Mehdi Djait
Avoid error returns on a failure to match and instead just warn with assumption that we have a correct dt-binding telling us that some new device with a different ID is backwards compatible.
As we already discussed in the past I think this patch might be not okay in case a hardware vendor decides to make incompatible device with non-supported yet ID. It might be even harmful to the hardware to program register without knowing that this is safe.
That said, I'm neither NAKing nor reviewing this and leave to maintainers to decide.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v8 3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility
Quoted 9 lines · On Thu, 24 Aug 2023 14:51:49 +0300 Andy Shevchenko…
Quoted 3 lines · Mehdi Djait
Avoid error returns on a failure to match and instead just warn with assumption that we have a correct dt-binding telling us that some new device with a different ID is backwards compatible.
As we already discussed in the past I think this patch might be not okay in case a hardware vendor decides to make incompatible device with non-supported yet ID. It might be even harmful to the hardware to program register without knowing that this is safe.
That only matters if they 'claim' it is compatible. Otherwise the driver never probes and we are fine.
DT maintainers view was that the job of the kernel was not to defend against bugs in device tree firmwares or someone binding the driver to the wrong device by hand.
Quoted 4 lines
That said, I'm neither NAKing nor reviewing this and leave to maintainers to decide.
PATCH v8 4/7 iio: accel: kionix-kx022a: Add an i2c_device_id table
In reply to Mehdi DjaitAdd the missing i2c device id.
---
v8:
v7:
v6:
v5:
v4:
- no changes
v3:
- no changes, this patch is introduced in the v2
drivers/iio/accel/kionix-kx022a-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/accel/kionix-kx022a-i2c.c +7 -0
@@ -30,6 +30,12 @@ static int kx022a_i2c_probe(struct i2c_client *i2c)return kx022a_probe_internal (dev); } +static const struct i2c_device_id kx022a_i2c_id[] = { + { .name ="kx022a" }, + { } +}; +MODULE_DEVICE_TABLE (i2c, kx022a_i2c_id); +static const struct of_device_id kx022a_of_match[] = { { .compatible ="kionix,kx022a" , }, { }
@@ -42,6 +48,7 @@ static struct i2c_driver kx022a_i2c_driver = { .of_match_table = kx022a_of_match, }, .probe_new = kx022a_i2c_probe, + .id_table = kx022a_i2c_id, };module_i2c_driver (kx022a_i2c_driver);
Signature · 1 line
2.30.2
Re: [PATCH v8 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table
Quoted 1 line · Mehdi Djait
Add the missing i2c device id.
This needs an explanation. Why do we need legacy table, what for?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v8 5/7 iio: accel: kionix-kx022a: Refactor driver and add chip_info structure
In reply to Mehdi DjaitAdd the chip_info structure to the driver's private data to hold all the device specific infos.
Refactor the kx022a driver implementation to make it more generic and extensible.
---
v8:
- replaced min_t() by min() and kmalloc() by kmalloc_array()
v7:
- no changes
v6:
- placed chip_info after the regmap elemnt in kx022a_data struct to save memory as suggested by Andy
- added a check for the availability of chip_info for the SPI case as suggested by Andy
v5:
- moved the "kfree" call to match the reverse of what happens in kx022a_fifo_enable() as suggested by Matti and Jonathan
- used min_t, checked for availability of chip_info as suggested by Andy
v4:
- allocating and freeing the buffer moved to the kx022a_fifo{enable, disable} functions
- used the spi_get_device_match_data helper function
v3:
- added the change of the buffer's allocation in the __kx022a_fifo_flush to this patch
- added the chip_info to the struct kx022a_data
drivers/iio/accel/kionix-kx022a-i2c.c | 18 +++- drivers/iio/accel/kionix-kx022a-spi.c | 13 ++- drivers/iio/accel/kionix-kx022a.c | 117 +++++++++++++++++--------- drivers/iio/accel/kionix-kx022a.h | 52 +++++++++++- 4 files changed, 148 insertions(+), 52 deletions(-)
drivers/iio/accel/kionix-kx022a-i2c.c +14 -4
@@ -15,6 +15,7 @@static int kx022a_i2c_probe (struct i2c_client *i2c) {struct device *dev = &i2c->dev; +const struct kx022a_chip_info *chip_info;struct regmap *regmap;if (!i2c->irq) {
@@ -22,22 +23,31 @@ static int kx022a_i2c_probe(struct i2c_client *i2c)return -EINVAL ; } - regmap =devm_regmap_init_i2c (i2c, &kx022a_regmap); + chip_info =device_get_match_data (&i2c->dev); +if (!chip_info) { +const struct i2c_device_id *id =i2c_client_get_device_id (i2c); + + chip_info = (const struct kx022a_chip_info *)id->driver_data; +if (!chip_info) +return -EINVAL ; + } + + regmap =devm_regmap_init_i2c (i2c, chip_info->regmap_config);if (IS_ERR (regmap))return dev_err_probe (dev,PTR_ERR (regmap),"Failed to initialize Regmap\n" ); -return kx022a_probe_internal (dev); +return kx022a_probe_internal (dev, chip_info); }static const struct i2c_device_id kx022a_i2c_id[] = { - { .name ="kx022a" }, + { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { } };MODULE_DEVICE_TABLE (i2c, kx022a_i2c_id);static const struct of_device_id kx022a_of_match[] = { - { .compatible ="kionix,kx022a" , }, + { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a-spi.c +9 -4
@@ -15,6 +15,7 @@static int kx022a_spi_probe (struct spi_device *spi) {struct device *dev = &spi->dev; +const struct kx022a_chip_info *chip_info;struct regmap *regmap;if (!spi->irq) {
@@ -22,22 +23,26 @@ static int kx022a_spi_probe(struct spi_device *spi)return -EINVAL ; } - regmap =devm_regmap_init_spi (spi, &kx022a_regmap); + chip_info =spi_get_device_match_data (spi); +if (!chip_info) +return -EINVAL ; + + regmap =devm_regmap_init_spi (spi, chip_info->regmap_config);if (IS_ERR (regmap))return dev_err_probe (dev,PTR_ERR (regmap),"Failed to initialize Regmap\n" ); -return kx022a_probe_internal (dev); +return kx022a_probe_internal (dev, chip_info); }static const struct spi_device_id kx022a_id[] = { - {"kx022a" }, + { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { } };MODULE_DEVICE_TABLE (spi, kx022a_id);static const struct of_device_id kx022a_of_match[] = { - { .compatible ="kionix,kx022a" , }, + { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a.c +75 -42
332 lines not on this page · raw message
drivers/iio/accel/kionix-kx022a.h +50 -2
57 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v8 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure
Quoted 4 lines · Mehdi Djait
Add the
chip_infostructure to the driver's private data to hold all the device specific infos.
Refactor the kx022a driver implementation to make it more generic and extensible.
...
drivers/iio/accel/kionix-kx022a-i2c.c static int kx022a_i2c_probe(struct i2c_client *i2c) · line 33
Quoted 8 lines
drivers/iio/accel/kionix-kx022a-i2c.c +8
-0+ chip_info =device_get_match_data (&i2c->dev); +if (!chip_info) { +const struct i2c_device_id *id =i2c_client_get_device_id (i2c); + + chip_info = (const struct kx022a_chip_info *)id->driver_data; +if (!chip_info) +return -EINVAL ; + }
There is a new API for that, please use it.
...
Quoted 1 line
+/* kx022a Regmap configs */
regmap
...
drivers/iio/accel/kionix-kx022a.c int kx022a_probe_internal(struct device *dev) · line 1081
Quoted 2 lines
drivers/iio/accel/kionix-kx022a.c +0
-0irq =fwnode_irq_get_byname (fwnode,"INT2" );if (irq <=0 )
= 0 case is fixed now, means should never appear here, but it's a material for another, separate change.
Quoted 1 line
return
dev_err_probe(dev, irq, "No suitable IRQ\n");
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v8 6/7 iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
In reply to Mehdi DjaitSince Kionix accelerometers use various numbers of bits to report data, a device-specific function is required.
Implement the function as a callback in the device-specific chip_info structure
---
v8:
v7:
- no changes
v6:
- directly return KX022A_FIFO_MAX_BYTES as suggested by Andy
v5:
- no changes
v4:
- removed the comment about "bogus value from i2c"
- removed regmap_get_device(data->regmap); dev is present in the driver's private data
v3:
- no changes
v2:
- separated this change from the chip_info introduction and made it a patch in v2
- changed the function from generic implementation for to device-specific one
- removed blank lines pointed out by checkpatch
- changed the allocation of the "buffer" array in __kx022a_fifo_flush
drivers/iio/accel/kionix-kx022a.c | 28 ++++++++++++++++++---------- drivers/iio/accel/kionix-kx022a.h | 4 ++++ 2 files changed, 22 insertions(+), 10 deletions(-)
drivers/iio/accel/kionix-kx022a.c +18 -10
@@ -596,26 +596,33 @@ static int kx022a_drop_fifo_contents(struct kx022a_data *data)return regmap_write (data->regmap, data->chip_info->buf_clear,0x0 ); } +static int kx022a_get_fifo_bytes (struct kx022a_data *data) +{ +int ret, fifo_bytes; + + ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); +if (ret) { +dev_err (data->dev,"Error reading buffer status\n" ); +return ret; + } + +if (fifo_bytes ==KX022A_FIFO_FULL_VALUE ) +return KX022A_FIFO_MAX_BYTES ; + +return fifo_bytes; +} +static int __kx022a_fifo_flush (struct iio_dev *idev,unsigned int samples,bool irq) {struct kx022a_data *data =iio_priv (idev); -struct device *dev =regmap_get_device (data->regmap);uint64_t sample_period;int count, fifo_bytes;bool renable = false;int64_t tstamp;int ret, i; - ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); -if (ret) { -dev_err (dev,"Error reading buffer status\n" ); -return ret; - } - -/* Let's not overflow if we for some reason get bogus value from i2c */ -if (fifo_bytes ==KX022A_FIFO_FULL_VALUE ) - fifo_bytes =KX022A_FIFO_MAX_BYTES ; + fifo_bytes = data->chip_info->get_fifo_bytes (data);if (fifo_bytes %KX022A_FIFO_SAMPLES_SIZE_BYTES )dev_warn (data->dev,"Bad FIFO alignment. Data may be corrupt\n" );
@@ -1024,6 +1031,7 @@ const struct kx022a_chip_info kx022a_chip_info = { .inc5 = KX022A_REG_INC5, .inc6 = KX022A_REG_INC6, .xout_l = KX022A_REG_XOUT_L, + .get_fifo_bytes = kx022a_get_fifo_bytes, };EXPORT_SYMBOL_NS_GPL (kx022a_chip_info,IIO_KX022A );
drivers/iio/accel/kionix-kx022a.h +4 -0
@@ -76,6 +76,8 @@struct device ; +struct kx022a_data ; +/** * struct kx022a_chip_info - Kionix accelerometer chip specific information *
@@ -99,6 +101,7 @@ struct device;* @inc5: interrupt control register 5 * @inc6: interrupt control register 6 * @xout_l: x-axis output least significant byte +* @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer */ struct kx022a_chip_info {const char *name;
@@ -121,6 +124,7 @@ struct kx022a_chip_info {u8 inc5;u8 inc6;u8 xout_l; +int (*get_fifo_bytes)(struct kx022a_data *); };int kx022a_probe_internal (struct device *dev,const struct kx022a_chip_info *chip_info);
Signature · 1 line
2.30.2
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 3 lines · Mehdi Djait
Since Kionix accelerometers use various numbers of bits to report data, a device-specific function is required.
Implement the function as a callback in the device-specificchip_infostructure
...
drivers/iio/accel/kionix-kx022a.c static int kx022a_drop_fifo_contents(struct kx022a_data *data) · line 612
Quoted 12 lines
drivers/iio/accel/kionix-kx022a.c +12
-0+int ret, fifo_bytes; + + ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); +if (ret) { +dev_err (data->dev,"Error reading buffer status\n" ); +return ret; + } + +if (fifo_bytes ==KX022A_FIFO_FULL_VALUE ) +return KX022A_FIFO_MAX_BYTES ; + +return fifo_bytes;
This will be called each time ->get_fifo_bytes() called. Do you expect the fifo_bytes to be changed over times? Shouldn't we simply cache the value?
...
drivers/iio/accel/kionix-kx022a.c static int kx022a_drop_fifo_contents(struct kx022a_data *data) · line 625
Quoted 3 lines
drivers/iio/accel/kionix-kx022a.c +1
-0+ fifo_bytes = data->chip_info->get_fifo_bytes (data);
Now this blank line becomes redundant.
Quoted 2 lines
drivers/iio/accel/kionix-kx022a.c +0
-0if (fifo_bytes %KX022A_FIFO_SAMPLES_SIZE_BYTES )dev_warn (data->dev,"Bad FIFO alignment. Data may be corrupt\n" );
Signature · 2 lines
With Best Regards, Andy Shevchenko
Matti Vaittinen
maintainerRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Mehdi Djait
Since Kionix accelerometers use various numbers of bits to report data, a device-specific function is required.
Implement the function as a callback in the device-specificchip_infostructure...
Quoted 16 lines
drivers/iio/accel/kionix-kx022a.c static int kx022a_drop_fifo_contents(struct kx022a_data *data) · line 612
Quoted 12 lines
drivers/iio/accel/kionix-kx022a.c +12
-0+int ret, fifo_bytes; + + ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); +if (ret) { +dev_err (data->dev,"Error reading buffer status\n" ); +return ret; + } + +if (fifo_bytes ==KX022A_FIFO_FULL_VALUE ) +return KX022A_FIFO_MAX_BYTES ; + +return fifo_bytes;This will be called each time ->get_fifo_bytes() called. Do you expect the
fifo_bytesto be changed over times? Shouldn't we simply cache the value?
I think this value tells how many samples there currently is in the FIFO. Caching it does not sound meaningful unless I am missing something.
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:
...
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/iio/accel/kionix-kx022a.c +8
-0+int ret, fifo_bytes; + + ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); +if (ret) { +dev_err (data->dev,"Error reading buffer status\n" ); +return ret; + } +Quoted 8 lines
drivers/iio/accel/kionix-kx022a.c static int kx022a_drop_fifo_contents(struct kx022a_data *data) · line 612
Quoted 4 lines
drivers/iio/accel/kionix-kx022a.c +4
-0+if (fifo_bytes ==KX022A_FIFO_FULL_VALUE ) +return KX022A_FIFO_MAX_BYTES ; + +return fifo_bytes;This will be called each time ->get_fifo_bytes() called. Do you expect the
fifo_bytesto be changed over times? Shouldn't we simply cache the value?
Quoted 2 lines
I think this value tells how many samples there currently is in the FIFO. Caching it does not sound meaningful unless I am missing something.
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()
or
get_bytes_in_fifo()
or alike.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Hello Andy,
Thank you for the review.
Quoted 29 lines · Andy Shevchenko
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:
...
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
+ int ret,
fifo_bytes;drivers/iio/accel/kionix-kx022a.c +7
-0+ + ret =regmap_read (data->regmap,KX022A_REG_BUF_STATUS_1 , &fifo_bytes); +if (ret) { +dev_err (data->dev,"Error reading buffer status\n" ); +return ret; + } +Quoted 8 lines
drivers/iio/accel/kionix-kx022a.c static int kx022a_drop_fifo_contents(struct kx022a_data *data) · line 612
Quoted 4 lines
+ if (
fifo_bytes==KX022A_FIFO_FULL_VALUE)drivers/iio/accel/kionix-kx022a.c +3
-0+return KX022A_FIFO_MAX_BYTES ; + +return fifo_bytes;This will be called each time ->get_fifo_bytes() called. Do you expect the
fifo_bytesto be changed over times? Shouldn't we simply cache the value?Quoted 2 lines
I think this value tells how many samples there currently is in the FIFO. Caching it does not sound meaningful unless I am missing something.
I see. I think my confusion can be easily cured by renaming the callback to
Quoted 7 lines
get_amount_bytes_in_fifo()or
get_bytes_in_fifo()or alike.
or leave it as is. The function is documented:
@@ -99,6 +101,7 @@ struct device;
* @inc5: interrupt control register 5
* @inc6: interrupt control register 6
* @xout_l: x-axis output least significant byte
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer */
struct kx022a_chip_info {
const char *name;
@@ -121,6 +124,7 @@ struct kx022a_chip_info {
u8 inc5;
u8 inc6;
u8 xout_l;
+ int (*get_fifo_bytes)(struct kx022a_data *);
};
--
Kind Regards
Mehdi Djait
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 5 lines · Mehdi Djait
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:
...
Quoted 6 lines
Quoted 6 lines
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()or
Quoted 7 lines
Quoted 3 lines
get_bytes_in_fifo()or alike.
or leave it as is. The function is documented:
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer
Do you find it unambiguous? I do not.
Still needs more words to explain if it's a capacity of FIFO or is it amount of valid bytes for the current transfer or what?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Mehdi Djait
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:
...
Quoted 10 lines
Quoted 9 lines
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()or
get_bytes_in_fifo()or alike.
Quoted 8 lines
Quoted 3 lines
or leave it as is. The function is documented:
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer
Do you find it unambiguous? I do not.
Still needs more words to explain if it's a capacity of FIFO or is it amount of valid bytes for the current transfer or what?
how about change the description to:
function pointer to get amount of acceleration data bytes currently stored in the sensor's FIFO buffer
and change the function to "get_amount_bytes_in_fifo()"
--
Kind Regards
Mehdi Djait
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 8 lines · Mehdi Djait
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Mehdi Djait
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:40PM +0200, Mehdi Djait wrote:
...
Quoted 16 lines
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()or
Quoted 7 lines
Quoted 3 lines
get_bytes_in_fifo()or alike.
or leave it as is. The function is documented:
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer
Do you find it unambiguous? I do not.
Quoted 8 lines
Quoted 2 lines
Still needs more words to explain if it's a capacity of FIFO or is it amount of valid bytes for the current transfer or what?
how about change the description to:
function pointer to get amount of acceleration data bytes currently stored in the sensor's FIFO bufferand change the function to "
get_amount_bytes_in_fifo()"
Sounds good to me, thank you!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()or
Quoted 7 lines
Quoted 3 lines
get_bytes_in_fifo()or alike.
or leave it as is. The function is documented:
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer
Do you find it unambiguous? I do not.
Still needs more words to explain if it's a capacity of FIFO or is it amount of valid bytes for the current transfer or what?
Quoted 8 lines
Quoted 5 lines
how about change the description to:
function pointer to get amount of acceleration data bytes currently stored in the sensor's FIFO bufferand change the function to "
get_amount_bytes_in_fifo()"Sounds good to me, thank you!
Bikeshedding time ;)
I don't like "amount" in this - it ends up adding little meaning and to me it is ugly English. It's making it clear that we are dealing with some sort of count but that is already true of get_bytes_in_fifo() So to my reading it adds nothing wrt to removing ambiguity.
get_number_of_bytes_in_fifo() flows better but also adds nothing over get_bytes_in_fifo()
You could make it clear it is something that changes over time.
get_current_bytes_in_fifo()
Which at least implies it changes - though it doesn't rule out a weird variable max size fifo.
get_fifo_bytes_available() might be the clearest option and is the one I would prefer. It's still a little messy as it could mean 'number of bytes of data that haven't been used yet in the fifo and
are available for samples in the future'.
Sigh. Maybe least ambiguous is something longer like.
get_fifo_bytes_available_to_read()get_fifo_bytes_available_out()
Honestly I don't care that much what you go with :)
Jonathan
Matti Vaittinen
maintainerRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 50 lines · Jonathan Cameron
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
I see. I think my confusion can be easily cured by renaming the callback to
get_amount_bytes_in_fifo()or
Quoted 7 lines
Quoted 3 lines
get_bytes_in_fifo()or alike.
or leave it as is. The function is documented:
+ * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer
Do you find it unambiguous? I do not.
Still needs more words to explain if it's a capacity of FIFO or is it amount of valid bytes for the current transfer or what?
Quoted 8 lines
Quoted 5 lines
how about change the description to:
function pointer to get amount of acceleration data bytes currently stored in the sensor's FIFO bufferand change the function to "
get_amount_bytes_in_fifo()"Sounds good to me, thank you!
Bikeshedding time ;)
I don't like "amount" in this - it ends up adding little meaning and to me it is ugly English. It's making it clear that we are dealing with some sort of count but that is already true of
get_bytes_in_fifo()So to my reading it adds nothing wrt to removing ambiguity.
get_number_of_bytes_in_fifo()flows better but also adds nothing overget_bytes_in_fifo()You could make it clear it is something that changes over time.
get_current_bytes_in_fifo()Which at least implies it changes - though it doesn't rule out a weird variable max size fifo.
get_fifo_bytes_available()might be the clearest option and is the one I would prefer. It's still a little messy as it could mean 'number of bytes of data that haven't been used yet in the fifo and
are available for samples in the future'.
Quoted 6 lines
Sigh. Maybe least ambiguous is something longer like.
get_fifo_bytes_available_to_read()get_fifo_bytes_available_out()Honestly I don't care that much what you go with :)
If this was a democracy (which it isn't) - my vote would go for "leave as it is" because the concept of a data collecting fifo where amount of data acquired in FIFO is readable from a register is common enough. I think that people who work on a driver like this should guess what this is for. Besides, if anything more than looking at the code is needed, then the plain guessing won't do and one needs anyway to open the data-sheet.
From my perspective this series adds a nice value and is good to go.
Just my 10 cents though :)
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 1 line · Matti Vaittinen
On 8/27/23 21:09, Jonathan Cameron wrote:
...
Quoted 2 lines
I think that people who work on a driver like this should guess what this is for.
_This_ is the result of what people always forgot to think about, i.e. newcomers. What _if_ the newcomer starts with this code and already being puzzled enough on what the heck the function does. With all ambiguity we rise the threshold for the newcomers and make the kernel project not attractive to start with (besides the C language which is already considered as mastodon among youngsters).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Matti Vaittinen
maintainerRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 8/27/23 21:09, Jonathan Cameron wrote:
...
Quoted 2 lines
I think that people who work on a driver like this should guess what this is for.
_This_ is the result of what people always forgot to think about, i.e. newcomers.
Thanks Andy. This was a good heads-up for me. I do also see the need for fresh blood here - we aren't getting any younger.
Quoted 3 lines
What _if_ the newcomer starts with this code and already being puzzled enough on what the heck the function does. With all ambiguity we rise the threshold for the newcomers and make the kernel project not attractive to start with
I really appreciate you making a point about attracting newcomers (and there is no sarcasm in this statement). I however don't think we're rising the bar here. If a newcomer wants to work on a device-driver, the _first_ thing to do is to be familiar with the device. Without prior experience of this kind of devices it is really a must to get the data-sheet and see how the device operates before jumping into reading the code. I would say that after reading the fifo lvl description from data-sheet this should be obvious - and no, I don't think we should replicate the data-sheet documentation in the drivers for parts that aren't very peculiar.
But the question how to attract newcomers to kernel is very valid and I guess that not too many of us is thinking of it. Actually, I think we should ask from the newcomers we have that what has been the most repulsive part of the work when they have contributed.
(besides the
Quoted 1 line
C language which is already considered as mastodon among youngsters).
I think this is at least partially the truth. However, I think that in many cases one of the issues goes beyond the language - many younger generation people I know aren't really interested in _why_ things work, they just want to get things working in any way they can - and nowadays when you can find a tutorial for pretty much anything - one really can just look up instruction about how a "foobar can be made to buzz" instead of trying to figure out what makes a "foobar to buzz" in order to make it to buzz. So, I don't blame people getting used to take a different approach. (Not sure this makes sense - don't really know how to express my thoughts about this in a clear way - besides, it may not even matter).
Anyways, I am pretty sure that - as with any community - the way people are treated and how their contribution is appreciated is the key to make them feel good and like the work. I think that in some cases it may include allowing new contributors to get their code merged when it has reached "good enough" state - even if it was not perfect. (Sure, when things are good enough is subject to greater minds than me to ponder) ;)
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 3 lines · Matti Vaittinen
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 8/27/23 21:09, Jonathan Cameron wrote:
Sorry it took a bit of time to reply on this.
...
Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
I think that people who work on a driver like this should guess what this is for.
_This_ is the result of what people always forgot to think about, i.e. newcomers.
Thanks Andy. This was a good heads-up for me. I do also see the need for fresh blood here - we aren't getting any younger.
Quoted 3 lines
What _if_ the newcomer starts with this code and already being puzzled enough on what the heck the function does. With all ambiguity we rise the threshold for the newcomers and make the kernel project not attractive to start with
Quoted 9 lines
I really appreciate you making a point about attracting newcomers (and there is no sarcasm in this statement). I however don't think we're rising the bar here. If a newcomer wants to work on a device-driver, the _first_ thing to do is to be familiar with the device. Without prior experience of this kind of devices it is really a must to get the data-sheet and see how the device operates before jumping into reading the code. I would say that after reading the fifo lvl description from data-sheet this should be obvious - and no, I don't think we should replicate the data-sheet documentation in the drivers for parts that aren't very peculiar.
There are (at least?) two approaches on the contribution:
1) generic / library wise;
2) specific hardware wise.
You are talking about 2), while my remark is about both. I can imagine a newcomer who possess a hardware that looks similar to what this driver is for. Now, they would like to write a new driver (note, that compatibility can be checked by reading the RTL definitions, so no need to dive into the code) and use this as a (nice) reference. With that in mind, they can read a function named get_fifo_bytes() with not so extensive documentation nor fully self-explanatory name. One may mistakenly though about this as a function for something that returns FIFO capacity, but in the reality it is current amount of valid / data bytes in the FIFO for the ongoing communication with the device.
Quoted 8 lines
But the question how to attract newcomers to kernel is very valid and I guess that not too many of us is thinking of it. Actually, I think we should ask from the newcomers we have that what has been the most repulsive part of the work when they have contributed.
(besides the
Quoted 1 line
C language which is already considered as mastodon among youngsters).
Quoted 10 lines
I think this is at least partially the truth. However, I think that in many cases one of the issues goes beyond the language - many younger generation people I know aren't really interested in _why_ things work, they just want to get things working in any way they can - and nowadays when you can find a tutorial for pretty much anything - one really can just look up instruction about how a "foobar can be made to buzz" instead of trying to figure out what makes a "foobar to buzz" in order to make it to buzz. So, I don't blame people getting used to take a different approach. (Not sure this makes sense
- don't really know how to express my thoughts about this in a clear way - besides, it may not even matter).
Yeah, I share your frustration and agree that people are loosing the feel of curiosity. Brave New World in front of us...
Quoted 6 lines
Anyways, I am pretty sure that - as with any community - the way people are treated and how their contribution is appreciated is the key to make them feel good and like the work. I think that in some cases it may include allowing new contributors to get their code merged when it has reached "good enough" state - even if it was not perfect. (Sure, when things are good enough is subject to greater minds than me to ponder) ;)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Matti Vaittinen
maintainerRe: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Matti Vaittinen
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 8/27/23 21:09, Jonathan Cameron wrote:
Sorry it took a bit of time to reply on this.
No problem. Autumn is approaching and darkness is falling in Finland... So, at least I am really slowing down with everything... :|
Quoted 24 lines
...
Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
I think that people who work on a driver like this should guess what this is for.
_This_ is the result of what people always forgot to think about, i.e. newcomers.
Thanks Andy. This was a good heads-up for me. I do also see the need for fresh blood here - we aren't getting any younger.
Quoted 3 lines
What _if_ the newcomer starts with this code and already being puzzled enough on what the heck the function does. With all ambiguity we rise the threshold for the newcomers and make the kernel project not attractive to start with
Quoted 9 lines
I really appreciate you making a point about attracting newcomers (and there is no sarcasm in this statement). I however don't think we're rising the bar here. If a newcomer wants to work on a device-driver, the _first_ thing to do is to be familiar with the device. Without prior experience of this kind of devices it is really a must to get the data-sheet and see how the device operates before jumping into reading the code. I would say that after reading the fifo lvl description from data-sheet this should be obvious - and no, I don't think we should replicate the data-sheet documentation in the drivers for parts that aren't very peculiar.
Quoted 6 lines
There are (at least?) two approaches on the contribution:
1) generic / library wise;
2) specific hardware wise.You are talking about 2), while my remark is about both. I can imagine a newcomer who possess a hardware that looks similar to what this driver is for.
Yes. I am talking about 2). And my stance is that device drivers belong to category 2). If one works with a device driver for some HW, then he/she needs to be willing to understand the hardware.
Now, they
Quoted 7 lines
would like to write a new driver (note, that compatibility can be checked by reading the RTL definitions, so no need to dive into the code) and use this as a (nice) reference. With that in mind, they can read a function named
get_fifo_bytes()with not so extensive documentation nor fully self-explanatory name. One may mistakenly though about this as a function for something that returns FIFO capacity, but in the reality it is current amount of valid / data bytes in the FIFO for the ongoing communication with the device.
I can't avoid having a feeling that this is a very unlikely scenario. I am afraid that by requesting this type of improvements at patch series which is at v8 and has been running for half an year (and which was of a good quality to start with, especially knowing this was the author's first driver) is going to be more repulsive to the newcomers than the potential obfuscation.
I don't try claiming that no-one could ever hit this trap (even if I don't see it likely). I still believe that if one does so, he/she will also get such a bug fixed without being totally discouraged - it's business as usual.
I hope this does not come out as rude. I do appreciate your reviews, it's comforting to know someone looks my code with sharp eyes and points out things like the dead code in BM1390 driver! I just like the words Jonathan once spilled out:
"Don't let the perfect be enemy of good" (or something along those lines).
Quoted 19 lines
Quoted 8 lines
But the question how to attract newcomers to kernel is very valid and I guess that not too many of us is thinking of it. Actually, I think we should ask from the newcomers we have that what has been the most repulsive part of the work when they have contributed.
(besides the
Quoted 1 line
C language which is already considered as mastodon among youngsters).
Quoted 10 lines
I think this is at least partially the truth. However, I think that in many cases one of the issues goes beyond the language - many younger generation people I know aren't really interested in _why_ things work, they just want to get things working in any way they can - and nowadays when you can find a tutorial for pretty much anything - one really can just look up instruction about how a "foobar can be made to buzz" instead of trying to figure out what makes a "foobar to buzz" in order to make it to buzz. So, I don't blame people getting used to take a different approach. (Not sure this makes sense
- don't really know how to express my thoughts about this in a clear way - besides, it may not even matter).
Quoted 2 lines
Yeah, I share your frustration and agree that people are loosing the feel of curiosity. Brave New World in front of us...
Well, who knows how things will be working out for the new generations? Maybe they won't need the kernel in the future? Yes, I am stubbornly hanging in the past practices and values. Direction things seem to head do not always appeal to me - but perhaps it's just me? Who can say my values and practices are the right ones for new generations :) My oldest son just moved to his own home and I need to accept that young do build their own lives on different values I had. And who knows, maybe the approach of just doing things without knowing what exactly happens under the hood makes this world very good for them?
But yes - I don't think it suits the kernel project at all :) This is a project of dinosaurs like us XD
(DISCLAIMER: I don't know quite all young people in the world. Frankly to tell, not even 90% XD So, I am not trying to say "all young people are like this or that". I just have a feeling that certain way of thinking is more common amongst certain generations - but maybe it's just my misjudgement. Please, don't be offended).
Quoted 8 lines
Quoted 7 lines
Anyways, I am pretty sure that - as with any community - the way people are treated and how their contribution is appreciated is the key to make them feel good and like the work. I think that in some cases it may include allowing new contributors to get their code merged when it has reached "good enough" state - even if it was not perfect. (Sure, when things are good enough is subject to greater minds than me to ponder) ;)
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH v8 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer
Quoted 5 lines · Matti Vaittinen
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Matti Vaittinen
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Matti Vaittinen
On 8/27/23 21:09, Jonathan Cameron wrote:
...
Quoted 45 lines
Quoted 24 lines
Quoted 14 lines
Quoted 5 lines
Quoted 2 lines
I think that people who work on a driver like this should guess what this is for.
_This_ is the result of what people always forgot to think about, i.e. newcomers.
Thanks Andy. This was a good heads-up for me. I do also see the need for fresh blood here - we aren't getting any younger.
Quoted 4 lines
What _if_ the newcomer starts with this code and already being puzzled enough on what the heck the function does. With all ambiguity we rise the threshold for the newcomers and make the kernel project not attractive to start with
Quoted 9 lines
I really appreciate you making a point about attracting newcomers (and there is no sarcasm in this statement). I however don't think we're rising the bar here. If a newcomer wants to work on a device-driver, the _first_ thing to do is to be familiar with the device. Without prior experience of this kind of devices it is really a must to get the data-sheet and see how the device operates before jumping into reading the code. I would say that after reading the fifo lvl description from data-sheet this should be obvious - and no, I don't think we should replicate the data-sheet documentation in the drivers for parts that aren't very peculiar.
Quoted 7 lines
There are (at least?) two approaches on the contribution:
1) generic / library wise;
2) specific hardware wise.You are talking about 2), while my remark is about both. I can imagine a newcomer who possess a hardware that looks similar to what this driver is for.
Yes. I am talking about 2). And my stance is that device drivers belong to category 2). If one works with a device driver for some HW, then he/she needs to be willing to understand the hardware.
Quoted 8 lines
Now, they would like to write a new driver (note, that compatibility can be checked by reading the RTL definitions, so no need to dive into the code) and use this as a (nice) reference. With that in mind, they can read a function named
get_fifo_bytes()with not so extensive documentation nor fully self-explanatory name. One may mistakenly though about this as a function for something that returns FIFO capacity, but in the reality it is current amount of valid / data bytes in the FIFO for the ongoing communication with the device.
Quoted 5 lines
I can't avoid having a feeling that this is a very unlikely scenario. I am afraid that by requesting this type of improvements at patch series which is at v8 and has been running for half an year (and which was of a good quality to start with, especially knowing this was the author's first driver) is going to be more repulsive to the newcomers than the potential obfuscation.
I agree and this is a side talk to the topic.
Quoted 10 lines
I don't try claiming that no-one could ever hit this trap (even if I don't see it likely). I still believe that if one does so, he/she will also get such a bug fixed without being totally discouraged - it's business as usual.
I hope this does not come out as rude. I do appreciate your reviews, it's comforting to know someone looks my code with sharp eyes and points out things like the dead code in BM1390 driver! I just like the words Jonathan once spilled out:
"Don't let the perfect be enemy of good" (or something along those lines).
True.
Quoted 32 lines
Quoted 19 lines
Quoted 8 lines
But the question how to attract newcomers to kernel is very valid and I guess that not too many of us is thinking of it. Actually, I think we should ask from the newcomers we have that what has been the most repulsive part of the work when they have contributed.
Quoted 2 lines
(besides the C language which is already considered as mastodon among youngsters).
Quoted 10 lines
I think this is at least partially the truth. However, I think that in many cases one of the issues goes beyond the language - many younger generation people I know aren't really interested in _why_ things work, they just want to get things working in any way they can - and nowadays when you can find a tutorial for pretty much anything - one really can just look up instruction about how a "foobar can be made to buzz" instead of trying to figure out what makes a "foobar to buzz" in order to make it to buzz. So, I don't blame people getting used to take a different approach. (Not sure this makes sense
- don't really know how to express my thoughts about this in a clear way - besides, it may not even matter).Quoted 2 lines
Yeah, I share your frustration and agree that people are loosing the feel of curiosity. Brave New World in front of us...
Well, who knows how things will be working out for the new generations? Maybe they won't need the kernel in the future? Yes, I am stubbornly hanging in the past practices and values. Direction things seem to head do not always appeal to me - but perhaps it's just me? Who can say my values and practices are the right ones for new generations :) My oldest son just moved to his own home and I need to accept that young do build their own lives on different values I had. And who knows, maybe the approach of just doing things without knowing what exactly happens under the hood makes this world very good for them?
Quoted 6 lines
But yes - I don't think it suits the kernel project at all :) This is a project of dinosaurs like us XD
(DISCLAIMER: I don't know quite all young people in the world. Frankly to tell, not even 90% XD So, I am not trying to say "all young people are like this or that".
Operating in terms of universal quantifier is always wrong (pun intended).
Quoted 10 lines
I just have a feeling that certain way of thinking is more common amongst certain generations - but maybe it's just my misjudgement. Please, don't be offended).
Quoted 6 lines
Quoted 6 lines
Anyways, I am pretty sure that - as with any community - the way people are treated and how their contribution is appreciated is the key to make them feel good and like the work. I think that in some cases it may include allowing new contributors to get their code merged when it has reached "good enough" state - even if it was not perfect. (Sure, when things are good enough is subject to greater minds than me to ponder) ;)
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v8 7/7 iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer
In reply to Mehdi DjaitKionix KX132-1211 is a tri-axis 16-bit accelerometer that can support ranges from ±2G to ±16G, digital output through I²C/SPI.
Add support for basic accelerometer features such as reading acceleration via IIO using raw reads, triggered buffer (data-ready), or the WMI IRQ.
Datasheet: https://kionixfs.azureedge.net/en/document/KX132-1211-Technical-Reference-Manual-Rev-5.0.pdf
---
v8:
- replaced min_t() by min()
v7:
- added a min_t in kx132_get_fifo_bytes to ensure that that the fifo_bytes is never bigger than the fifo_length * KX022A_FIFO_SAMPLES_SIZE_BYTES no matter what we read from I2C as suggested by Matti
v6:
- no changes
v5:
- moved the position of u16 buf_smp_lvl_mask as suggested by Andy
- introduced buf_smp_lvl_mask in Patch 7 as suggested by Jonathan
v4:
- added KX132_REG_CNTL5 to the volatile ranges
- added the kionix reserved regs to the read_only ranges
- removed KX132_REG_MAN_WAKEUP from the write_only ranges
v3:
- fixed the warning of the kernel test robot in kx132_get_fifo_bytes (invalid assignment: &=, left side has type restricted __le16 right side has type unsigned short)
v2:
- mentioned the kx132-1211 in the Kconfig
- added a kx132-specific get_fifo_bytes function
- changed the device name from "kx132" to "kx132-1211
drivers/iio/accel/Kconfig | 8 +- drivers/iio/accel/kionix-kx022a-i2c.c | 2 + drivers/iio/accel/kionix-kx022a-spi.c | 2 + drivers/iio/accel/kionix-kx022a.c | 164 ++++++++++++++++++++++++++ drivers/iio/accel/kionix-kx022a.h | 54 +++++++++ 5 files changed, 226 insertions(+), 4 deletions(-)
drivers/iio/accel/Kconfig +4 -4
@@ -418,8 +418,8 @@ config IIO_KX022A_SPI select IIO_KX022A select REGMAP_SPI help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to SPI interface. config IIO_KX022A_I2C tristate "Kionix KX022A tri-axis digital accelerometer I2C interface"
@@ -427,8 +427,8 @@ config IIO_KX022A_I2C select IIO_KX022A select REGMAP_I2C help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to I2C interface. config KXSD9 tristate "Kionix KXSD9 Accelerometer Driver"
drivers/iio/accel/kionix-kx022a-i2c.c +2 -0
@@ -42,12 +42,14 @@ static int kx022a_i2c_probe(struct i2c_client *i2c)static const struct i2c_device_id kx022a_i2c_id[] = { { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, + { .name ="kx132-1211" , .driver_data = (kernel_ulong_t)&kx132_chip_info }, { } };MODULE_DEVICE_TABLE (i2c, kx022a_i2c_id);static const struct of_device_id kx022a_of_match[] = { { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, + { .compatible ="kionix,kx132-1211" , .data = &kx132_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a-spi.c +2 -0
@@ -37,12 +37,14 @@ static int kx022a_spi_probe(struct spi_device *spi)static const struct spi_device_id kx022a_id[] = { { .name ="kx022a" , .driver_data = (kernel_ulong_t)&kx022a_chip_info }, + { .name ="kx132-1211" , .driver_data = (kernel_ulong_t)&kx132_chip_info }, { } };MODULE_DEVICE_TABLE (spi, kx022a_id);static const struct of_device_id kx022a_of_match[] = { { .compatible ="kionix,kx022a" , .data = &kx022a_chip_info }, + { .compatible ="kionix,kx132-1211" , .data = &kx132_chip_info }, { } };MODULE_DEVICE_TABLE (of, kx022a_of_match);
drivers/iio/accel/kionix-kx022a.c +164 -0
188 lines not on this page · raw message
drivers/iio/accel/kionix-kx022a.h +54 -0
77 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 4 lines · Mehdi Djait
Kionix KX132-1211 is a tri-axis 16-bit accelerometer that can support ranges from ±2G to ±16G, digital output through I²C/SPI.
Add support for basic accelerometer features such as reading acceleration via IIO using raw reads, triggered buffer (data-ready), or the WMI IRQ.
...
drivers/iio/accel/Kconfig config IIO_KX022A_SPI · line 422
Quoted 5 lines
drivers/iio/accel/Kconfig +2
-2help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to SPI interface.
I know I have given a tag, but since it most likely require a new version, this can be amended for the better maintenance as
Enable support for the Kionix digital tri-axis accelerometers connected to SPI interface. Supported devices are:
KX022A, KX132-1211
...
drivers/iio/accel/Kconfig config IIO_KX022A_I2C · line 431
Quoted 5 lines
drivers/iio/accel/Kconfig +2
-2help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to I2C interface.
Ditto.
...
drivers/iio/accel/kionix-kx022a.c static const struct regmap_config kx022a_regmap_config = { · line 175
Quoted 2 lines
drivers/iio/accel/kionix-kx022a.c +2
-0+static const struct regmap_access_table kx132_volatile_regs = { + .yes_ranges = &kx132_volatile_ranges[0 ],
This should be the same as
.yes_ranges = kx132_volatile_ranges,
Review
Quoted 2 lines
(quoted diff) +2
-0+ .n_yes_ranges = ARRAY_SIZE(kx132_volatile_ranges), +};
Ditto for the following.
Quoted 19 lines
drivers/iio/accel/kionix-kx022a.c +16
-0+static const struct regmap_access_table kx132_precious_regs = { + .yes_ranges = &kx132_precious_ranges[0 ], + .n_yes_ranges =ARRAY_SIZE (kx132_precious_ranges), +}; +static const struct regmap_access_table kx132_ro_regs = { + .no_ranges = &kx132_read_only_ranges[0 ], + .n_no_ranges =ARRAY_SIZE (kx132_read_only_ranges), +}; +static const struct regmap_access_table kx132_wo_regs = { + .no_ranges = &kx132_write_only_ranges[0 ], + .n_no_ranges =ARRAY_SIZE (kx132_write_only_ranges), +}; +static const struct regmap_access_table kx132_nir_regs = { + .yes_ranges = &kx132_noinc_read_ranges[0 ], + .n_yes_ranges =ARRAY_SIZE (kx132_noinc_read_ranges), +};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Matti Vaittinen
maintainerQuoted 33 lines · Andy Shevchenko
Quoted 4 lines · Mehdi Djait
Kionix KX132-1211 is a tri-axis 16-bit accelerometer that can support ranges from ±2G to ±16G, digital output through I²C/SPI.
Add support for basic accelerometer features such as reading acceleration via IIO using raw reads, triggered buffer (data-ready), or the WMI IRQ....
drivers/iio/accel/Kconfig config IIO_KX022A_SPI · line 422
Quoted 5 lines
help
drivers/iio/accel/Kconfig +2
-2- Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to SPI interface.I know I have given a tag, but since it most likely require a new version, this can be amended for the better maintenance as
Enable support for the Kionix digital tri-axis accelerometers connected to SPI interface. Supported devices are:
KX022A, KX132-1211...
drivers/iio/accel/Kconfig config IIO_KX022A_I2C · line 431
Quoted 5 lines
help
drivers/iio/accel/Kconfig +2
-2- Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to I2C interface.Ditto.
...
Quoted 8 lines
drivers/iio/accel/kionix-kx022a.c static const struct regmap_config kx022a_regmap_config = { · line 175
Quoted 2 lines
drivers/iio/accel/kionix-kx022a.c +2
-0+static const struct regmap_access_table kx132_volatile_regs = { + .yes_ranges = &kx132_volatile_ranges[0 ],This should be the same as
.yes_ranges =
kx132_volatile_ranges,
The driver uses &kx132_volatile_ranges[0] in a few places (for kx022a) so I believe this is okay. Well, I know I am biased as I do personally find &kx132_volatile_ranges[0] clearer. Here we point to the first element in an array - and yes, it may be I am minority here - but at least I wouldn't ask for changing this.
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Quoted 2 lines · Matti Vaittinen
Quoted 1 line · Andy Shevchenko
On Wed, Aug 23, 2023 at 11:16:41PM +0200, Mehdi Djait wrote:
...
Quoted 5 lines
Quoted 5 lines
drivers/iio/accel/kionix-kx022a.c static const struct regmap_config kx022a_regmap_config = { · line 175
Quoted 1 line
drivers/iio/accel/kionix-kx022a.c +1
-0+ .yes_ranges = &kx132_volatile_ranges[0],This should be the same as
Quoted 8 lines
Quoted 2 lines
.yes_ranges =
kx132_volatile_ranges,The driver uses &kx132_volatile_ranges[0] in a few places (for kx022a) so I believe this is okay. Well, I know I am biased as I do personally find &kx132_volatile_ranges[0] clearer. Here we point to the first element in an array - and yes, it may be I am minority here - but at least I wouldn't ask for changing this.
It's a minor thingy, can be ignored.
Signature · 2 lines
With Best Regards, Andy Shevchenko