iio: remaining easy of_match_ptr removal and related.
Subsystems (5)
Jonathan Cameron
maintainercover iio: remaining easy of_match_ptr removal and related.
From: Jonathan Cameron <[email protected]>
This bumper set removes all the remaining cases where of_match_ptr is mostly serving to prevent use of the device via ACPI PRP0001 and complicating the code. The main aim of this set is to reduce the chances of it being used in future drivers.
It also includes some related refactorings, use of generic fw accessors, dropping of CONFIG_OF and lots of header changes inline with the above.
For examples of how to use PRP0001 see https://github.com/westeri/meta-acpi
which is an excellent resource from which to copy snippets of DSDT tables.
It may well not be worth changing the remaining 10 IIO drivers and I certainly don't plan to do so anytime soon.
Jonathan Cameron (38):
iio:potentiometer:ad5272: Drop of_match_ptr and CONFIG_OF protections. iio:potentiometer:ds1803: Drop of_match_ptr and CONFIG_OF protections iio:potentiometer:max5432: Drop of_match_ptr and use generic fw
accessors
iio:potentiometer:max5481: Drop of_match_ptr and CONFIG_OF
protections.
iio:potentiometer:max5481: Drop invalid ACPI binding. iio:potentiometer:mcp4018: Drop of_match_ptr and CONFIG_OF
protections.
iio:potentiometer:mcp4131: Drop of_match_ptr and use generic fw
interfaces.
iio:potentiometer:mcp4531: Drop of_match_ptr and CONFIG_OF
protections.
iio:dac:ad5446: Drop of_match_ptr and CONFIG_OF protections iio:dac:ad5592r: Drop of_match_ptr and ACPI_PTR protections. iio:dac:ad5593r: Drop of_match_ptr and ACPI_PTR protections. iio:dac:ad7303: Drop of_match_ptr protection iio:dac:mcp4725: drop of_match_ptr and use generic fw properties iio:dac:ti-dac082s085: Drop of_match_ptr and CONFIG_OF protections iio:dac:ti-dac5571: Drop of_match_ptr and CONFIG_OF protections iio:potentiostat:lmp91000: Drop of_match_ptr and use generic fw
accessors
iio:pressure:icp10100: Drop of_match_ptr and CONFIG_OF protections iio:pressure:ms5611: Drop of_match_ptr and CONFIG_OF protections iio:pressure:ms5637: Drop of_match_ptr protection iio:pressure:zpa2326: Drop of_match_ptr protection iio:temperature:tsys01: Drop of_match_ptr protection iio:temperature:tmp007: Drop of_match_ptr protection iio:resolver:ad2s1200: Drop of_match_ptr protection iio:chemical:ams-iaq-core: Drop of_match_ptr protection iio:chemical:atlas-sensor: Drop of_match_ptr and use generic fw
accessors
iio:chemical:sgp30: Use local variable dev to simplify code iio:chemical:sgp30: Drop of_match_ptr and use generic fw accessors iio:chemical:vz89x: Introduce local struct device pointer. iio:chemical:vz89x: Drop of_match_ptr protection and use generic fw
accessors
iio:humidity:hdc100x: Drop of_match_ptr protection. iio:proximity:as3935: Use local struct device pointer to simplify
code.
iio:proximity:as3935: Drop of_match_ptr and use generic fw accessors iio:proximity:pulsedlight: Drop of_match_ptr protection iio:magn:ak8975: Drop of_match_ptr and ACPI_PTR protections. iio:magn:ak8974: Drop of_match_ptr protection iio:humidity:htu21: Drop of_match_ptr protection iio:humidity:si7020: Drop of_match_ptr protection iio:health:max30102: Drop of_match_ptr and use generic fw accessors
drivers/iio/chemical/ams-iaq-core.c | 3 +- drivers/iio/chemical/atlas-sensor.c | 10 ++--- drivers/iio/chemical/sgp30.c | 28 ++++++------ drivers/iio/chemical/vz89x.c | 18 ++++---- drivers/iio/dac/ad5446.c | 5 +-- drivers/iio/dac/ad5592r.c | 7 ++- drivers/iio/dac/ad5593r.c | 7 ++- drivers/iio/dac/ad7303.c | 3 +- drivers/iio/dac/mcp4725.c | 29 +++--------- drivers/iio/dac/ti-dac082s085.c | 5 +-- drivers/iio/dac/ti-dac5571.c | 7 +-- drivers/iio/health/max30102.c | 11 +++-- drivers/iio/humidity/hdc100x.c | 3 +- drivers/iio/humidity/htu21.c | 3 +- drivers/iio/humidity/si7020.c | 3 +- drivers/iio/magnetometer/ak8974.c | 3 +- drivers/iio/magnetometer/ak8975.c | 8 ++-- drivers/iio/potentiometer/ad5272.c | 5 +-- drivers/iio/potentiometer/ds1803.c | 6 +-- drivers/iio/potentiometer/max5432.c | 8 ++-- drivers/iio/potentiometer/max5481.c | 23 ++-------- drivers/iio/potentiometer/mcp4018.c | 12 ++--- drivers/iio/potentiometer/mcp4131.c | 8 ++-- drivers/iio/potentiometer/mcp4531.c | 11 ++--- drivers/iio/potentiostat/lmp91000.c | 11 +++-- drivers/iio/pressure/icp10100.c | 3 +- drivers/iio/pressure/ms5611_i2c.c | 6 +-- drivers/iio/pressure/ms5611_spi.c | 6 +-- drivers/iio/pressure/ms5637.c | 3 +- drivers/iio/pressure/zpa2326_i2c.c | 6 +-- drivers/iio/pressure/zpa2326_spi.c | 6 +-- drivers/iio/proximity/as3935.c | 44 +++++++++---------- .../iio/proximity/pulsedlight-lidar-lite-v2.c | 3 +- drivers/iio/resolver/ad2s1200.c | 3 +- drivers/iio/temperature/tmp007.c | 4 +- drivers/iio/temperature/tsys01.c | 3 +- 36 files changed, 134 insertions(+), 190 deletions(-)
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 1/38 iio:potentiometer:ad5272: Drop of_match_ptr and CONFIG_OF protections.
From: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Drop them to remove this restriction.
Also added mod_devicetable.h include given use of struct of_device_id which is defined in that header.
--- drivers/iio/potentiometer/ad5272.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/potentiometer/ad5272.c +2 -3
@@ -15,6 +15,7 @@#include <linux/i2c.h> #include <linux/iio/iio.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #define AD5272_RDAC_WR 1#define AD5272_RDAC_RD 2
@@ -192,7 +193,6 @@ static int ad5272_probe(struct i2c_client *client,return devm_iio_device_register (dev, indio_dev); } -#if defined(CONFIG_OF )static const struct of_device_id ad5272_dt_ids[] = { { .compatible ="adi,ad5272-020" , .data = (void *)AD5272_020 }, { .compatible ="adi,ad5272-050" , .data = (void *)AD5272_050 },
@@ -202,7 +202,6 @@ static const struct of_device_id ad5272_dt_ids[] = { {} };MODULE_DEVICE_TABLE (of, ad5272_dt_ids); -#endif /* CONFIG_OF */ static const struct i2c_device_id ad5272_id[] = { {"ad5272-020" ,AD5272_020 },
@@ -217,7 +216,7 @@ MODULE_DEVICE_TABLE(i2c, ad5272_id);static struct i2c_driver ad5272_driver = { .driver = { .name ="ad5272" , - .of_match_table =of_match_ptr (ad5272_dt_ids), + .of_match_table = ad5272_dt_ids, }, .probe = ad5272_probe, .id_table = ad5272_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 2/38 iio:potentiometer:ds1803: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Drop them to remove this restriction.
Also switch of.h for mod_devicetable.h include given use of struct of_device_id which is defined in that header.
--- drivers/iio/potentiometer/ds1803.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/potentiometer/ds1803.c +2 -4
@@ -14,7 +14,7 @@#include <linux/i2c.h> #include <linux/iio/iio.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #define DS1803_MAX_POS 255#define DS1803_WRITE (chan) (0xa8 | ((chan) + 1))
@@ -134,7 +134,6 @@ static int ds1803_probe(struct i2c_client *client,return devm_iio_device_register (dev, indio_dev); } -#if defined(CONFIG_OF )static const struct of_device_id ds1803_dt_ids[] = { { .compatible ="maxim,ds1803-010" , .data = &ds1803_cfg[DS1803_010 ] }, { .compatible ="maxim,ds1803-050" , .data = &ds1803_cfg[DS1803_050 ] },
@@ -142,7 +141,6 @@ static const struct of_device_id ds1803_dt_ids[] = { {} };MODULE_DEVICE_TABLE (of, ds1803_dt_ids); -#endif /* CONFIG_OF */ static const struct i2c_device_id ds1803_id[] = { {"ds1803-010" ,DS1803_010 },
@@ -155,7 +153,7 @@ MODULE_DEVICE_TABLE(i2c, ds1803_id);static struct i2c_driver ds1803_driver = { .driver = { .name ="ds1803" , - .of_match_table =of_match_ptr (ds1803_dt_ids), + .of_match_table = ds1803_dt_ids, }, .probe = ds1803_probe, .id_table = ds1803_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 3/38 iio:potentiometer:max5432: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Drop them to remove this restriction.
Also switch headers to reflect this change.
--- drivers/iio/potentiometer/max5432.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/potentiometer/max5432.c +4 -4
@@ -11,8 +11,8 @@#include <linux/iio/iio.h> #include <linux/limits.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> /* All chip variants have 32 wiper positions. */ #define MAX5432_MAX_POS 31
@@ -100,7 +100,7 @@ static int max5432_probe(struct i2c_client *client, data =iio_priv (indio_dev); data->client = client; - data->ohm = (unsigned long )of_device_get_match_data (dev); + data->ohm = (unsigned long )device_get_match_data (dev); indio_dev->info = &max5432_info; indio_dev->channels = max5432_channels;
@@ -122,7 +122,7 @@ MODULE_DEVICE_TABLE(of, max5432_dt_ids);static struct i2c_driver max5432_driver = { .driver = { .name ="max5432" , - .of_match_table =of_match_ptr (max5432_dt_ids), + .of_match_table = max5432_dt_ids, }, .probe = max5432_probe, };
Signature · 1 line
2.28.0
Re: [PATCH 03/38] iio:potentiometer:max5432: Drop of_match_ptr and use generic fw accessors
Thus wrote Jonathan Cameron ([email protected]):
Quoted 49 lines
From: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Drop them to remove this restriction.
Also switch headers to reflect this change.
Signed-off-by Jonathan Cameron <[email protected]>Cc Martin Kaiser <[email protected]>--- drivers/iio/potentiometer/max5432.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/iio/potentiometer/max5432.c +4
-4@@ -11,8 +11,8 @@#include <linux/iio/iio.h> #include <linux/limits.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> /* All chip variants have 32 wiper positions. */ #define MAX5432_MAX_POS 31@@ -100,7 +100,7 @@ static int max5432_probe(struct i2c_client *client, data =iio_priv (indio_dev); data->client = client; - data->ohm = (unsigned long )of_device_get_match_data (dev); + data->ohm = (unsigned long )device_get_match_data (dev); indio_dev->info = &max5432_info; indio_dev->channels = max5432_channels;@@ -122,7 +122,7 @@ MODULE_DEVICE_TABLE(of, max5432_dt_ids);static struct i2c_driver max5432_driver = { .driver = { .name ="max5432" , - .of_match_table =of_match_ptr (max5432_dt_ids), + .of_match_table = max5432_dt_ids, }, .probe = max5432_probe, };Signature · 1 line
2.28.0
Looks good to me.
Jonathan Cameron
maintainerPATCH 4/38 iio:potentiometer:max5481: Drop of_match_ptr and CONFIG_OF protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Whilst this driver has an ACPI binding, it is not of a form that is valid under ACPI so will be dropped shortly.
Also switch to device_get_match_data() and switch headers.
--- drivers/iio/potentiometer/max5481.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iio/potentiometer/max5481.c +4 -6
@@ -11,8 +11,8 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> #include <linux/spi/spi.h> /* write wiper reg */
@@ -117,7 +117,6 @@ static const struct iio_info max5481_info = { .write_raw = max5481_write_raw, }; -#if defined(CONFIG_OF )static const struct of_device_id max5481_match[] = { { .compatible ="maxim,max5481" , .data = &max5481_cfg[max5481] }, { .compatible ="maxim,max5482" , .data = &max5481_cfg[max5482] },
@@ -126,7 +125,6 @@ static const struct of_device_id max5481_match[] = { { } };MODULE_DEVICE_TABLE (of, max5481_match); -#endif static int max5481_probe (struct spi_device *spi) {
@@ -144,7 +142,7 @@ static int max5481_probe(struct spi_device *spi) data->spi = spi; - data->cfg =of_device_get_match_data (&spi->dev); + data->cfg =device_get_match_data (&spi->dev);if (!data->cfg) data->cfg = &max5481_cfg[id->driver_data];
@@ -198,7 +196,7 @@ MODULE_DEVICE_TABLE(acpi, max5481_acpi_match);static struct spi_driver max5481_driver = { .driver = { .name ="max5481" , - .of_match_table =of_match_ptr (max5481_match), + .of_match_table = max5481_match, .acpi_match_table =ACPI_PTR (max5481_acpi_match), }, .probe = max5481_probe,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 5/38 iio:potentiometer:max5481: Drop invalid ACPI binding.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Given that an ACPI binding must start with 3 or 4 capitals, this cannot represent a valid binding.
It seems unlikely anything out there is using it.
--- drivers/iio/potentiometer/max5481.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/iio/potentiometer/max5481.c +0 -13
@@ -7,7 +7,6 @@* https://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf */ -#include <linux/acpi.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/module.h>
@@ -182,22 +181,10 @@ static const struct spi_device_id max5481_id_table[] = { };MODULE_DEVICE_TABLE (spi, max5481_id_table); -#if defined(CONFIG_ACPI ) -static const struct acpi_device_id max5481_acpi_match[] = { - {"max5481" , max5481 }, - {"max5482" , max5482 }, - {"max5483" , max5483 }, - {"max5484" , max5484 }, - { } -}; -MODULE_DEVICE_TABLE (acpi, max5481_acpi_match); -#endif -static struct spi_driver max5481_driver = { .driver = { .name ="max5481" , .of_match_table = max5481_match, - .acpi_match_table =ACPI_PTR (max5481_acpi_match), }, .probe = max5481_probe, .remove = max5481_remove,
Signature · 1 line
2.28.0
Re: [PATCH 05/38] iio:potentiometer:max5481: Drop invalid ACPI binding.
Quoted 7 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Given that an ACPI binding must start with 3 or 4 capitals, this cannot represent a valid binding.
It seems unlikely anything out there is using it.
Totally agree.
The names are dictated by the ACPI specification and don't mention small letters.
Quoted 46 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Maury Anderson <[email protected]>Cc Matthew Weber <[email protected]>Cc Slawomir Stepien <[email protected]>--- drivers/iio/potentiometer/max5481.c | 13 ------------- 1 file changed, 13 deletions(-)drivers/iio/potentiometer/max5481.c +0
-14@@ -7,7 +7,6 @@* https://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf */ -#include <linux/acpi.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/module.h> @@ -182,22 +181,10 @@ static const struct spi_device_id max5481_id_table[] = { };MODULE_DEVICE_TABLE (spi, max5481_id_table); -#if defined(CONFIG_ACPI ) -static const struct acpi_device_id max5481_acpi_match[] = { - {"max5481" , max5481 }, - {"max5482" , max5482 }, - {"max5483" , max5483 }, - {"max5484" , max5484 }, - { } -}; -MODULE_DEVICE_TABLE (acpi, max5481_acpi_match); -#endif -static struct spi_driver max5481_driver = { .driver = { .name ="max5481" , .of_match_table = max5481_match, - .acpi_match_table =ACPI_PTR (max5481_acpi_match), }, .probe = max5481_probe, .remove = max5481_remove, --2.28.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerPATCH 6/38 iio:potentiometer:mcp4018: Drop of_match_ptr and CONFIG_OF protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Also use device_get_match_data() rather than devicetree only version.
--- drivers/iio/potentiometer/mcp4018.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/iio/potentiometer/mcp4018.c +4 -8
@@ -16,8 +16,8 @@#include <linux/i2c.h> #include <linux/iio/iio.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> #define MCP4018_WIPER_MAX 127
@@ -116,8 +116,6 @@ static const struct i2c_device_id mcp4018_id[] = { };MODULE_DEVICE_TABLE (i2c, mcp4018_id); -#ifdef CONFIG_OF -#define MCP4018_COMPATIBLE (of_compatible, cfg) { \ .compatible = of_compatible, \ .data = &mcp4018_cfg[cfg], \
@@ -140,8 +138,6 @@ static const struct of_device_id mcp4018_of_match[] = { };MODULE_DEVICE_TABLE (of, mcp4018_of_match); -#endif -static int mcp4018_probe (struct i2c_client *client) {struct device *dev = &client->dev;
@@ -161,7 +157,7 @@ static int mcp4018_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =of_device_get_match_data (dev); + data->cfg =device_get_match_data (dev);if (!data->cfg) data->cfg = &mcp4018_cfg[i2c_match_id (mcp4018_id, client)->driver_data];
@@ -176,7 +172,7 @@ static int mcp4018_probe(struct i2c_client *client)static struct i2c_driver mcp4018_driver = { .driver = { .name ="mcp4018" , - .of_match_table =of_match_ptr (mcp4018_of_match), + .of_match_table = mcp4018_of_match, }, .probe_new = mcp4018_probe, .id_table = mcp4018_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 7/38 iio:potentiometer:mcp4131: Drop of_match_ptr and use generic fw interfaces.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This change allows the use of the driver with ACPI via PRP0001 and remove an example of an anti pattern I'm trying to remove from IIO. Also adjust includes to reflect this change.
--- drivers/iio/potentiometer/mcp4131.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/potentiometer/mcp4131.c +4 -4
@@ -37,9 +37,9 @@#include <linux/iio/iio.h> #include <linux/iio/types.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/property.h> #include <linux/spi/spi.h> #define MCP4131_WRITE (0x00 << 2)
@@ -252,7 +252,7 @@ static int mcp4131_probe(struct spi_device *spi) data =iio_priv (indio_dev);spi_set_drvdata (spi, indio_dev); data->spi = spi; - data->cfg =of_device_get_match_data (&spi->dev); + data->cfg =device_get_match_data (&spi->dev);if (!data->cfg) { devid =spi_get_device_id (spi)->driver_data; data->cfg = &mcp4131_cfg[devid];
@@ -479,7 +479,7 @@ MODULE_DEVICE_TABLE(spi, mcp4131_id);static struct spi_driver mcp4131_driver = { .driver = { .name ="mcp4131" , - .of_match_table =of_match_ptr (mcp4131_dt_ids), + .of_match_table = mcp4131_dt_ids, }, .probe = mcp4131_probe, .id_table = mcp4131_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 8/38 iio:potentiometer:mcp4531: Drop of_match_ptr and CONFIG_OF protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
Also switch to device_get_match_data() from of_ variant and adjust headers to reflect the change.
--- drivers/iio/potentiometer/mcp4531.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/iio/potentiometer/mcp4531.c +4 -7
@@ -28,8 +28,8 @@#include <linux/module.h> #include <linux/i2c.h> #include <linux/err.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> #include <linux/iio/iio.h>
@@ -275,8 +275,6 @@ static const struct i2c_device_id mcp4531_id[] = { };MODULE_DEVICE_TABLE (i2c, mcp4531_id); -#ifdef CONFIG_OF -#define MCP4531_COMPATIBLE (of_compatible, cfg) { \ .compatible = of_compatible, \ .data = &mcp4531_cfg[cfg], \
@@ -350,7 +348,6 @@ static const struct of_device_id mcp4531_of_match[] = { {/* sentinel */ } };MODULE_DEVICE_TABLE (of, mcp4531_of_match); -#endif static int mcp4531_probe (struct i2c_client *client) {
@@ -371,7 +368,7 @@ static int mcp4531_probe(struct i2c_client *client)i2c_set_clientdata (client, indio_dev); data->client = client; - data->cfg =of_device_get_match_data (dev); + data->cfg =device_get_match_data (dev);if (!data->cfg) data->cfg = &mcp4531_cfg[i2c_match_id (mcp4531_id, client)->driver_data];
@@ -386,7 +383,7 @@ static int mcp4531_probe(struct i2c_client *client)static struct i2c_driver mcp4531_driver = { .driver = { .name ="mcp4531" , - .of_match_table =of_match_ptr (mcp4531_of_match), + .of_match_table = mcp4531_of_match, }, .probe_new = mcp4531_probe, .id_table = mcp4531_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 9/38 iio:dac:ad5446: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
--- drivers/iio/dac/ad5446.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/dac/ad5446.c +2 -3
@@ -17,6 +17,7 @@#include <linux/regulator/consumer.h> #include <linux/err.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -478,13 +479,11 @@ static const struct spi_device_id ad5446_spi_ids[] = { };MODULE_DEVICE_TABLE (spi, ad5446_spi_ids); -#ifdef CONFIG_OF static const struct of_device_id ad5446_of_ids[] = { { .compatible ="ti,dac7512" }, { } };MODULE_DEVICE_TABLE (of, ad5446_of_ids); -#endif static int ad5446_spi_probe (struct spi_device *spi) {
@@ -502,7 +501,7 @@ static int ad5446_spi_remove(struct spi_device *spi)static struct spi_driver ad5446_spi_driver = { .driver = { .name ="ad5446" , - .of_match_table =of_match_ptr (ad5446_of_ids), + .of_match_table = ad5446_of_ids, }, .probe = ad5446_spi_probe, .remove = ad5446_spi_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 10/38 iio:dac:ad5592r: Drop of_match_ptr and ACPI_PTR protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These result in a very small reduction in driver size, but at the cost of more complex build and slightly harder to read code. In the case of of_match_ptr it also prevents use of PRP0001 ACPI based identification. In this particular case we have a valid ACPI/PNP ID that I am assuming was issued by Analog Devices. That should be used in preference to PRP0001 but doesn't mean we should prevent that route.
--- drivers/iio/dac/ad5592r.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/ad5592r.c +3 -4
@@ -10,9 +10,8 @@#include <linux/bitops.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/spi/spi.h> -#include <linux/acpi.h> #define AD5592R_GPIO_READBACK_EN BIT(10)#define AD5592R_LDAC_READBACK_EN BIT(6)
@@ -157,8 +156,8 @@ MODULE_DEVICE_TABLE(acpi, ad5592r_acpi_match);static struct spi_driver ad5592r_spi_driver = { .driver = { .name ="ad5592r" , - .of_match_table =of_match_ptr (ad5592r_of_match), - .acpi_match_table =ACPI_PTR (ad5592r_acpi_match), + .of_match_table = ad5592r_of_match, + .acpi_match_table = ad5592r_acpi_match, }, .probe = ad5592r_spi_probe, .remove = ad5592r_spi_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 11/38 iio:dac:ad5593r: Drop of_match_ptr and ACPI_PTR protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These result in a very small reduction in driver size, but at the cost of more complex build and slightly harder to read code. In the case of of_match_ptr it also prevents use of PRP0001 ACPI based identification. In this particular case we have a valid ACPI/PNP ID that I am assuming was issued by Analog Devices. That should be used in preference to PRP0001 but doesn't mean we should prevent that route.
--- drivers/iio/dac/ad5593r.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/ad5593r.c +3 -4
@@ -11,8 +11,7 @@#include <linux/bitops.h> #include <linux/i2c.h> #include <linux/module.h> -#include <linux/of.h> -#include <linux/acpi.h> +#include <linux/mod_devicetable.h> #define AD5593R_MODE_CONF (0 << 4)#define AD5593R_MODE_DAC_WRITE (1 << 4)
@@ -124,8 +123,8 @@ MODULE_DEVICE_TABLE(acpi, ad5593r_acpi_match);static struct i2c_driver ad5593r_driver = { .driver = { .name ="ad5593r" , - .of_match_table =of_match_ptr (ad5593r_of_match), - .acpi_match_table =ACPI_PTR (ad5593r_acpi_match), + .of_match_table = ad5593r_of_match, + .acpi_match_table = ad5593r_acpi_match, }, .probe = ad5593r_i2c_probe, .remove = ad5593r_i2c_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 12/38 iio:dac:ad7303: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO.
Also add mod_devicetable.h include given struct of_device_id is declared there.
--- drivers/iio/dac/ad7303.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/dac/ad7303.c +2 -1
@@ -7,6 +7,7 @@#include <linux/err.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/kernel.h> #include <linux/spi/spi.h> #include <linux/slab.h>
@@ -287,7 +288,7 @@ MODULE_DEVICE_TABLE(spi, ad7303_spi_ids);static struct spi_driver ad7303_driver = { .driver = { .name ="ad7303" , - .of_match_table =of_match_ptr (ad7303_spi_of_match), + .of_match_table = ad7303_spi_of_match, }, .probe = ad7303_probe, .remove = ad7303_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 13/38 iio:dac:mcp4725: drop of_match_ptr and use generic fw properties
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This enables use of ACPI PRP0001 and removes an antipattern I am trying to stop people copying in IIO.
This particular case is more complex than most because it allowed probing via sysfs with out a fwnode but would presumably always
have then failed. Now the code will assume that properties are
the defaults if not specified or the firmware node is not present. This relaxation of the constraints should not break any existing cases and may enable some new ones.
--- drivers/iio/dac/mcp4725.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-)
drivers/iio/dac/mcp4725.c +7 -22
@@ -16,8 +16,8 @@#include <linux/err.h> #include <linux/delay.h> #include <linux/regulator/consumer.h> -#include <linux/of_device.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> +#include <linux/property.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -357,29 +357,16 @@ static const struct iio_info mcp4725_info = { .attrs = &mcp4725_attribute_group, }; -#ifdef CONFIG_OF static int mcp4725_probe_dt (struct device *dev,struct mcp4725_platform_data *pdata) { -struct device_node *np = dev->of_node; - -if (!np) -return -ENODEV ; -/* check if is the vref-supply defined */ - pdata->use_vref =of_property_read_bool (np,"vref-supply" ); + pdata->use_vref =device_property_read_bool (dev,"vref-supply" ); pdata->vref_buffered = -of_property_read_bool (np,"microchip,vref-buffered" ); +device_property_read_bool (dev,"microchip,vref-buffered" );return 0 ; } -#else -static int mcp4725_probe_dt (struct device *dev, -struct mcp4725_platform_data *platform_data) -{ -return -ENODEV ; -} -#endif static int mcp4725_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -398,8 +385,8 @@ static int mcp4725_probe(struct i2c_client *client, data =iio_priv (indio_dev);i2c_set_clientdata (client, indio_dev); data->client = client; -if (client->dev.of_node) - data->id = (enum chip_id )of_device_get_match_data (&client->dev); +if (dev_fwnode (&client->dev)) + data->id = (enum chip_id )device_get_match_data (&client->dev);else data->id = id->driver_data; pdata =dev_get_platdata (&client->dev);
@@ -519,7 +506,6 @@ static const struct i2c_device_id mcp4725_id[] = { };MODULE_DEVICE_TABLE (i2c, mcp4725_id); -#ifdef CONFIG_OFstatic const struct of_device_id mcp4725_of_match[] = { { .compatible ="microchip,mcp4725" ,
@@ -532,12 +518,11 @@ static const struct of_device_id mcp4725_of_match[] = { { } };MODULE_DEVICE_TABLE (of, mcp4725_of_match); -#endif static struct i2c_driver mcp4725_driver = { .driver = { .name =MCP4725_DRV_NAME , - .of_match_table =of_match_ptr (mcp4725_of_match), + .of_match_table = mcp4725_of_match, .pm = &mcp4725_pm_ops, }, .probe = mcp4725_probe,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 14/38 iio:dac:ti-dac082s085: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent the use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
--- drivers/iio/dac/ti-dac082s085.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/dac/ti-dac082s085.c +2 -3
@@ -14,6 +14,7 @@#include <linux/iio/iio.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/regulator/consumer.h> #include <linux/spi/spi.h>
@@ -324,7 +325,6 @@ static int ti_dac_remove(struct spi_device *spi)return 0 ; } -#ifdef CONFIG_OF static const struct of_device_id ti_dac_of_id[] = { { .compatible ="ti,dac082s085" }, { .compatible ="ti,dac102s085" },
@@ -335,7 +335,6 @@ static const struct of_device_id ti_dac_of_id[] = { { } };MODULE_DEVICE_TABLE (of, ti_dac_of_id); -#endif static const struct spi_device_id ti_dac_spi_id[] = { {"dac082s085" , dual_8bit },
@@ -351,7 +350,7 @@ MODULE_DEVICE_TABLE(spi, ti_dac_spi_id);static struct spi_driver ti_dac_driver = { .driver = { .name ="ti-dac082s085" , - .of_match_table =of_match_ptr (ti_dac_of_id), + .of_match_table = ti_dac_of_id, }, .probe = ti_dac_probe, .remove = ti_dac_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 15/38 iio:dac:ti-dac5571: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevent the use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
--- drivers/iio/dac/ti-dac5571.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/dac/ti-dac5571.c +2 -5
@@ -18,8 +18,7 @@#include <linux/iio/iio.h> #include <linux/i2c.h> #include <linux/module.h> -#include <linux/of_device.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/regulator/consumer.h> enum chip_id {
@@ -384,7 +383,6 @@ static int dac5571_remove(struct i2c_client *i2c)return 0 ; } -#ifdef CONFIG_OF static const struct of_device_id dac5571_of_id[] = { {.compatible ="ti,dac5571" }, {.compatible ="ti,dac6571" },
@@ -398,7 +396,6 @@ static const struct of_device_id dac5571_of_id[] = { {} };MODULE_DEVICE_TABLE (of, dac5571_of_id); -#endif static const struct i2c_device_id dac5571_id[] = { {"dac5571" , single_8bit},
@@ -417,7 +414,7 @@ MODULE_DEVICE_TABLE(i2c, dac5571_id);static struct i2c_driver dac5571_driver = { .driver = { .name ="ti-dac5571" , - .of_match_table =of_match_ptr (dac5571_of_id), + .of_match_table = dac5571_of_id, }, .probe = dac5571_probe, .remove = dac5571_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 16/38 iio:potentiostat:lmp91000: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This change allows use of this driver with ACPI via PRP0001 and removes an example of an anti pattern I'm trying to remove from IIO.
--- drivers/iio/potentiostat/lmp91000.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/potentiostat/lmp91000.c +5 -6
@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/i2c.h> #include <linux/delay.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h>
@@ -205,13 +205,12 @@ static const struct iio_info lmp91000_info = {static int lmp91000_read_config (struct lmp91000_data *data) {struct device *dev = data->dev; -struct device_node *np = dev->of_node;unsigned int reg, val;int i, ret; - ret =of_property_read_u32 (np,"ti,tia-gain-ohm" , &val); + ret =device_property_read_u32 (dev,"ti,tia-gain-ohm" , &val);if (ret) { -if (!of_property_read_bool (np,"ti,external-tia-resistor" )) { +if (!device_property_read_bool (dev,"ti,external-tia-resistor" )) {dev_err (dev,"no ti,tia-gain-ohm defined and external resistor not specified\n" );return ret; }
@@ -232,7 +231,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)return ret; } - ret =of_property_read_u32 (np,"ti,rload-ohm" , &val); + ret =device_property_read_u32 (dev,"ti,rload-ohm" , &val);if (ret) { val =100 ;dev_info (dev,"no ti,rload-ohm defined, default to %d\n" , val);
@@ -422,7 +421,7 @@ MODULE_DEVICE_TABLE(i2c, lmp91000_id);static struct i2c_driver lmp91000_driver = { .driver = { .name =LMP91000_DRV_NAME , - .of_match_table =of_match_ptr (lmp91000_of_match), + .of_match_table = lmp91000_of_match, }, .probe = lmp91000_probe, .remove = lmp91000_remove,
Signature · 1 line
2.28.0
Re: [PATCH 16/38] iio:potentiostat:lmp91000: Drop of_match_ptr and use generic fw accessors
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This change allows use of this driver with ACPI via PRP0001 and removes an example of an anti pattern I'm trying to remove from IIO.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 54 lines
--- drivers/iio/potentiostat/lmp91000.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/potentiostat/lmp91000.c +5
-7@@ -11,7 +11,7 @@#include <linux/module.h> #include <linux/i2c.h> #include <linux/delay.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> @@ -205,13 +205,12 @@ static const struct iio_info lmp91000_info = {static int lmp91000_read_config (struct lmp91000_data *data) {struct device *dev = data->dev; -struct device_node *np = dev->of_node;unsigned int reg, val;int i, ret; - ret =of_property_read_u32 (np,"ti,tia-gain-ohm" , &val); + ret =device_property_read_u32 (dev,"ti,tia-gain-ohm" , &val);if (ret) { -if (!of_property_read_bool (np,"ti,external-tia-resistor" )) { +if (!device_property_read_bool (dev,"ti,external-tia-resistor" )) {dev_err (dev,"no ti,tia-gain-ohm defined and external resistor not specified\n" );return ret; }@@ -232,7 +231,7 @@ static int lmp91000_read_config(struct lmp91000_data *data)return ret; } - ret =of_property_read_u32 (np,"ti,rload-ohm" , &val); + ret =device_property_read_u32 (dev,"ti,rload-ohm" , &val);if (ret) { val =100 ;dev_info (dev,"no ti,rload-ohm defined, default to %d\n" , val);@@ -422,7 +421,7 @@ MODULE_DEVICE_TABLE(i2c, lmp91000_id);static struct i2c_driver lmp91000_driver = { .driver = { .name =LMP91000_DRV_NAME , - .of_match_table =of_match_ptr (lmp91000_of_match), + .of_match_table = lmp91000_of_match, }, .probe = lmp91000_probe, .remove = lmp91000_remove, --2.28.0
Jonathan Cameron
maintainerPATCH 17/38 iio:pressure:icp10100: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevents use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
--- drivers/iio/pressure/icp10100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/pressure/icp10100.c +2 -1
@@ -10,6 +10,7 @@#include <linux/device.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/i2c.h> #include <linux/pm_runtime.h> #include <linux/crc8.h>
@@ -645,7 +646,7 @@ static struct i2c_driver icp10100_driver = { .driver = { .name = "icp10100", .pm = &icp10100_pm, - .of_match_table = of_match_ptr(icp10100_of_match), + .of_match_table = icp10100_of_match, }, .probe = icp10100_probe, .id_table = icp10100_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 18/38 iio:pressure:ms5611: Drop of_match_ptr and CONFIG_OF protections
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
These prevents use of this driver with ACPI via PRP0001 and are an example of an anti pattern I'm trying to remove from IIO. Hence drop them from this driver.
--- drivers/iio/pressure/ms5611_i2c.c | 6 ++---- drivers/iio/pressure/ms5611_spi.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/iio/pressure/ms5611_i2c.c +2 -4
@@ -14,7 +14,7 @@#include <linux/delay.h> #include <linux/i2c.h> #include <linux/module.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <asm/unaligned.h>
@@ -113,14 +113,12 @@ static int ms5611_i2c_remove(struct i2c_client *client)return ms5611_remove (i2c_get_clientdata (client)); } -#if defined(CONFIG_OF )static const struct of_device_id ms5611_i2c_matches[] = { { .compatible ="meas,ms5611" }, { .compatible ="meas,ms5607" }, { } };MODULE_DEVICE_TABLE (of, ms5611_i2c_matches); -#endif static const struct i2c_device_id ms5611_id[] = { {"ms5611" ,MS5611 },
@@ -132,7 +130,7 @@ MODULE_DEVICE_TABLE(i2c, ms5611_id);static struct i2c_driver ms5611_driver = { .driver = { .name ="ms5611" , - .of_match_table =of_match_ptr (ms5611_i2c_matches) + .of_match_table = ms5611_i2c_matches, }, .id_table = ms5611_id, .probe = ms5611_i2c_probe,
drivers/iio/pressure/ms5611_spi.c +2 -4
@@ -9,7 +9,7 @@#include <linux/delay.h> #include <linux/module.h> #include <linux/spi/spi.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <asm/unaligned.h>
@@ -115,14 +115,12 @@ static int ms5611_spi_remove(struct spi_device *spi)return ms5611_remove (spi_get_drvdata (spi)); } -#if defined(CONFIG_OF )static const struct of_device_id ms5611_spi_matches[] = { { .compatible ="meas,ms5611" }, { .compatible ="meas,ms5607" }, { } };MODULE_DEVICE_TABLE (of, ms5611_spi_matches); -#endif static const struct spi_device_id ms5611_id[] = { {"ms5611" ,MS5611 },
@@ -134,7 +132,7 @@ MODULE_DEVICE_TABLE(spi, ms5611_id);static struct spi_driver ms5611_driver = { .driver = { .name ="ms5611" , - .of_match_table =of_match_ptr (ms5611_spi_matches) + .of_match_table = ms5611_spi_matches }, .id_table = ms5611_id, .probe = ms5611_spi_probe,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 19/38 iio:pressure:ms5637: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/pressure/ms5637.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/pressure/ms5637.c +2 -1
@@ -22,6 +22,7 @@#include <linux/kernel.h> #include <linux/stat.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/i2c.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -192,7 +193,7 @@ static struct i2c_driver ms5637_driver = { .id_table = ms5637_id, .driver = { .name = "ms5637", - .of_match_table = of_match_ptr(ms5637_of_match), + .of_match_table = ms5637_of_match, }, };
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 20/38 iio:pressure:zpa2326: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/pressure/zpa2326_i2c.c | 6 ++---- drivers/iio/pressure/zpa2326_spi.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/iio/pressure/zpa2326_i2c.c +2 -4
@@ -10,7 +10,7 @@#include <linux/module.h> #include <linux/regmap.h> #include <linux/i2c.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include "zpa2326.h" /*
@@ -66,18 +66,16 @@ static const struct i2c_device_id zpa2326_i2c_ids[] = { };MODULE_DEVICE_TABLE (i2c, zpa2326_i2c_ids); -#if defined(CONFIG_OF )static const struct of_device_id zpa2326_i2c_matches[] = { { .compatible ="murata,zpa2326" }, { } };MODULE_DEVICE_TABLE (of, zpa2326_i2c_matches); -#endif static struct i2c_driver zpa2326_i2c_driver = { .driver = { .name ="zpa2326-i2c" , - .of_match_table =of_match_ptr (zpa2326_i2c_matches), + .of_match_table = zpa2326_i2c_matches, .pm =ZPA2326_PM_OPS , }, .probe = zpa2326_probe_i2c,
drivers/iio/pressure/zpa2326_spi.c +2 -4
@@ -10,7 +10,7 @@#include <linux/module.h> #include <linux/regmap.h> #include <linux/spi/spi.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include "zpa2326.h" /*
@@ -70,18 +70,16 @@ static const struct spi_device_id zpa2326_spi_ids[] = { };MODULE_DEVICE_TABLE (spi, zpa2326_spi_ids); -#if defined(CONFIG_OF )static const struct of_device_id zpa2326_spi_matches[] = { { .compatible ="murata,zpa2326" }, { } };MODULE_DEVICE_TABLE (of, zpa2326_spi_matches); -#endif static struct spi_driver zpa2326_spi_driver = { .driver = { .name ="zpa2326-spi" , - .of_match_table =of_match_ptr (zpa2326_spi_matches), + .of_match_table = zpa2326_spi_matches, .pm =ZPA2326_PM_OPS , }, .probe = zpa2326_probe_spi,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 21/38 iio:temperature:tsys01: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/temperature/tsys01.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/temperature/tsys01.c +2 -1
@@ -13,6 +13,7 @@#include <linux/device.h> #include <linux/mutex.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/stat.h>
@@ -222,7 +223,7 @@ static struct i2c_driver tsys01_driver = { .id_table = tsys01_id, .driver = { .name = "tsys01", - .of_match_table = of_match_ptr(tsys01_of_match), + .of_match_table = tsys01_of_match, }, };
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 22/38 iio:temperature:tmp007: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/temperature/tmp007.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/temperature/tmp007.c +2 -2
@@ -20,7 +20,7 @@#include <linux/module.h> #include <linux/pm.h> #include <linux/bitops.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/irq.h> #include <linux/interrupt.h>
@@ -578,7 +578,7 @@ MODULE_DEVICE_TABLE(i2c, tmp007_id);static struct i2c_driver tmp007_driver = { .driver = { .name ="tmp007" , - .of_match_table =of_match_ptr (tmp007_of_match), + .of_match_table = tmp007_of_match, .pm = &tmp007_pm_ops, }, .probe = tmp007_probe,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 23/38 iio:resolver:ad2s1200: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/resolver/ad2s1200.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/resolver/ad2s1200.c +2 -1
@@ -12,6 +12,7 @@#include <linux/device.h> #include <linux/gpio/consumer.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/spi/spi.h> #include <linux/sysfs.h>
@@ -192,7 +193,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1200_id);static struct spi_driver ad2s1200_driver = { .driver = { .name =DRV_NAME , - .of_match_table =of_match_ptr (ad2s1200_of_match), + .of_match_table = ad2s1200_of_match, }, .probe = ad2s1200_probe, .id_table = ad2s1200_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 24/38 iio:chemical:ams-iaq-core: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/chemical/ams-iaq-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/chemical/ams-iaq-core.c +2 -1
@@ -7,6 +7,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/init.h> #include <linux/i2c.h>
@@ -177,7 +178,7 @@ MODULE_DEVICE_TABLE(of, ams_iaqcore_dt_ids);static struct i2c_driver ams_iaqcore_driver = { .driver = { .name ="ams-iaq-core" , - .of_match_table =of_match_ptr (ams_iaqcore_dt_ids), + .of_match_table = ams_iaqcore_dt_ids, }, .probe = ams_iaqcore_probe, .id_table = ams_iaqcore_id,
Signature · 1 line
2.28.0
Re: [PATCH 24/38] iio:chemical:ams-iaq-core: Drop of_match_ptr protection
Quoted 9 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 28 lines
--- drivers/iio/chemical/ams-iaq-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/chemical/ams-iaq-core.c +2
-2@@ -7,6 +7,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/init.h> #include <linux/i2c.h> @@ -177,7 +178,7 @@ MODULE_DEVICE_TABLE(of, ams_iaqcore_dt_ids);static struct i2c_driver ams_iaqcore_driver = { .driver = { .name ="ams-iaq-core" , - .of_match_table =of_match_ptr (ams_iaqcore_dt_ids), + .of_match_table = ams_iaqcore_dt_ids, }, .probe = ams_iaqcore_probe, .id_table = ams_iaqcore_id, --2.28.0
Jonathan Cameron
maintainerPATCH 25/38 iio:chemical:atlas-sensor: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
of_match_ptr() prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver and use generic fw accessors to check if there is a fw_node and get the id.
It might be neater to use pointers rather than indexes for the device_data but that is another issue and should be handled separately.
--- drivers/iio/chemical/atlas-sensor.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iio/chemical/atlas-sensor.c +4 -6
@@ -15,7 +15,7 @@#include <linux/irq.h> #include <linux/irq_work.h> #include <linux/i2c.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h>
@@ -620,7 +620,6 @@ static int atlas_probe(struct i2c_client *client, {struct atlas_data *data;struct atlas_device *chip; -const struct of_device_id *of_id;struct iio_trigger *trig;struct iio_dev *indio_dev;int ret;
@@ -629,11 +628,10 @@ static int atlas_probe(struct i2c_client *client,if (!indio_dev)return -ENOMEM ; - of_id =of_match_device (atlas_dt_ids, &client->dev); -if (!of_id) +if (!dev_fwnode (&client->dev)) chip = &atlas_devices[id->driver_data];else - chip = &atlas_devices[(unsigned long )of_id->data]; + chip = &atlas_devices[(unsigned long )device_get_match_data (&client->dev)]; indio_dev->info = &atlas_info; indio_dev->name =ATLAS_DRV_NAME ;
@@ -775,7 +773,7 @@ static const struct dev_pm_ops atlas_pm_ops = {static struct i2c_driver atlas_driver = { .driver = { .name =ATLAS_DRV_NAME , - .of_match_table =of_match_ptr (atlas_dt_ids), + .of_match_table = atlas_dt_ids, .pm = &atlas_pm_ops, }, .probe = atlas_probe,
Signature · 1 line
2.28.0
Re: [PATCH 25/38] iio:chemical:atlas-sensor: Drop of_match_ptr and use generic fw accessors
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
of_match_ptr()prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver and use generic fw accessors to check if there is afw_nodeand get the id.
Quoted 6 lines
It might be neater to use pointers rather than indexes for the
device_databut that is another issue and should be handled separately.Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 51 lines
--- drivers/iio/chemical/atlas-sensor.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/iio/chemical/atlas-sensor.c +4
-7@@ -15,7 +15,7 @@#include <linux/irq.h> #include <linux/irq_work.h> #include <linux/i2c.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> @@ -620,7 +620,6 @@ static int atlas_probe(struct i2c_client *client, {struct atlas_data *data;struct atlas_device *chip; -const struct of_device_id *of_id;struct iio_trigger *trig;struct iio_dev *indio_dev;int ret;@@ -629,11 +628,10 @@ static int atlas_probe(struct i2c_client *client,if (!indio_dev)return -ENOMEM ; - of_id =of_match_device (atlas_dt_ids, &client->dev); -if (!of_id) +if (!dev_fwnode (&client->dev)) chip = &atlas_devices[id->driver_data];else - chip = &atlas_devices[(unsigned long )of_id->data]; + chip = &atlas_devices[(unsigned long )device_get_match_data (&client->dev)]; indio_dev->info = &atlas_info; indio_dev->name =ATLAS_DRV_NAME ;@@ -775,7 +773,7 @@ static const struct dev_pm_ops atlas_pm_ops = {static struct i2c_driver atlas_driver = { .driver = { .name =ATLAS_DRV_NAME , - .of_match_table =of_match_ptr (atlas_dt_ids), + .of_match_table = atlas_dt_ids, .pm = &atlas_pm_ops, }, .probe = atlas_probe, --2.28.0
Jonathan Cameron
maintainerPATCH 26/38 iio:chemical:sgp30: Use local variable dev to simplify code
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This cleans up the code at bit, but is primarily here as a precusor to the next patch. I've only done this for the two functions which use the dev pointer repeatedly.
--- drivers/iio/chemical/sgp30.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/iio/chemical/sgp30.c +10 -10
@@ -409,6 +409,7 @@ static int sgp_read_raw(struct iio_dev *indio_dev,static int sgp_check_compat (struct sgp_data *data,unsigned int product_id) { +struct device *dev = &data->client->dev;const struct sgp_version *supported_versions;u16 ix, num_fs;u16 product, generation, major, minor;
@@ -416,21 +417,20 @@ static int sgp_check_compat(struct sgp_data *data,/* driver does not match product */ generation =SGP_VERS_GEN (data);if (generation !=0 ) { -dev_err (&data->client->dev, +dev_err (dev,"incompatible product generation %d != 0" , generation);return -ENODEV ; } product =SGP_VERS_PRODUCT (data);if (product != product_id) { -dev_err (&data->client->dev, -"sensor reports a different product: 0x%04hx\n" , +dev_err (dev,"sensor reports a different product: 0x%04hx\n" , product);return -ENODEV ; }if (SGP_VERS_RESERVED (data)) -dev_warn (&data->client->dev,"reserved bit is set\n" ); +dev_warn (dev,"reserved bit is set\n" );/* engineering samples are not supported: no interface guarantees */ if (SGP_VERS_ENG_BIT (data))
@@ -456,8 +456,7 @@ static int sgp_check_compat(struct sgp_data *data, minor >= supported_versions[ix].minor)return 0 ; } -dev_err (&data->client->dev,"unsupported sgp version: %d.%d\n" , - major, minor); +dev_err (dev,"unsupported sgp version: %d.%d\n" , major, minor);return -ENODEV ; }
@@ -499,17 +498,18 @@ static const struct of_device_id sgp_dt_ids[] = {static int sgp_probe (struct i2c_client *client,const struct i2c_device_id *id) { +struct device *dev = &client->dev;struct iio_dev *indio_dev;struct sgp_data *data;const struct of_device_id *of_id;unsigned long product_id;int ret; - indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*data));if (!indio_dev)return -ENOMEM ; - of_id =of_match_device (sgp_dt_ids, &client->dev); + of_id =of_match_device (sgp_dt_ids, dev);if (of_id) product_id = (unsigned long )of_id->data;else
@@ -541,9 +541,9 @@ static int sgp_probe(struct i2c_client *client,sgp_init (data); - ret =devm_iio_device_register (&client->dev, indio_dev); + ret =devm_iio_device_register (dev, indio_dev);if (ret) { -dev_err (&client->dev,"failed to register iio device\n" ); +dev_err (dev,"failed to register iio device\n" );return ret; }
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 27/38 iio:chemical:sgp30: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This change allow the driver to be used with ACPI PRP0001 and removes an antipattern that I want to avoid being copied into new IIO drivers.
The handling of match_data uses a different approach as device_get_match_data doesn't distinguish between no match, and a match but with NULL data.
--- drivers/iio/chemical/sgp30.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iio/chemical/sgp30.c +4 -6
@@ -20,9 +20,9 @@#include <linux/delay.h> #include <linux/kthread.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/i2c.h> -#include <linux/of_device.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -501,7 +501,6 @@ static int sgp_probe(struct i2c_client *client,struct device *dev = &client->dev;struct iio_dev *indio_dev;struct sgp_data *data; -const struct of_device_id *of_id;unsigned long product_id;int ret;
@@ -509,9 +508,8 @@ static int sgp_probe(struct i2c_client *client,if (!indio_dev)return -ENOMEM ; - of_id =of_match_device (sgp_dt_ids, dev); -if (of_id) - product_id = (unsigned long )of_id->data; +if (dev_fwnode (dev)) + product_id = (unsigned long )device_get_match_data (dev);else product_id = id->driver_data;
@@ -576,7 +574,7 @@ MODULE_DEVICE_TABLE(of, sgp_dt_ids);static struct i2c_driver sgp_driver = { .driver = { .name ="sgp30" , - .of_match_table =of_match_ptr (sgp_dt_ids), + .of_match_table = sgp_dt_ids, }, .probe = sgp_probe, .remove = sgp_remove,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 28/38 iio:chemical:vz89x: Introduce local struct device pointer.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Avoids lots of repition of &client->dev and will make the next patch tidier.
--- drivers/iio/chemical/vz89x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/iio/chemical/vz89x.c +5 -4
@@ -352,12 +352,13 @@ MODULE_DEVICE_TABLE(of, vz89x_dt_ids);static int vz89x_probe (struct i2c_client *client,const struct i2c_device_id *id) { +struct device *dev = &client->dev;struct iio_dev *indio_dev;struct vz89x_data *data;const struct of_device_id *of_id;int chip_id; - indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*data));if (!indio_dev)return -ENOMEM ; data =iio_priv (indio_dev);
@@ -370,7 +371,7 @@ static int vz89x_probe(struct i2c_client *client,else return -EOPNOTSUPP ; - of_id =of_match_device (vz89x_dt_ids, &client->dev); + of_id =of_match_device (vz89x_dt_ids, dev);if (!of_id) chip_id = id->driver_data;else
@@ -383,13 +384,13 @@ static int vz89x_probe(struct i2c_client *client,mutex_init (&data->lock); indio_dev->info = &vz89x_info; - indio_dev->name =dev_name (&client->dev); + indio_dev->name =dev_name (dev); indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = data->chip->channels; indio_dev->num_channels = data->chip->num_channels; -return devm_iio_device_register (&client->dev, indio_dev); +return devm_iio_device_register (dev, indio_dev); }static const struct i2c_device_id vz89x_id[] = {
Signature · 1 line
2.28.0
Re: [PATCH 28/38] iio:chemical:vz89x: Introduce local struct device pointer.
Quoted 5 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Avoids lots of repition of
&client->devand will make the next patch tidier.
Typo of repetition.
Quoted 3 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 51 lines
--- drivers/iio/chemical/vz89x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/iio/chemical/vz89x.c +5
-5@@ -352,12 +352,13 @@ MODULE_DEVICE_TABLE(of, vz89x_dt_ids);static int vz89x_probe (struct i2c_client *client,const struct i2c_device_id *id) { +struct device *dev = &client->dev;struct iio_dev *indio_dev;struct vz89x_data *data;const struct of_device_id *of_id;int chip_id; - indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*data));if (!indio_dev)return -ENOMEM ; data =iio_priv (indio_dev);@@ -370,7 +371,7 @@ static int vz89x_probe(struct i2c_client *client,else return -EOPNOTSUPP ; - of_id =of_match_device (vz89x_dt_ids, &client->dev); + of_id =of_match_device (vz89x_dt_ids, dev);if (!of_id) chip_id = id->driver_data;else @@ -383,13 +384,13 @@ static int vz89x_probe(struct i2c_client *client,mutex_init (&data->lock); indio_dev->info = &vz89x_info; - indio_dev->name =dev_name (&client->dev); + indio_dev->name =dev_name (dev); indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = data->chip->channels; indio_dev->num_channels = data->chip->num_channels; -return devm_iio_device_register (&client->dev, indio_dev); +return devm_iio_device_register (dev, indio_dev); }static const struct i2c_device_id vz89x_id[] = { --2.28.0
Jonathan Cameron
maintainerPATCH 29/38 iio:chemical:vz89x: Drop of_match_ptr protection and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This change allow the driver to be used with ACPI PRP0001 and removes an antipattern that I want to avoid being copied into new IIO drivers.
The handling of match_data uses a different approach as device_get_match_data() doesn't distinguish between no match, and a match but with NULL data.
--- drivers/iio/chemical/vz89x.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/iio/chemical/vz89x.c +4 -7
@@ -10,8 +10,7 @@#include <linux/mutex.h> #include <linux/init.h> #include <linux/i2c.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -355,7 +354,6 @@ static int vz89x_probe(struct i2c_client *client,struct device *dev = &client->dev;struct iio_dev *indio_dev;struct vz89x_data *data; -const struct of_device_id *of_id;int chip_id; indio_dev =devm_iio_device_alloc (dev,sizeof (*data));
@@ -371,11 +369,10 @@ static int vz89x_probe(struct i2c_client *client,else return -EOPNOTSUPP ; - of_id =of_match_device (vz89x_dt_ids, dev); -if (!of_id) +if (!dev_fwnode (dev)) chip_id = id->driver_data;else - chip_id = (unsigned long )of_id->data; + chip_id = (unsigned long )device_get_match_data (dev);i2c_set_clientdata (client, indio_dev); data->client = client;
@@ -403,7 +400,7 @@ MODULE_DEVICE_TABLE(i2c, vz89x_id);static struct i2c_driver vz89x_driver = { .driver = { .name ="vz89x" , - .of_match_table =of_match_ptr (vz89x_dt_ids), + .of_match_table = vz89x_dt_ids, }, .probe = vz89x_probe, .id_table = vz89x_id,
Signature · 1 line
2.28.0
Re: [PATCH 29/38] iio:chemical:vz89x: Drop of_match_ptr protection and use generic fw accessors
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This change allow the driver to be used with ACPI PRP0001 and removes an antipattern that I want to avoid being copied into new IIO drivers.
Quoted 6 lines
The handling of
match_datauses a different approach asdevice_get_match_data()doesn't distinguish between no match, and a match but with NULL data.Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 52 lines
--- drivers/iio/chemical/vz89x.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/iio/chemical/vz89x.c +4
-8@@ -10,8 +10,7 @@#include <linux/mutex.h> #include <linux/init.h> #include <linux/i2c.h> -#include <linux/of.h> -#include <linux/of_device.h> +#include <linux/mod_devicetable.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> @@ -355,7 +354,6 @@ static int vz89x_probe(struct i2c_client *client,struct device *dev = &client->dev;struct iio_dev *indio_dev;struct vz89x_data *data; -const struct of_device_id *of_id;int chip_id; indio_dev =devm_iio_device_alloc (dev,sizeof (*data));@@ -371,11 +369,10 @@ static int vz89x_probe(struct i2c_client *client,else return -EOPNOTSUPP ; - of_id =of_match_device (vz89x_dt_ids, dev); -if (!of_id) +if (!dev_fwnode (dev)) chip_id = id->driver_data;else - chip_id = (unsigned long )of_id->data; + chip_id = (unsigned long )device_get_match_data (dev);i2c_set_clientdata (client, indio_dev); data->client = client;@@ -403,7 +400,7 @@ MODULE_DEVICE_TABLE(i2c, vz89x_id);static struct i2c_driver vz89x_driver = { .driver = { .name ="vz89x" , - .of_match_table =of_match_ptr (vz89x_dt_ids), + .of_match_table = vz89x_dt_ids, }, .probe = vz89x_probe, .id_table = vz89x_id, --2.28.0
Jonathan Cameron
maintainerPATCH 30/38 iio:humidity:hdc100x: Drop of_match_ptr protection.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/humidity/hdc100x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/humidity/hdc100x.c +2 -1
@@ -15,6 +15,7 @@#include <linux/delay.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/i2c.h>
@@ -417,7 +418,7 @@ MODULE_DEVICE_TABLE(of, hdc100x_dt_ids);static struct i2c_driver hdc100x_driver = { .driver = { .name ="hdc100x" , - .of_match_table =of_match_ptr (hdc100x_dt_ids), + .of_match_table = hdc100x_dt_ids, }, .probe = hdc100x_probe, .id_table = hdc100x_id,
Signature · 1 line
2.28.0
Re: [PATCH 30/38] iio:humidity:hdc100x: Drop of_match_ptr protection.
Quoted 9 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 28 lines
--- drivers/iio/humidity/hdc100x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/humidity/hdc100x.c +2
-2@@ -15,6 +15,7 @@#include <linux/delay.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/i2c.h> @@ -417,7 +418,7 @@ MODULE_DEVICE_TABLE(of, hdc100x_dt_ids);static struct i2c_driver hdc100x_driver = { .driver = { .name ="hdc100x" , - .of_match_table =of_match_ptr (hdc100x_dt_ids), + .of_match_table = hdc100x_dt_ids, }, .probe = hdc100x_probe, .id_table = hdc100x_id, --2.28.0
Jonathan Cameron
maintainerPATCH 31/38 iio:proximity:as3935: Use local struct device pointer to simplify code.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This makes the existing code easier to read and will make the following patch a little simpler.
--- drivers/iio/proximity/as3935.c | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-)
drivers/iio/proximity/as3935.c +18 -20
@@ -352,19 +352,20 @@ static void as3935_stop_work(void *data)static int as3935_probe (struct spi_device *spi) { +struct device *dev = &spi->dev;struct iio_dev *indio_dev;struct iio_trigger *trig;struct as3935_state *st; -struct device_node *np = spi->dev.of_node; +struct device_node *np = dev->of_node;int ret;/* Be sure lightning event interrupt is specified */ if (!spi->irq) { -dev_err (&spi->dev,"unable to get event interrupt\n" ); +dev_err (dev,"unable to get event interrupt\n" );return -EINVAL ; } - indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*st));if (!indio_dev)return -ENOMEM ;
@@ -378,14 +379,12 @@ static int as3935_probe(struct spi_device *spi) "ams,tuning-capacitor-pf", &st->tune_cap);if (ret) { st->tune_cap =0 ; -dev_warn (&spi->dev, -"no tuning-capacitor-pf set, defaulting to %d" , +dev_warn (dev,"no tuning-capacitor-pf set, defaulting to %d" , st->tune_cap); }if (st->tune_cap >MAX_PF_CAP ) { -dev_err (&spi->dev, -"wrong tuning-capacitor-pf setting of %d\n" , +dev_err (dev,"wrong tuning-capacitor-pf setting of %d\n" , st->tune_cap);return -EINVAL ; }
@@ -393,8 +392,7 @@ static int as3935_probe(struct spi_device *spi) ret =of_property_read_u32 (np,"ams,nflwdth" , &st->nflwdth_reg);if (!ret && st->nflwdth_reg >AS3935_NFLWDTH_MASK ) { -dev_err (&spi->dev, -"invalid nflwdth setting of %d\n" , +dev_err (dev,"invalid nflwdth setting of %d\n" , st->nflwdth_reg);return -EINVAL ; }
@@ -405,7 +403,7 @@ static int as3935_probe(struct spi_device *spi) indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = &as3935_info; - trig =devm_iio_trigger_alloc (&spi->dev,"%s-dev%d" , + trig =devm_iio_trigger_alloc (dev,"%s-dev%d" , indio_dev->name, indio_dev->id);if (!trig)
@@ -417,42 +415,42 @@ static int as3935_probe(struct spi_device *spi)iio_trigger_set_drvdata (trig, indio_dev); trig->ops = &iio_interrupt_trigger_ops; - ret =devm_iio_trigger_register (&spi->dev, trig); + ret =devm_iio_trigger_register (dev, trig);if (ret) { -dev_err (&spi->dev,"failed to register trigger\n" ); +dev_err (dev,"failed to register trigger\n" );return ret; } - ret =devm_iio_triggered_buffer_setup (&spi->dev, indio_dev, + ret =devm_iio_triggered_buffer_setup (dev, indio_dev, iio_pollfunc_store_time, as3935_trigger_handler,NULL );if (ret) { -dev_err (&spi->dev,"cannot setup iio trigger\n" ); +dev_err (dev,"cannot setup iio trigger\n" );return ret; }calibrate_as3935 (st);INIT_DELAYED_WORK (&st->work, as3935_event_work); - ret =devm_add_action (&spi->dev, as3935_stop_work, indio_dev); + ret =devm_add_action (dev, as3935_stop_work, indio_dev);if (ret)return ret; - ret =devm_request_irq (&spi->dev, spi->irq, + ret =devm_request_irq (dev, spi->irq, &as3935_interrupt_handler,IRQF_TRIGGER_RISING , -dev_name (&spi->dev), +dev_name (dev), indio_dev);if (ret) { -dev_err (&spi->dev,"unable to request irq\n" ); +dev_err (dev,"unable to request irq\n" );return ret; } - ret =devm_iio_device_register (&spi->dev, indio_dev); + ret =devm_iio_device_register (dev, indio_dev);if (ret <0 ) { -dev_err (&spi->dev,"unable to register device\n" ); +dev_err (dev,"unable to register device\n" );return ret; }return 0 ;
Signature · 1 line
2.28.0
Re: [PATCH 31/38] iio:proximity:as3935: Use local struct device pointer to simplify code.
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This makes the existing code easier to read and will make the following patch a little simpler.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 124 lines
--- drivers/iio/proximity/as3935.c | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-)drivers/iio/proximity/as3935.c +18
-21@@ -352,19 +352,20 @@ static void as3935_stop_work(void *data)static int as3935_probe (struct spi_device *spi) { +struct device *dev = &spi->dev;struct iio_dev *indio_dev;struct iio_trigger *trig;struct as3935_state *st; -struct device_node *np = spi->dev.of_node; +struct device_node *np = dev->of_node;int ret;/* Be sure lightning event interrupt is specified */ if (!spi->irq) { -dev_err (&spi->dev,"unable to get event interrupt\n" ); +dev_err (dev,"unable to get event interrupt\n" );return -EINVAL ; } - indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*st));if (!indio_dev)return -ENOMEM ;@@ -378,14 +379,12 @@ static int as3935_probe(struct spi_device *spi) "ams,tuning-capacitor-pf", &st->tune_cap);if (ret) { st->tune_cap =0 ; -dev_warn (&spi->dev, -"no tuning-capacitor-pf set, defaulting to %d" , +dev_warn (dev,"no tuning-capacitor-pf set, defaulting to %d" , st->tune_cap); }if (st->tune_cap >MAX_PF_CAP ) { -dev_err (&spi->dev, -"wrong tuning-capacitor-pf setting of %d\n" , +dev_err (dev,"wrong tuning-capacitor-pf setting of %d\n" , st->tune_cap);return -EINVAL ; }@@ -393,8 +392,7 @@ static int as3935_probe(struct spi_device *spi) ret =of_property_read_u32 (np,"ams,nflwdth" , &st->nflwdth_reg);if (!ret && st->nflwdth_reg >AS3935_NFLWDTH_MASK ) { -dev_err (&spi->dev, -"invalid nflwdth setting of %d\n" , +dev_err (dev,"invalid nflwdth setting of %d\n" , st->nflwdth_reg);return -EINVAL ; }@@ -405,7 +403,7 @@ static int as3935_probe(struct spi_device *spi) indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->info = &as3935_info; - trig =devm_iio_trigger_alloc (&spi->dev,"%s-dev%d" , + trig =devm_iio_trigger_alloc (dev,"%s-dev%d" , indio_dev->name, indio_dev->id);if (!trig)@@ -417,42 +415,42 @@ static int as3935_probe(struct spi_device *spi)iio_trigger_set_drvdata (trig, indio_dev); trig->ops = &iio_interrupt_trigger_ops; - ret =devm_iio_trigger_register (&spi->dev, trig); + ret =devm_iio_trigger_register (dev, trig);if (ret) { -dev_err (&spi->dev,"failed to register trigger\n" ); +dev_err (dev,"failed to register trigger\n" );return ret; } - ret =devm_iio_triggered_buffer_setup (&spi->dev, indio_dev, + ret =devm_iio_triggered_buffer_setup (dev, indio_dev, iio_pollfunc_store_time, as3935_trigger_handler,NULL );if (ret) { -dev_err (&spi->dev,"cannot setup iio trigger\n" ); +dev_err (dev,"cannot setup iio trigger\n" );return ret; }calibrate_as3935 (st);INIT_DELAYED_WORK (&st->work, as3935_event_work); - ret =devm_add_action (&spi->dev, as3935_stop_work, indio_dev); + ret =devm_add_action (dev, as3935_stop_work, indio_dev);if (ret)return ret; - ret =devm_request_irq (&spi->dev, spi->irq, + ret =devm_request_irq (dev, spi->irq, &as3935_interrupt_handler,IRQF_TRIGGER_RISING , -dev_name (&spi->dev), +dev_name (dev), indio_dev);if (ret) { -dev_err (&spi->dev,"unable to request irq\n" ); +dev_err (dev,"unable to request irq\n" );return ret; } - ret =devm_iio_device_register (&spi->dev, indio_dev); + ret =devm_iio_device_register (dev, indio_dev);if (ret <0 ) { -dev_err (&spi->dev,"unable to register device\n" ); +dev_err (dev,"unable to register device\n" );return ret; }return 0 ; --2.28.0
Jonathan Cameron
maintainerPATCH 32/38 iio:proximity:as3935: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This change allows the driver to be used with ACPI PRP0001 and removes an antipattern that I want to avoid being copied into new IIO drivers.
--- drivers/iio/proximity/as3935.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/proximity/as3935.c +4 -4
@@ -7,6 +7,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/delay.h>
@@ -356,7 +357,6 @@ static int as3935_probe(struct spi_device *spi)struct iio_dev *indio_dev;struct iio_trigger *trig;struct as3935_state *st; -struct device_node *np = dev->of_node;int ret;/* Be sure lightning event interrupt is specified */
@@ -375,7 +375,7 @@ static int as3935_probe(struct spi_device *spi)spi_set_drvdata (spi, indio_dev);mutex_init (&st->lock); - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"ams,tuning-capacitor-pf" , &st->tune_cap);if (ret) { st->tune_cap =0 ;
@@ -389,7 +389,7 @@ static int as3935_probe(struct spi_device *spi)return -EINVAL ; } - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"ams,nflwdth" , &st->nflwdth_reg);if (!ret && st->nflwdth_reg >AS3935_NFLWDTH_MASK ) { dev_err(dev, "invalid nflwdth setting of %d\n",
@@ -471,7 +471,7 @@ MODULE_DEVICE_TABLE(spi, as3935_id);static struct spi_driver as3935_driver = { .driver = { .name ="as3935" , - .of_match_table =of_match_ptr (as3935_of_match), + .of_match_table = as3935_of_match, .pm =AS3935_PM_OPS , }, .probe = as3935_probe,
Signature · 1 line
2.28.0
Re: [PATCH 32/38] iio:proximity:as3935: Drop of_match_ptr and use generic fw accessors
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This change allows the driver to be used with ACPI PRP0001 and removes an antipattern that I want to avoid being copied into new IIO drivers.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 54 lines
--- drivers/iio/proximity/as3935.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/iio/proximity/as3935.c +4
-5@@ -7,6 +7,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/delay.h> @@ -356,7 +357,6 @@ static int as3935_probe(struct spi_device *spi)struct iio_dev *indio_dev;struct iio_trigger *trig;struct as3935_state *st; -struct device_node *np = dev->of_node;int ret;/* Be sure lightning event interrupt is specified */ @@ -375,7 +375,7 @@ static int as3935_probe(struct spi_device *spi)spi_set_drvdata (spi, indio_dev);mutex_init (&st->lock); - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"ams,tuning-capacitor-pf" , &st->tune_cap);if (ret) { st->tune_cap =0 ;@@ -389,7 +389,7 @@ static int as3935_probe(struct spi_device *spi)return -EINVAL ; } - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"ams,nflwdth" , &st->nflwdth_reg);if (!ret && st->nflwdth_reg >AS3935_NFLWDTH_MASK ) { dev_err(dev, "invalid nflwdth setting of %d\n",@@ -471,7 +471,7 @@ MODULE_DEVICE_TABLE(spi, as3935_id);static struct spi_driver as3935_driver = { .driver = { .name ="as3935" , - .of_match_table =of_match_ptr (as3935_of_match), + .of_match_table = as3935_of_match, .pm =AS3935_PM_OPS , }, .probe = as3935_probe, --2.28.0
Jonathan Cameron
maintainerPATCH 33/38 iio:proximity:pulsedlight: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2 -1
@@ -13,6 +13,7 @@#include <linux/i2c.h> #include <linux/delay.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/pm_runtime.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -360,7 +361,7 @@ static const struct dev_pm_ops lidar_pm_ops = {static struct i2c_driver lidar_driver = { .driver = { .name =LIDAR_DRV_NAME , - .of_match_table =of_match_ptr (lidar_dt_ids), + .of_match_table = lidar_dt_ids, .pm = &lidar_pm_ops, }, .probe = lidar_probe,
Signature · 1 line
2.28.0
Re: [PATCH 33/38] iio:proximity:pulsedlight: Drop of_match_ptr protection
Quoted 9 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 28 lines
--- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2
-2@@ -13,6 +13,7 @@#include <linux/i2c.h> #include <linux/delay.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/pm_runtime.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> @@ -360,7 +361,7 @@ static const struct dev_pm_ops lidar_pm_ops = {static struct i2c_driver lidar_driver = { .driver = { .name =LIDAR_DRV_NAME , - .of_match_table =of_match_ptr (lidar_dt_ids), + .of_match_table = lidar_dt_ids, .pm = &lidar_pm_ops, }, .probe = lidar_probe, --2.28.0
Jonathan Cameron
maintainerPATCH 34/38 iio:magn:ak8975: Drop of_match_ptr and ACPI_PTR protections.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Both would result in only a small size saving. For simplicity it is best to remove them. I also wish to remove both these antipatterns from IIO.
--- drivers/iio/magnetometer/ak8975.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/magnetometer/ak8975.c +3 -5
@@ -8,6 +8,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/i2c.h>
@@ -17,7 +18,6 @@#include <linux/delay.h> #include <linux/bitops.h> #include <linux/gpio/consumer.h> -#include <linux/acpi.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h>
@@ -773,7 +773,6 @@ static const struct iio_info ak8975_info = { .read_raw = &ak8975_read_raw, }; -#ifdef CONFIG_ACPI static const struct acpi_device_id ak_acpi_match[] = { {"AK8975" ,AK8975 }, {"AK8963" ,AK8963 },
@@ -785,7 +784,6 @@ static const struct acpi_device_id ak_acpi_match[] = { { } };MODULE_DEVICE_TABLE (acpi, ak_acpi_match); -#endif static void ak8975_fill_buffer (struct iio_dev *indio_dev) {
@@ -1075,8 +1073,8 @@ static struct i2c_driver ak8975_driver = { .driver = { .name = "ak8975", .pm = &ak8975_dev_pm_ops, - .of_match_table = of_match_ptr(ak8975_of_match), - .acpi_match_table = ACPI_PTR(ak_acpi_match), + .of_match_table = ak8975_of_match, + .acpi_match_table = ak_acpi_match, }, .probe = ak8975_probe, .remove = ak8975_remove,
Signature · 1 line
2.28.0
Re: [PATCH 34/38] iio:magn:ak8975: Drop of_match_ptr and ACPI_PTR protections.
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Both would result in only a small size saving. For simplicity it is best to remove them. I also wish to remove both these antipatterns from IIO.
Hi Jonathan and thank you!
I compiled and tested this patch on ak09911 so, for what is worth,
Best regards,
Jonathan
Quoted 56 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Jonathan Albrieux <[email protected]>--- drivers/iio/magnetometer/ak8975.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/iio/magnetometer/ak8975.c +3
-5@@ -8,6 +8,7 @@*/ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/i2c.h> @@ -17,7 +18,6 @@#include <linux/delay.h> #include <linux/bitops.h> #include <linux/gpio/consumer.h> -#include <linux/acpi.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> @@ -773,7 +773,6 @@ static const struct iio_info ak8975_info = { .read_raw = &ak8975_read_raw, }; -#ifdef CONFIG_ACPI static const struct acpi_device_id ak_acpi_match[] = { {"AK8975" ,AK8975 }, {"AK8963" ,AK8963 },@@ -785,7 +784,6 @@ static const struct acpi_device_id ak_acpi_match[] = { { } };MODULE_DEVICE_TABLE (acpi, ak_acpi_match); -#endif static void ak8975_fill_buffer (struct iio_dev *indio_dev) {@@ -1075,8 +1073,8 @@ static struct i2c_driver ak8975_driver = { .driver = { .name = "ak8975", .pm = &ak8975_dev_pm_ops, - .of_match_table = of_match_ptr(ak8975_of_match), - .acpi_match_table = ACPI_PTR(ak_acpi_match), + .of_match_table = ak8975_of_match, + .acpi_match_table = ak_acpi_match, }, .probe = ak8975_probe, .remove = ak8975_remove,Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 35/38 iio:magn:ak8974: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/magnetometer/ak8974.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/magnetometer/ak8974.c +2 -1
@@ -12,6 +12,7 @@* Author: Linus Walleij <[email protected]> */ #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/kernel.h> #include <linux/i2c.h> #include <linux/interrupt.h>
@@ -1051,7 +1052,7 @@ static struct i2c_driver ak8974_driver = { .driver = { .name = "ak8974", .pm = &ak8974_dev_pm_ops, - .of_match_table = of_match_ptr(ak8974_of_match), + .of_match_table = ak8974_of_match, }, .probe = ak8974_probe, .remove = ak8974_remove,
Signature · 1 line
2.28.0
Re: [PATCH 35/38] iio:magn:ak8974: Drop of_match_ptr protection
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
Signed-off-by Jonathan Cameron <[email protected]>Cc Linus Walleij <[email protected]>
Yours,
Linus Walleij
Jonathan Cameron
maintainerPATCH 36/38 iio:humidity:htu21: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/humidity/htu21.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/humidity/htu21.c +2 -1
@@ -19,6 +19,7 @@#include <linux/kernel.h> #include <linux/stat.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -247,7 +248,7 @@ static struct i2c_driver htu21_driver = { .id_table = htu21_id, .driver = { .name = "htu21", - .of_match_table = of_match_ptr(htu21_of_match), + .of_match_table = htu21_of_match, }, };
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 37/38 iio:humidity:si7020: Drop of_match_ptr protection
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This prevents use of this driver with ACPI via PRP0001 and is an example of an anti pattern I'm trying to remove from IIO. Hence drop from this driver.
--- drivers/iio/humidity/si7020.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/humidity/si7020.c +2 -1
@@ -20,6 +20,7 @@#include <linux/delay.h> #include <linux/i2c.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/slab.h> #include <linux/sysfs.h>
@@ -153,7 +154,7 @@ MODULE_DEVICE_TABLE(of, si7020_dt_ids);static struct i2c_driver si7020_driver = { .driver = { .name ="si7020" , - .of_match_table =of_match_ptr (si7020_dt_ids), + .of_match_table = si7020_dt_ids, }, .probe = si7020_probe, .id_table = si7020_id,
Signature · 1 line
2.28.0
Jonathan Cameron
maintainerPATCH 38/38 iio:health:max30102: Drop of_match_ptr and use generic fw accessors
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This enables use of the driver with ACPI PRP0001 and also removes an antipattern that I am trying to clear out of IIO to avoid it being coppied into new drivers.
--- drivers/iio/health/max30102.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/health/max30102.c +5 -6
@@ -19,7 +19,7 @@#include <linux/irq.h> #include <linux/i2c.h> #include <linux/mutex.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h>
@@ -323,11 +323,10 @@ static int max30102_get_current_idx(unsigned int val, int *reg)static int max30102_led_init (struct max30102_data *data) {struct device *dev = &data->client->dev; -struct device_node *np = dev->of_node;unsigned int val;int reg, ret; - ret =of_property_read_u32 (np,"maxim,red-led-current-microamp" , &val); + ret =device_property_read_u32 (dev,"maxim,red-led-current-microamp" , &val);if (ret) {dev_info (dev,"no red-led-current-microamp set\n" );
@@ -346,7 +345,7 @@ static int max30102_led_init(struct max30102_data *data)return ret;if (data->chip_id == max30105) { - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"maxim,green-led-current-microamp" , &val);if (ret) {dev_info (dev,"no green-led-current-microamp set\n" );
@@ -368,7 +367,7 @@ static int max30102_led_init(struct max30102_data *data)return ret; } - ret =of_property_read_u32 (np,"maxim,ir-led-current-microamp" , &val); + ret =device_property_read_u32 (dev,"maxim,ir-led-current-microamp" , &val);if (ret) {dev_info (dev,"no ir-led-current-microamp set\n" );
@@ -624,7 +623,7 @@ MODULE_DEVICE_TABLE(of, max30102_dt_ids);static struct i2c_driver max30102_driver = { .driver = { .name =MAX30102_DRV_NAME , - .of_match_table =of_match_ptr (max30102_dt_ids), + .of_match_table = max30102_dt_ids, }, .probe = max30102_probe, .remove = max30102_remove,
Signature · 1 line
2.28.0
Re: [PATCH 38/38] iio:health:max30102: Drop of_match_ptr and use generic fw accessors
Quoted 6 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This enables use of the driver with ACPI PRP0001 and also removes an antipattern that I am trying to clear out of IIO to avoid it being coppied into new drivers.
Typo, should be copied.
Quoted 3 lines
Signed-off-by Jonathan Cameron <[email protected]>Cc Matt Ranostay <[email protected]>
Quoted 60 lines
--- drivers/iio/health/max30102.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/health/max30102.c +5
-7@@ -19,7 +19,7 @@#include <linux/irq.h> #include <linux/i2c.h> #include <linux/mutex.h> -#include <linux/of.h> +#include <linux/mod_devicetable.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> @@ -323,11 +323,10 @@ static int max30102_get_current_idx(unsigned int val, int *reg)static int max30102_led_init (struct max30102_data *data) {struct device *dev = &data->client->dev; -struct device_node *np = dev->of_node;unsigned int val;int reg, ret; - ret =of_property_read_u32 (np,"maxim,red-led-current-microamp" , &val); + ret =device_property_read_u32 (dev,"maxim,red-led-current-microamp" , &val);if (ret) {dev_info (dev,"no red-led-current-microamp set\n" );@@ -346,7 +345,7 @@ static int max30102_led_init(struct max30102_data *data)return ret;if (data->chip_id == max30105) { - ret =of_property_read_u32 (np, + ret =device_property_read_u32 (dev,"maxim,green-led-current-microamp" , &val);if (ret) {dev_info (dev,"no green-led-current-microamp set\n" );@@ -368,7 +367,7 @@ static int max30102_led_init(struct max30102_data *data)return ret; } - ret =of_property_read_u32 (np,"maxim,ir-led-current-microamp" , &val); + ret =device_property_read_u32 (dev,"maxim,ir-led-current-microamp" , &val);if (ret) {dev_info (dev,"no ir-led-current-microamp set\n" );@@ -624,7 +623,7 @@ MODULE_DEVICE_TABLE(of, max30102_dt_ids);static struct i2c_driver max30102_driver = { .driver = { .name =MAX30102_DRV_NAME , - .of_match_table =of_match_ptr (max30102_dt_ids), + .of_match_table = max30102_dt_ids, }, .probe = max30102_probe, .remove = max30102_remove, --2.28.0
Quoted 10 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This bumper set removes all the remaining cases where
of_match_ptris mostly serving to prevent use of the device via ACPI PRP0001 and complicating the code. The main aim of this set is to reduce the chances of it being used in future drivers.
It also includes some related refactorings, use of generic fw accessors, dropping ofCONFIG_OFand lots of header changes inline with the above.
Quoted 6 lines
For examples of how to use PRP0001 see https://github.com/westeri/meta-acpi
which is an excellent resource from which to copy snippets of DSDT tables.It may well not be worth changing the remaining 10 IIO drivers and I certainly don't plan to do so anytime soon.
I briefly looked at the series and didn't see anything wrong with it (esp. taking into consideration that you are already familiar with the topic).
Quoted 90 lines
Jonathan Cameron (38):
iio:potentiometer:ad5272: Dropof_match_ptrandCONFIG_OFprotections. iio:potentiometer:ds1803: Dropof_match_ptrandCONFIG_OFprotections iio:potentiometer:max5432: Dropof_match_ptrand use generic fw
accessors
iio:potentiometer:max5481: Dropof_match_ptrandCONFIG_OF
protections.
iio:potentiometer:max5481: Drop invalid ACPI binding. iio:potentiometer:mcp4018: Dropof_match_ptrandCONFIG_OF
protections.
iio:potentiometer:mcp4131: Dropof_match_ptrand use generic fw
interfaces.
iio:potentiometer:mcp4531: Dropof_match_ptrandCONFIG_OF
protections.
iio:dac:ad5446: Dropof_match_ptrandCONFIG_OFprotections iio:dac:ad5592r: Dropof_match_ptrandACPI_PTRprotections. iio:dac:ad5593r: Dropof_match_ptrandACPI_PTRprotections. iio:dac:ad7303: Dropof_match_ptrprotection iio:dac:mcp4725: dropof_match_ptrand use generic fw properties iio:dac:ti-dac082s085: Dropof_match_ptrandCONFIG_OFprotections iio:dac:ti-dac5571: Dropof_match_ptrandCONFIG_OFprotections iio:potentiostat:lmp91000: Dropof_match_ptrand use generic fw
accessors
iio:pressure:icp10100: Dropof_match_ptrandCONFIG_OFprotections iio:pressure:ms5611: Dropof_match_ptrandCONFIG_OFprotections iio:pressure:ms5637: Dropof_match_ptrprotection iio:pressure:zpa2326: Dropof_match_ptrprotection iio:temperature:tsys01: Dropof_match_ptrprotection iio:temperature:tmp007: Dropof_match_ptrprotection iio:resolver:ad2s1200: Dropof_match_ptrprotection iio:chemical:ams-iaq-core: Dropof_match_ptrprotection iio:chemical:atlas-sensor: Dropof_match_ptrand use generic fw
accessors
iio:chemical:sgp30: Use local variable dev to simplify code iio:chemical:sgp30: Dropof_match_ptrand use generic fw accessors iio:chemical:vz89x: Introduce local struct device pointer. iio:chemical:vz89x: Dropof_match_ptrprotection and use generic fw
accessors
iio:humidity:hdc100x: Dropof_match_ptrprotection. iio:proximity:as3935: Use local struct device pointer to simplify
code.
iio:proximity:as3935: Dropof_match_ptrand use generic fw accessors iio:proximity:pulsedlight: Dropof_match_ptrprotection iio:magn:ak8975: Dropof_match_ptrandACPI_PTRprotections. iio:magn:ak8974: Dropof_match_ptrprotection iio:humidity:htu21: Dropof_match_ptrprotection iio:humidity:si7020: Dropof_match_ptrprotection iio:health:max30102: Dropof_match_ptrand use generic fw accessorsdrivers/iio/chemical/ams-iaq-core.c | 3 +- drivers/iio/chemical/atlas-sensor.c | 10 ++--- drivers/iio/chemical/sgp30.c | 28 ++++++------ drivers/iio/chemical/vz89x.c | 18 ++++---- drivers/iio/dac/ad5446.c | 5 +-- drivers/iio/dac/ad5592r.c | 7 ++- drivers/iio/dac/ad5593r.c | 7 ++- drivers/iio/dac/ad7303.c | 3 +- drivers/iio/dac/mcp4725.c | 29 +++--------- drivers/iio/dac/ti-dac082s085.c | 5 +-- drivers/iio/dac/ti-dac5571.c | 7 +-- drivers/iio/health/max30102.c | 11 +++-- drivers/iio/humidity/hdc100x.c | 3 +- drivers/iio/humidity/htu21.c | 3 +- drivers/iio/humidity/si7020.c | 3 +- drivers/iio/magnetometer/ak8974.c | 3 +- drivers/iio/magnetometer/ak8975.c | 8 ++-- drivers/iio/potentiometer/ad5272.c | 5 +-- drivers/iio/potentiometer/ds1803.c | 6 +-- drivers/iio/potentiometer/max5432.c | 8 ++-- drivers/iio/potentiometer/max5481.c | 23 ++-------- drivers/iio/potentiometer/mcp4018.c | 12 ++--- drivers/iio/potentiometer/mcp4131.c | 8 ++-- drivers/iio/potentiometer/mcp4531.c | 11 ++--- drivers/iio/potentiostat/lmp91000.c | 11 +++-- drivers/iio/pressure/icp10100.c | 3 +- drivers/iio/pressure/ms5611_i2c.c | 6 +-- drivers/iio/pressure/ms5611_spi.c | 6 +-- drivers/iio/pressure/ms5637.c | 3 +- drivers/iio/pressure/zpa2326_i2c.c | 6 +-- drivers/iio/pressure/zpa2326_spi.c | 6 +-- drivers/iio/proximity/as3935.c | 44 +++++++++---------- .../iio/proximity/pulsedlight-lidar-lite-v2.c | 3 +- drivers/iio/resolver/ad2s1200.c | 3 +- drivers/iio/temperature/tmp007.c | 4 +- drivers/iio/temperature/tsys01.c | 3 +- 36 files changed, 134 insertions(+), 190 deletions(-)--
2.28.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 14 lines · On Mon, 14 Sep 2020 11:04:43 +0300 Andy Shevchenko <[email protected]>…
Quoted 13 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This bumper set removes all the remaining cases where
of_match_ptris mostly serving to prevent use of the device via ACPI PRP0001 and complicating the code. The main aim of this set is to reduce the chances of it being used in future drivers.
It also includes some related refactorings, use of generic fw accessors, dropping ofCONFIG_OFand lots of header changes inline with the above.For examples of how to use PRP0001 see https://github.com/westeri/meta-acpi
which is an excellent resource from which to copy snippets of DSDT tables.
Quoted 8 lines
Quoted 3 lines
It may well not be worth changing the remaining 10 IIO drivers and I certainly don't plan to do so anytime soon.
I briefly looked at the series and didn't see anything wrong with it (esp. taking into consideration that you are already familiar with the topic).
Reviewed-by Andy Shevchenko <[email protected]>
Thanks Andy + others that reviewed. I've fixed the typo's in descriptions Matt highlighted and applied the lot.
If anyone want to add tags, it will be a few days before I push this out as a non rebasing tree.
Thanks,
Jonathan
Quoted 93 lines
Quoted 91 lines
Jonathan Cameron (38):
iio:potentiometer:ad5272: Dropof_match_ptrandCONFIG_OFprotections. iio:potentiometer:ds1803: Dropof_match_ptrandCONFIG_OFprotections iio:potentiometer:max5432: Dropof_match_ptrand use generic fw
accessors
iio:potentiometer:max5481: Dropof_match_ptrandCONFIG_OF
protections.
iio:potentiometer:max5481: Drop invalid ACPI binding. iio:potentiometer:mcp4018: Dropof_match_ptrandCONFIG_OF
protections.
iio:potentiometer:mcp4131: Dropof_match_ptrand use generic fw
interfaces.
iio:potentiometer:mcp4531: Dropof_match_ptrandCONFIG_OF
protections.
iio:dac:ad5446: Dropof_match_ptrandCONFIG_OFprotections iio:dac:ad5592r: Dropof_match_ptrandACPI_PTRprotections. iio:dac:ad5593r: Dropof_match_ptrandACPI_PTRprotections. iio:dac:ad7303: Dropof_match_ptrprotection iio:dac:mcp4725: dropof_match_ptrand use generic fw properties iio:dac:ti-dac082s085: Dropof_match_ptrandCONFIG_OFprotections iio:dac:ti-dac5571: Dropof_match_ptrandCONFIG_OFprotections iio:potentiostat:lmp91000: Dropof_match_ptrand use generic fw
accessors
iio:pressure:icp10100: Dropof_match_ptrandCONFIG_OFprotections iio:pressure:ms5611: Dropof_match_ptrandCONFIG_OFprotections iio:pressure:ms5637: Dropof_match_ptrprotection iio:pressure:zpa2326: Dropof_match_ptrprotection iio:temperature:tsys01: Dropof_match_ptrprotection iio:temperature:tmp007: Dropof_match_ptrprotection iio:resolver:ad2s1200: Dropof_match_ptrprotection iio:chemical:ams-iaq-core: Dropof_match_ptrprotection iio:chemical:atlas-sensor: Dropof_match_ptrand use generic fw
accessors
iio:chemical:sgp30: Use local variable dev to simplify code iio:chemical:sgp30: Dropof_match_ptrand use generic fw accessors iio:chemical:vz89x: Introduce local struct device pointer. iio:chemical:vz89x: Dropof_match_ptrprotection and use generic fw
accessors
iio:humidity:hdc100x: Dropof_match_ptrprotection. iio:proximity:as3935: Use local struct device pointer to simplify
code.
iio:proximity:as3935: Dropof_match_ptrand use generic fw accessors iio:proximity:pulsedlight: Dropof_match_ptrprotection iio:magn:ak8975: Dropof_match_ptrandACPI_PTRprotections. iio:magn:ak8974: Dropof_match_ptrprotection iio:humidity:htu21: Dropof_match_ptrprotection iio:humidity:si7020: Dropof_match_ptrprotection iio:health:max30102: Dropof_match_ptrand use generic fw accessorsdrivers/iio/chemical/ams-iaq-core.c | 3 +- drivers/iio/chemical/atlas-sensor.c | 10 ++--- drivers/iio/chemical/sgp30.c | 28 ++++++------ drivers/iio/chemical/vz89x.c | 18 ++++---- drivers/iio/dac/ad5446.c | 5 +-- drivers/iio/dac/ad5592r.c | 7 ++- drivers/iio/dac/ad5593r.c | 7 ++- drivers/iio/dac/ad7303.c | 3 +- drivers/iio/dac/mcp4725.c | 29 +++--------- drivers/iio/dac/ti-dac082s085.c | 5 +-- drivers/iio/dac/ti-dac5571.c | 7 +-- drivers/iio/health/max30102.c | 11 +++-- drivers/iio/humidity/hdc100x.c | 3 +- drivers/iio/humidity/htu21.c | 3 +- drivers/iio/humidity/si7020.c | 3 +- drivers/iio/magnetometer/ak8974.c | 3 +- drivers/iio/magnetometer/ak8975.c | 8 ++-- drivers/iio/potentiometer/ad5272.c | 5 +-- drivers/iio/potentiometer/ds1803.c | 6 +-- drivers/iio/potentiometer/max5432.c | 8 ++-- drivers/iio/potentiometer/max5481.c | 23 ++-------- drivers/iio/potentiometer/mcp4018.c | 12 ++--- drivers/iio/potentiometer/mcp4131.c | 8 ++-- drivers/iio/potentiometer/mcp4531.c | 11 ++--- drivers/iio/potentiostat/lmp91000.c | 11 +++-- drivers/iio/pressure/icp10100.c | 3 +- drivers/iio/pressure/ms5611_i2c.c | 6 +-- drivers/iio/pressure/ms5611_spi.c | 6 +-- drivers/iio/pressure/ms5637.c | 3 +- drivers/iio/pressure/zpa2326_i2c.c | 6 +-- drivers/iio/pressure/zpa2326_spi.c | 6 +-- drivers/iio/proximity/as3935.c | 44 +++++++++---------- .../iio/proximity/pulsedlight-lidar-lite-v2.c | 3 +- drivers/iio/resolver/ad2s1200.c | 3 +- drivers/iio/temperature/tmp007.c | 4 +- drivers/iio/temperature/tsys01.c | 3 +- 36 files changed, 134 insertions(+), 190 deletions(-)--
2.28.0