iio: Clean up macro definitions
Subsystems (5)
cover iio: Clean up macro definitions
Currently there are a bunch of drivers using macro definitions for string literals that are only used once. There seem to be a "style guide" to not do this, and this is often mentioned during the reviews (if caught). And since developers most often look at other drivers for inspiration (or just trying to figure out the "style guide") when writing a new one, it is desirable to have some consistency.
In this patch series we identify the drivers that have macro definitions for string literals that are only used once. The most common one is the driver name. These can be identified by
rgrep -A 10 "\.driver" drivers/iio/ | grep "\.name" | grep -v '"'
And then count the number of occurrences of the particular macro definition (e.g. with grep -c). Most drivers use these macro definitions for .name in struct device_driver and indio_dev->name (which could be justified with a macro definition). However, the ones with only one occurrence are identified and removed in this patch series.
There are also drivers that have a mixture, e.g. macro definition for indio_dev->name but in-line string literal for .name in struct device_driver). The following have therefore not been touched (but should maybe use the macro definition for both places):
drivers/iio/accel/stk8ba50.c
drivers/iio/accel/mma7660.c
drivers/iio/humidity/am2315.c
drivers/iio/light/stk3310.c
Likewise, there are drivers that only use KBUILD_MODNAME in one place. These have also been left for the same reasons.
Finally, while cleaning up these ones, other similar macro definitions could be identified with the same "style guide" issue: macro definitions for IRQ name and regmap name. There are even unused macro definitions. All of these are also addressed in this patch series.
Waqar Hameed (4):
iio: Remove single use of macro definition for driver name
iio: Remove single use of macro definition for IRQ name
iio: Remove single use of macro definition for regmap name
iio: Remove unused macro definition for driver and IRQ name
drivers/iio/accel/bma180.c | 3 --- drivers/iio/accel/bmc150-accel-core.c | 5 +---- drivers/iio/accel/kxcjk-1013.c | 7 ++----- drivers/iio/accel/mma9551.c | 6 ++---- drivers/iio/accel/mma9553.c | 7 ++----- drivers/iio/accel/mxc4005.c | 6 ++---- drivers/iio/accel/mxc6255.c | 3 +-- drivers/iio/accel/sca3300.c | 4 +--- drivers/iio/accel/stk8312.c | 3 +-- drivers/iio/accel/stk8ba50.c | 3 +-- drivers/iio/adc/hi8435.c | 4 +--- drivers/iio/adc/max9611.c | 4 +--- drivers/iio/adc/vf610_adc.c | 5 +---- drivers/iio/chemical/atlas-sensor.c | 3 +-- drivers/iio/dac/max517.c | 4 +--- drivers/iio/dac/mcp4725.c | 4 +--- drivers/iio/gyro/bmg160_core.c | 4 +--- drivers/iio/health/max30100.c | 3 +-- drivers/iio/health/max30102.c | 3 +-- drivers/iio/humidity/dht11.c | 4 +--- drivers/iio/imu/kmx61.c | 7 ++----- drivers/iio/light/adux1020.c | 3 +-- drivers/iio/light/apds9160.c | 4 +--- drivers/iio/light/apds9300.c | 3 +-- drivers/iio/light/apds9960.c | 3 +-- drivers/iio/light/jsa1212.c | 3 +-- drivers/iio/light/ltr501.c | 8 ++------ drivers/iio/light/rpr0521.c | 6 ++---- drivers/iio/light/stk3310.c | 6 ++---- drivers/iio/light/vcnl4035.c | 6 ++---- drivers/iio/magnetometer/bmc150_magn.c | 5 +---- drivers/iio/magnetometer/mmc35240.c | 3 +-- drivers/iio/proximity/sx9500.c | 3 +-- drivers/iio/resolver/ad2s1200.c | 3 +-- 34 files changed, 42 insertions(+), 106 deletions(-)
base-commit: 914873bc7df913db988284876c16257e6ab772c6
Signature · 1 line
2.39.5
PATCH 1/4 iio: Remove single use of macro definition for driver name
There is really no reason for having the driver name as a macro definition if it is only used once (often as .name in struct device_driver). It is also more readable this way. Remove these macro definitions and instead use the string literal directly.
--- drivers/iio/accel/kxcjk-1013.c | 3 +-- drivers/iio/accel/mma9551.c | 3 +-- drivers/iio/accel/mma9553.c | 3 +-- drivers/iio/accel/sca3300.c | 4 +--- drivers/iio/adc/hi8435.c | 4 +--- drivers/iio/adc/max9611.c | 4 +--- drivers/iio/adc/vf610_adc.c | 5 +---- drivers/iio/dac/max517.c | 4 +--- drivers/iio/dac/mcp4725.c | 4 +--- drivers/iio/humidity/dht11.c | 4 +--- drivers/iio/imu/kmx61.c | 3 +-- drivers/iio/light/ltr501.c | 4 +--- drivers/iio/resolver/ad2s1200.c | 3 +-- 13 files changed, 13 insertions(+), 35 deletions(-)
drivers/iio/accel/kxcjk-1013.c +1 -2
@@ -26,7 +26,6 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/accel/kxcjk_1013.h> -#define KXCJK1013_DRV_NAME "kxcjk1013"#define KXCJK1013_IRQ_NAME "kxcjk1013_event"#define KXTF9_REG_HP_XOUT_L 0x00
@@ -1727,7 +1726,7 @@ MODULE_DEVICE_TABLE(acpi, kx_acpi_match);static struct i2c_driver kxcjk1013_driver = { .driver = { - .name =KXCJK1013_DRV_NAME , + .name ="kxcjk1013" , .acpi_match_table = kx_acpi_match, .of_match_table = kxcjk1013_of_match, .pm =pm_ptr (&kxcjk1013_pm_ops),
drivers/iio/accel/mma9551.c +1 -2
@@ -17,7 +17,6 @@#include <linux/pm_runtime.h> #include "mma9551_core.h" -#define MMA9551_DRV_NAME "mma9551"#define MMA9551_IRQ_NAME "mma9551_event"#define MMA9551_GPIO_COUNT 4
@@ -592,7 +591,7 @@ MODULE_DEVICE_TABLE(i2c, mma9551_id);static struct i2c_driver mma9551_driver = { .driver = { - .name =MMA9551_DRV_NAME , + .name ="mma9551" , .acpi_match_table = mma9551_acpi_match, .pm =pm_ptr (&mma9551_pm_ops), },
drivers/iio/accel/mma9553.c +1 -2
@@ -15,7 +15,6 @@#include <linux/pm_runtime.h> #include "mma9551_core.h" -#define MMA9553_DRV_NAME "mma9553"#define MMA9553_IRQ_NAME "mma9553_event"/* Pedometer configuration registers (R/W) */
@@ -1230,7 +1229,7 @@ MODULE_DEVICE_TABLE(i2c, mma9553_id);static struct i2c_driver mma9553_driver = { .driver = { - .name =MMA9553_DRV_NAME , + .name ="mma9553" , .acpi_match_table = mma9553_acpi_match, .pm =pm_ptr (&mma9553_pm_ops), },
drivers/iio/accel/sca3300.c +1 -3
@@ -20,8 +20,6 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#define SCA3300_ALIAS "sca3300" -#define SCA3300_CRC8_POLYNOMIAL 0x1d/* Device mode register */
@@ -687,7 +685,7 @@ MODULE_DEVICE_TABLE(spi, sca3300_ids);static struct spi_driver sca3300_driver = { .driver = { - .name =SCA3300_ALIAS , + .name ="sca3300" , .of_match_table = sca3300_dt_ids, }, .probe = sca3300_probe,
drivers/iio/adc/hi8435.c +1 -3
@@ -19,8 +19,6 @@#include <linux/spi/spi.h> #include <linux/gpio/consumer.h> -#define DRV_NAME "hi8435" -/* Register offsets for HI-8435 */ #define HI8435_CTRL_REG 0x02#define HI8435_PSEN_REG 0x04
@@ -536,7 +534,7 @@ MODULE_DEVICE_TABLE(spi, hi8435_id);static struct spi_driver hi8435_driver = { .driver = { - .name =DRV_NAME , + .name ="hi8435" , .of_match_table = hi8435_dt_ids, }, .probe = hi8435_probe,
drivers/iio/adc/max9611.c +1 -3
@@ -25,8 +25,6 @@#include <linux/mod_devicetable.h> #include <linux/property.h> -#define DRIVER_NAME "max9611" -/* max9611 register addresses */ #define MAX9611_REG_CSA_DATA 0x00#define MAX9611_REG_RS_DATA 0x02
@@ -553,7 +551,7 @@ static int max9611_probe(struct i2c_client *client)static struct i2c_driver max9611_driver = { .driver = { - .name =DRIVER_NAME , + .name ="max9611" , .of_match_table = max9611_of_table, }, .probe = max9611_probe,
drivers/iio/adc/vf610_adc.c +1 -4
@@ -27,9 +27,6 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -/* This will be the driver name the kernel reports */ -#define DRIVER_NAME "vf610-adc" -/* Vybrid/IMX ADC registers */ #define VF610_REG_ADC_HC0 0x00#define VF610_REG_ADC_HC1 0x04
@@ -962,7 +959,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend,static struct platform_driver vf610_adc_driver = { .probe = vf610_adc_probe, .driver = { - .name =DRIVER_NAME , + .name ="vf610-adc" , .of_match_table = vf610_adc_match, .pm =pm_sleep_ptr (&vf610_adc_pm_ops), },
drivers/iio/dac/max517.c +1 -3
@@ -15,8 +15,6 @@#include <linux/iio/sysfs.h> #include <linux/iio/dac/max517.h> -#define MAX517_DRV_NAME "max517" -/* Commands */ #define COMMAND_CHANNEL0 0x00#define COMMAND_CHANNEL1 0x01/* for MAX518 and MAX519 */
@@ -200,7 +198,7 @@ MODULE_DEVICE_TABLE(i2c, max517_id);static struct i2c_driver max517_driver = { .driver = { - .name =MAX517_DRV_NAME , + .name ="max517" , .pm =pm_sleep_ptr (&max517_pm_ops), }, .probe = max517_probe,
drivers/iio/dac/mcp4725.c +1 -3
@@ -24,8 +24,6 @@#include <linux/iio/dac/mcp4725.h> -#define MCP4725_DRV_NAME "mcp4725" -#define MCP472X_REF_VDD 0x00#define MCP472X_REF_VREF_UNBUFFERED 0x02#define MCP472X_REF_VREF_BUFFERED 0x03
@@ -546,7 +544,7 @@ MODULE_DEVICE_TABLE(of, mcp4725_of_match);static struct i2c_driver mcp4725_driver = { .driver = { - .name =MCP4725_DRV_NAME , + .name ="mcp4725" , .of_match_table = mcp4725_of_match, .pm =pm_sleep_ptr (&mcp4725_pm_ops), },
drivers/iio/humidity/dht11.c +1 -3
@@ -27,8 +27,6 @@#include <linux/iio/iio.h> -#define DRIVER_NAME "dht11" -#define DHT11_DATA_VALID_TIME 2000000000/* 2s in ns */ #define DHT11_EDGES_PREAMBLE 2
@@ -331,7 +329,7 @@ static int dht11_probe(struct platform_device *pdev)static struct platform_driver dht11_driver = { .driver = { - .name =DRIVER_NAME , + .name ="dht11" , .of_match_table = dht11_dt_ids, }, .probe = dht11_probe,
drivers/iio/imu/kmx61.c +1 -2
@@ -22,7 +22,6 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> -#define KMX61_DRV_NAME "kmx61"#define KMX61_IRQ_NAME "kmx61_event"#define KMX61_REG_WHO_AM_I 0x00
@@ -1494,7 +1493,7 @@ MODULE_DEVICE_TABLE(i2c, kmx61_id);static struct i2c_driver kmx61_driver = { .driver = { - .name =KMX61_DRV_NAME , + .name ="kmx61" , .pm =pm_ptr (&kmx61_pm_ops), }, .probe = kmx61_probe,
drivers/iio/light/ltr501.c +1 -3
@@ -24,8 +24,6 @@#include <linux/iio/buffer.h> #include <linux/iio/triggered_buffer.h> -#define LTR501_DRV_NAME "ltr501" -#define LTR501_ALS_CONTR 0x80/* ALS operation mode, SW reset */ #define LTR501_PS_CONTR 0x81/* PS operation mode */ #define LTR501_PS_MEAS_RATE 0x84/* measurement rate*/
@@ -1624,7 +1622,7 @@ MODULE_DEVICE_TABLE(of, ltr501_of_match);static struct i2c_driver ltr501_driver = { .driver = { - .name =LTR501_DRV_NAME , + .name ="ltr501" , .of_match_table = ltr501_of_match, .pm =pm_sleep_ptr (<r501_pm_ops), .acpi_match_table = ltr_acpi_match,
drivers/iio/resolver/ad2s1200.c +1 -2
@@ -21,7 +21,6 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -#define DRV_NAME "ad2s1200"/* input clock on serial interface */ #define AD2S1200_HZ 8192000
@@ -192,7 +191,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1200_id);static struct spi_driver ad2s1200_driver = { .driver = { - .name =DRV_NAME , + .name ="ad2s1200" , .of_match_table = ad2s1200_of_match, }, .probe = ad2s1200_probe,
Signature · 1 line
2.39.5
PATCH 2/4 iio: Remove single use of macro definition for IRQ name
In reply to Waqar HameedThere is really no reason for having the IRQ name as a macro definition if it is only used once (often in functions requesting the IRQ). It is also more readable this way. Remove these macro definitions and instead use the string literal directly.
--- drivers/iio/accel/bmc150-accel-core.c | 3 +-- drivers/iio/accel/kxcjk-1013.c | 4 +--- drivers/iio/accel/mma9551.c | 3 +-- drivers/iio/accel/mma9553.c | 4 +--- drivers/iio/accel/mxc4005.c | 3 +-- drivers/iio/accel/stk8312.c | 3 +-- drivers/iio/accel/stk8ba50.c | 3 +-- drivers/iio/gyro/bmg160_core.c | 4 +--- drivers/iio/imu/kmx61.c | 4 +--- drivers/iio/light/apds9300.c | 3 +-- drivers/iio/light/rpr0521.c | 3 +-- drivers/iio/light/stk3310.c | 3 +-- drivers/iio/light/vcnl4035.c | 3 +-- drivers/iio/magnetometer/bmc150_magn.c | 3 +-- drivers/iio/proximity/sx9500.c | 3 +-- 15 files changed, 15 insertions(+), 34 deletions(-)
drivers/iio/accel/bmc150-accel-core.c +1 -2
@@ -26,7 +26,6 @@#include "bmc150-accel.h" #define BMC150_ACCEL_DRV_NAME "bmc150_accel" -#define BMC150_ACCEL_IRQ_NAME "bmc150_accel_event"#define BMC150_ACCEL_REG_CHIP_ID 0x00
@@ -1706,7 +1705,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, bmc150_accel_irq_handler, bmc150_accel_irq_thread_handler,IRQF_TRIGGER_RISING , -BMC150_ACCEL_IRQ_NAME , +"bmc150_accel_event" , indio_dev);if (ret) goto err_buffer_cleanup;
drivers/iio/accel/kxcjk-1013.c +1 -3
@@ -26,8 +26,6 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/accel/kxcjk_1013.h> -#define KXCJK1013_IRQ_NAME "kxcjk1013_event" -#define KXTF9_REG_HP_XOUT_L 0x00#define KXTF9_REG_HP_XOUT_H 0x01#define KXTF9_REG_HP_YOUT_L 0x02
@@ -1516,7 +1514,7 @@ static int kxcjk1013_probe(struct i2c_client *client) kxcjk1013_data_rdy_trig_poll, kxcjk1013_event_handler,IRQF_TRIGGER_RISING , -KXCJK1013_IRQ_NAME , +"kxcjk1013_event" , indio_dev);if (ret) goto err_poweroff;
drivers/iio/accel/mma9551.c +1 -2
@@ -17,7 +17,6 @@#include <linux/pm_runtime.h> #include "mma9551_core.h" -#define MMA9551_IRQ_NAME "mma9551_event"#define MMA9551_GPIO_COUNT 4/* Tilt application (inclination in IIO terms). */
@@ -421,7 +420,7 @@ static int mma9551_gpio_probe(struct iio_dev *indio_dev) ret =devm_request_threaded_irq (dev, data->irqs[i],NULL , mma9551_event_handler,IRQF_TRIGGER_RISING |IRQF_ONESHOT , -MMA9551_IRQ_NAME , indio_dev); +"mma9551_event" , indio_dev);if (ret <0 ) {dev_err (dev,"request irq %d failed\n" , data->irqs[i]);return ret;
drivers/iio/accel/mma9553.c +1 -3
@@ -15,8 +15,6 @@#include <linux/pm_runtime.h> #include "mma9551_core.h" -#define MMA9553_IRQ_NAME "mma9553_event" -/* Pedometer configuration registers (R/W) */ #define MMA9553_REG_CONF_SLEEPMIN 0x00#define MMA9553_REG_CONF_SLEEPMAX 0x02
@@ -1101,7 +1099,7 @@ static int mma9553_probe(struct i2c_client *client) mma9553_irq_handler, mma9553_event_handler,IRQF_TRIGGER_RISING , - MMA9553_IRQ_NAME, indio_dev); + "mma9553_event", indio_dev);if (ret <0 ) {dev_err (&client->dev,"request irq %d failed\n" , client->irq);
drivers/iio/accel/mxc4005.c +1 -2
@@ -19,7 +19,6 @@#include <linux/iio/trigger_consumer.h> #define MXC4005_DRV_NAME "mxc4005" -#define MXC4005_IRQ_NAME "mxc4005_event"#define MXC4005_REGMAP_NAME "mxc4005_regmap"#define MXC4005_REG_XOUT_UPPER 0x03
@@ -493,7 +492,7 @@ static int mxc4005_probe(struct i2c_client *client)NULL ,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , -MXC4005_IRQ_NAME , +"mxc4005_event" , data->dready_trig);if (ret) { dev_err(&client->dev,
drivers/iio/accel/stk8312.c +1 -2
@@ -46,7 +46,6 @@#define STK8312_ALL_CHANNEL_SIZE 3#define STK8312_DRIVER_NAME "stk8312" -#define STK8312_IRQ_NAME "stk8312_event"/* * The accelerometer has two measurement ranges:
@@ -543,7 +542,7 @@ static int stk8312_probe(struct i2c_client *client)NULL ,IRQF_TRIGGER_RISING |IRQF_ONESHOT , -STK8312_IRQ_NAME , +"stk8312_event" , indio_dev);if (ret <0 ) { dev_err(&client->dev, "request irq %d failed\n",
drivers/iio/accel/stk8ba50.c +1 -2
@@ -42,7 +42,6 @@#define STK8BA50_ALL_CHANNEL_SIZE 6#define STK8BA50_DRIVER_NAME "stk8ba50" -#define STK8BA50_IRQ_NAME "stk8ba50_event"#define STK8BA50_SCALE_AVAIL "0.0384 0.0767 0.1534 0.3069"
@@ -436,7 +435,7 @@ static int stk8ba50_probe(struct i2c_client *client)NULL ,IRQF_TRIGGER_RISING |IRQF_ONESHOT , -STK8BA50_IRQ_NAME , +"stk8ba50_event" , indio_dev);if (ret <0 ) { dev_err(&client->dev, "request irq %d failed\n",
drivers/iio/gyro/bmg160_core.c +1 -3
@@ -21,8 +21,6 @@#include <linux/regulator/consumer.h> #include "bmg160.h" -#define BMG160_IRQ_NAME "bmg160_event" -#define BMG160_REG_CHIP_ID 0x00#define BMG160_CHIP_ID_VAL 0x0F
@@ -1099,7 +1097,7 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, bmg160_data_rdy_trig_poll, bmg160_event_handler,IRQF_TRIGGER_RISING , -BMG160_IRQ_NAME , +"bmg160_event" , indio_dev);if (ret)return ret;
drivers/iio/imu/kmx61.c +1 -3
@@ -22,8 +22,6 @@#include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> -#define KMX61_IRQ_NAME "kmx61_event" -#define KMX61_REG_WHO_AM_I 0x00#define KMX61_REG_INS1 0x01#define KMX61_REG_INS2 0x02
@@ -1311,7 +1309,7 @@ static int kmx61_probe(struct i2c_client *client) kmx61_data_rdy_trig_poll, kmx61_event_handler,IRQF_TRIGGER_RISING , -KMX61_IRQ_NAME , +"kmx61_event" , data);if (ret) goto err_chip_uninit;
drivers/iio/light/apds9300.c +1 -2
@@ -17,7 +17,6 @@#include <linux/iio/events.h> #define APDS9300_DRV_NAME "apds9300" -#define APDS9300_IRQ_NAME "apds9300_event"/* Command register bits */ #define APDS9300_CMD BIT(7)/* Select command register. Must write as 1 */
@@ -432,7 +431,7 @@ static int apds9300_probe(struct i2c_client *client) ret =devm_request_threaded_irq (&client->dev, client->irq,NULL , apds9300_interrupt_handler,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , -APDS9300_IRQ_NAME , indio_dev); +"apds9300_event" , indio_dev);if (ret) {dev_err (&client->dev,"irq request error %d\n" , -ret); goto err;
drivers/iio/light/rpr0521.c +1 -2
@@ -68,7 +68,6 @@#define RPR0521_DEFAULT_MEAS_TIME 0x06/* ALS - 100ms, PXS - 100ms */ #define RPR0521_DRV_NAME "RPR0521" -#define RPR0521_IRQ_NAME "rpr0521_event"#define RPR0521_REGMAP_NAME "rpr0521_regmap"#define RPR0521_SLEEP_DELAY_MS 2000
@@ -982,7 +981,7 @@ static int rpr0521_probe(struct i2c_client *client) ret =devm_request_threaded_irq (&client->dev, client->irq, rpr0521_drdy_irq_handler, rpr0521_drdy_irq_thread,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , -RPR0521_IRQ_NAME , indio_dev); +"rpr0521_event" , indio_dev);if (ret <0 ) {dev_err (&client->dev,"request irq %d for trigger0 failed\n" , client->irq);
drivers/iio/light/stk3310.c +1 -2
@@ -47,7 +47,6 @@#define STK3310_DRIVER_NAME "stk3310"#define STK3310_REGMAP_NAME "stk3310_regmap" -#define STK3310_EVENT "stk3310_event"#define STK3310_SCALE_AVAILABLE "6.4 1.6 0.4 0.1"
@@ -643,7 +642,7 @@ static int stk3310_probe(struct i2c_client *client) stk3310_irq_event_handler,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , - STK3310_EVENT, indio_dev); + "stk3310_event", indio_dev);if (ret <0 ) {dev_err (&client->dev,"request irq %d failed\n" , client->irq);
drivers/iio/light/vcnl4035.c +1 -2
@@ -23,7 +23,6 @@#include <linux/iio/triggered_buffer.h> #define VCNL4035_DRV_NAME "vcnl4035" -#define VCNL4035_IRQ_NAME "vcnl4035_event"#define VCNL4035_REGMAP_NAME "vcnl4035_regmap"/* Device registers */
@@ -535,7 +534,7 @@ static int vcnl4035_probe_trigger(struct iio_dev *indio_dev) ret =devm_request_threaded_irq (&data->client->dev, data->client->irq,NULL , vcnl4035_drdy_irq_thread,IRQF_TRIGGER_LOW |IRQF_ONESHOT , -VCNL4035_IRQ_NAME , indio_dev); +"vcnl4035_event" , indio_dev);if (ret <0 )dev_err (&data->client->dev,"request irq %d for trigger0 failed\n" , data->client->irq);
drivers/iio/magnetometer/bmc150_magn.c +1 -2
@@ -29,7 +29,6 @@#include "bmc150_magn.h" #define BMC150_MAGN_DRV_NAME "bmc150_magn" -#define BMC150_MAGN_IRQ_NAME "bmc150_magn_event"#define BMC150_MAGN_REG_CHIP_ID 0x40#define BMC150_MAGN_CHIP_ID_VAL 0x32
@@ -918,7 +917,7 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap, iio_trigger_generic_data_rdy_poll,NULL ,IRQF_TRIGGER_RISING |IRQF_ONESHOT , -BMC150_MAGN_IRQ_NAME , +"bmc150_magn_event" , data->dready_trig);if (ret <0 ) {dev_err (dev,"request irq %d failed\n" , irq);
drivers/iio/proximity/sx9500.c +1 -2
@@ -27,7 +27,6 @@#include <linux/iio/trigger_consumer.h> #define SX9500_DRIVER_NAME "sx9500" -#define SX9500_IRQ_NAME "sx9500_event"/* Register definitions. */ #define SX9500_REG_IRQ_SRC 0x00
@@ -939,7 +938,7 @@ static int sx9500_probe(struct i2c_client *client) ret =devm_request_threaded_irq (&client->dev, client->irq, sx9500_irq_handler, sx9500_irq_thread_handler,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , -SX9500_IRQ_NAME , indio_dev); +"sx9500_event" , indio_dev);if (ret <0 )return ret;
Signature · 1 line
2.39.5
PATCH 3/4 iio: Remove single use of macro definition for regmap name
In reply to Waqar HameedThere is really no reason for having the regmap name as a macro definition if it is only used once directly in struct regmap_config. It is also more readable this way. Remove these macro definitions and instead use the string literal directly.
--- drivers/iio/accel/mxc4005.c | 3 +-- drivers/iio/accel/mxc6255.c | 3 +-- drivers/iio/chemical/atlas-sensor.c | 3 +-- drivers/iio/health/max30100.c | 3 +-- drivers/iio/health/max30102.c | 3 +-- drivers/iio/light/adux1020.c | 3 +-- drivers/iio/light/apds9160.c | 4 +--- drivers/iio/light/apds9960.c | 3 +-- drivers/iio/light/jsa1212.c | 3 +-- drivers/iio/light/ltr501.c | 4 +--- drivers/iio/light/rpr0521.c | 3 +-- drivers/iio/light/stk3310.c | 3 +-- drivers/iio/light/vcnl4035.c | 3 +-- drivers/iio/magnetometer/mmc35240.c | 3 +-- 14 files changed, 14 insertions(+), 30 deletions(-)
drivers/iio/accel/mxc4005.c +1 -2
@@ -19,7 +19,6 @@#include <linux/iio/trigger_consumer.h> #define MXC4005_DRV_NAME "mxc4005" -#define MXC4005_REGMAP_NAME "mxc4005_regmap"#define MXC4005_REG_XOUT_UPPER 0x03#define MXC4005_REG_XOUT_LOWER 0x04
@@ -137,7 +136,7 @@ static bool mxc4005_is_writeable_reg(struct device *dev, unsigned int reg) }static const struct regmap_config mxc4005_regmap_config = { - .name =MXC4005_REGMAP_NAME , + .name ="mxc4005_regmap" , .reg_bits =8 , .val_bits =8 ,
drivers/iio/accel/mxc6255.c +1 -2
@@ -17,7 +17,6 @@#include <linux/iio/sysfs.h> #define MXC6255_DRV_NAME "mxc6255" -#define MXC6255_REGMAP_NAME "mxc6255_regmap"#define MXC6255_REG_XOUT 0x00#define MXC6255_REG_YOUT 0x01
@@ -105,7 +104,7 @@ static bool mxc6255_is_readable_reg(struct device *dev, unsigned int reg) }static const struct regmap_config mxc6255_regmap_config = { - .name =MXC6255_REGMAP_NAME , + .name ="mxc6255_regmap" , .reg_bits =8 , .val_bits =8 ,
drivers/iio/chemical/atlas-sensor.c +1 -2
@@ -24,7 +24,6 @@#include <linux/iio/triggered_buffer.h> #include <linux/pm_runtime.h> -#define ATLAS_REGMAP_NAME "atlas_regmap"#define ATLAS_DRV_NAME "atlas"#define ATLAS_REG_DEV_TYPE 0x00
@@ -96,7 +95,7 @@ struct atlas_data { };static const struct regmap_config atlas_regmap_config = { - .name =ATLAS_REGMAP_NAME , + .name ="atlas_regmap" , .reg_bits =8 , .val_bits =8 , };
drivers/iio/health/max30100.c +1 -2
@@ -22,7 +22,6 @@#include <linux/iio/buffer.h> #include <linux/iio/kfifo_buf.h> -#define MAX30100_REGMAP_NAME "max30100_regmap"#define MAX30100_DRV_NAME "max30100"#define MAX30100_REG_INT_STATUS 0x00
@@ -94,7 +93,7 @@ static bool max30100_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config max30100_regmap_config = { - .name =MAX30100_REGMAP_NAME , + .name ="max30100_regmap" , .reg_bits =8 , .val_bits =8 ,
drivers/iio/health/max30102.c +1 -2
@@ -25,7 +25,6 @@#include <linux/iio/buffer.h> #include <linux/iio/kfifo_buf.h> -#define MAX30102_REGMAP_NAME "max30102_regmap"#define MAX30102_DRV_NAME "max30102"#define MAX30102_PART_NUMBER 0x15
@@ -112,7 +111,7 @@ struct max30102_data { };static const struct regmap_config max30102_regmap_config = { - .name =MAX30102_REGMAP_NAME , + .name ="max30102_regmap" , .reg_bits =8 , .val_bits =8 ,
drivers/iio/light/adux1020.c +1 -2
@@ -23,7 +23,6 @@#include <linux/iio/sysfs.h> #include <linux/iio/events.h> -#define ADUX1020_REGMAP_NAME "adux1020_regmap"#define ADUX1020_DRV_NAME "adux1020"/* System registers */
@@ -114,7 +113,7 @@ static const struct adux1020_mode_data adux1020_modes[] = { };static const struct regmap_config adux1020_regmap_config = { - .name =ADUX1020_REGMAP_NAME , + .name ="adux1020_regmap" , .reg_bits =8 , .val_bits =16 , .max_register =0x6F ,
drivers/iio/light/apds9160.c +1 -3
@@ -25,8 +25,6 @@#include <linux/unaligned.h> -#define APDS9160_REGMAP_NAME "apds9160_regmap" -/* Main control register */ #define APDS9160_REG_CTRL 0x00#define APDS9160_CTRL_SWRESET BIT(4)/* 1: Activate reset */
@@ -161,7 +159,7 @@ static const struct regmap_access_table apds9160_volatile_table = { };static const struct regmap_config apds9160_regmap_config = { - .name =APDS9160_REGMAP_NAME , + .name ="apds9160_regmap" , .reg_bits =8 , .val_bits =8 , .use_single_read = true,
drivers/iio/light/apds9960.c +1 -2
@@ -25,7 +25,6 @@#include <linux/iio/kfifo_buf.h> #include <linux/iio/sysfs.h> -#define APDS9960_REGMAP_NAME "apds9960_regmap"#define APDS9960_DRV_NAME "apds9960"#define APDS9960_REG_RAM_START 0x00
@@ -221,7 +220,7 @@ static const struct regmap_access_table apds9960_writeable_table = { };static const struct regmap_config apds9960_regmap_config = { - .name =APDS9960_REGMAP_NAME , + .name ="apds9960_regmap" , .reg_bits =8 , .val_bits =8 , .use_single_read = true,
drivers/iio/light/jsa1212.c +1 -2
@@ -106,7 +106,6 @@#define JSA1212_PXS_DELAY_MS 100#define JSA1212_DRIVER_NAME "jsa1212" -#define JSA1212_REGMAP_NAME "jsa1212_regmap"enum jsa1212_op_mode {JSA1212_OPMODE_ALS_EN ,
@@ -300,7 +299,7 @@ static bool jsa1212_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config jsa1212_regmap_config = { - .name =JSA1212_REGMAP_NAME , + .name ="jsa1212_regmap" , .reg_bits =8 , .val_bits =8 , .max_register =JSA1212_MAX_REG ,
drivers/iio/light/ltr501.c +1 -3
@@ -63,8 +63,6 @@#define LTR501_ALS_DEF_PERIOD 500000#define LTR501_PS_DEF_PERIOD 100000 -#define LTR501_REGMAP_NAME "ltr501_regmap" -#define LTR501_LUX_CONV (vis_coeff, vis_data, ir_coeff, ir_data) \ ((vis_coeff * vis_data) - (ir_coeff * ir_data))
@@ -1400,7 +1398,7 @@ static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config ltr501_regmap_config = { - .name =LTR501_REGMAP_NAME , + .name ="ltr501_regmap" , .reg_bits =8 , .val_bits =8 , .max_register =LTR501_MAX_REG ,
drivers/iio/light/rpr0521.c +1 -2
@@ -68,7 +68,6 @@#define RPR0521_DEFAULT_MEAS_TIME 0x06/* ALS - 100ms, PXS - 100ms */ #define RPR0521_DRV_NAME "RPR0521" -#define RPR0521_REGMAP_NAME "rpr0521_regmap"#define RPR0521_SLEEP_DELAY_MS 2000
@@ -904,7 +903,7 @@ static bool rpr0521_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config rpr0521_regmap_config = { - .name =RPR0521_REGMAP_NAME , + .name ="rpr0521_regmap" , .reg_bits =8 , .val_bits =8 ,
drivers/iio/light/stk3310.c +1 -2
@@ -46,7 +46,6 @@#define STK3310_PS_MAX_VAL 0xFFFF#define STK3310_DRIVER_NAME "stk3310" -#define STK3310_REGMAP_NAME "stk3310_regmap"#define STK3310_SCALE_AVAILABLE "6.4 1.6 0.4 0.1"
@@ -526,7 +525,7 @@ static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config stk3310_regmap_config = { - .name =STK3310_REGMAP_NAME , + .name ="stk3310_regmap" , .reg_bits =8 , .val_bits =8 , .max_register =STK3310_MAX_REG ,
drivers/iio/light/vcnl4035.c +1 -2
@@ -23,7 +23,6 @@#include <linux/iio/triggered_buffer.h> #define VCNL4035_DRV_NAME "vcnl4035" -#define VCNL4035_REGMAP_NAME "vcnl4035_regmap"/* Device registers */ #define VCNL4035_ALS_CONF 0x00
@@ -492,7 +491,7 @@ static bool vcnl4035_is_volatile_reg(struct device *dev, unsigned int reg) }static const struct regmap_config vcnl4035_regmap_config = { - .name =VCNL4035_REGMAP_NAME , + .name ="vcnl4035_regmap" , .reg_bits =8 , .val_bits =16 , .max_register =VCNL4035_DEV_ID ,
drivers/iio/magnetometer/mmc35240.c +1 -2
@@ -21,7 +21,6 @@#include <linux/iio/sysfs.h> #define MMC35240_DRV_NAME "mmc35240" -#define MMC35240_REGMAP_NAME "mmc35240_regmap"#define MMC35240_REG_XOUT_L 0x00#define MMC35240_REG_XOUT_H 0x01
@@ -463,7 +462,7 @@ static const struct reg_default mmc35240_reg_defaults[] = { };static const struct regmap_config mmc35240_regmap_config = { - .name =MMC35240_REGMAP_NAME , + .name ="mmc35240_regmap" , .reg_bits =8 , .val_bits =8 ,
Signature · 1 line
2.39.5
PATCH 4/4 iio: Remove unused macro definition for driver and IRQ name
In reply to Waqar HameedThese macro definitions are completely unused. Remove them.
--- drivers/iio/accel/bma180.c | 3 --- drivers/iio/accel/bmc150-accel-core.c | 2 -- drivers/iio/magnetometer/bmc150_magn.c | 2 -- 3 files changed, 7 deletions(-)
drivers/iio/accel/bma180.c +0 -3
@@ -29,9 +29,6 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#define BMA180_DRV_NAME "bma180" -#define BMA180_IRQ_NAME "bma180_event" -enum chip_ids {BMA023 ,BMA150 ,
drivers/iio/accel/bmc150-accel-core.c +0 -2
@@ -25,8 +25,6 @@#include "bmc150-accel.h" -#define BMC150_ACCEL_DRV_NAME "bmc150_accel" -#define BMC150_ACCEL_REG_CHIP_ID 0x00#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B
drivers/iio/magnetometer/bmc150_magn.c +0 -2
@@ -28,8 +28,6 @@#include "bmc150_magn.h" -#define BMC150_MAGN_DRV_NAME "bmc150_magn" -#define BMC150_MAGN_REG_CHIP_ID 0x40#define BMC150_MAGN_CHIP_ID_VAL 0x32
Signature · 1 line
2.39.5
Jonathan Cameron
maintainerQuoted 30 lines · On Tue, 27 May 2025 16:45:41 +0200 Waqar Hameed <[email protected]> wrote:
Currently there are a bunch of drivers using macro definitions for string literals that are only used once. There seem to be a "style guide" to not do this, and this is often mentioned during the reviews (if caught). And since developers most often look at other drivers for inspiration (or just trying to figure out the "style guide") when writing a new one, it is desirable to have some consistency.
In this patch series we identify the drivers that have macro definitions for string literals that are only used once. The most common one is the driver name. These can be identified by
rgrep -A 10 "\.driver"
drivers/iio/| grep "\.name" | grep -v '"'And then count the number of occurrences of the particular macro definition (e.g. with
grep -c). Most drivers use these macro definitions for.nameinstruct device_driverandindio_dev->name(which could be justified with a macro definition). However, the ones with only one occurrence are identified and removed in this patch series.There are also drivers that have a mixture, e.g. macro definition for
indio_dev->namebut in-line string literal for.nameinstruct device_driver). The following have therefore not been touched (but should maybe use the macro definition for both places):
drivers/iio/accel/stk8ba50.c
drivers/iio/accel/mma7660.c
drivers/iio/humidity/am2315.c
drivers/iio/light/stk3310.c
Quoted 7 lines
Likewise, there are drivers that only use
KBUILD_MODNAMEin one place. These have also been left for the same reasons.Finally, while cleaning up these ones, other similar macro definitions could be identified with the same "style guide" issue: macro definitions for IRQ name and
regmapname. There are even unused macro definitions. All of these are also addressed in this patch series.
Thanks for tidying all these up!
Applied to the testing branch of iio.git which will be rebased on rc1 once available.
Jonathan
Quoted 45 lines
Waqar Hameed (4):
iio: Remove single use of macro definition for driver name
iio: Remove single use of macro definition for IRQ name
iio: Remove single use of macro definition for regmap name
iio: Remove unused macro definition for driver and IRQ namedrivers/iio/accel/bma180.c | 3 --- drivers/iio/accel/bmc150-accel-core.c | 5 +---- drivers/iio/accel/kxcjk-1013.c | 7 ++----- drivers/iio/accel/mma9551.c | 6 ++---- drivers/iio/accel/mma9553.c | 7 ++----- drivers/iio/accel/mxc4005.c | 6 ++---- drivers/iio/accel/mxc6255.c | 3 +-- drivers/iio/accel/sca3300.c | 4 +--- drivers/iio/accel/stk8312.c | 3 +-- drivers/iio/accel/stk8ba50.c | 3 +-- drivers/iio/adc/hi8435.c | 4 +--- drivers/iio/adc/max9611.c | 4 +--- drivers/iio/adc/vf610_adc.c | 5 +---- drivers/iio/chemical/atlas-sensor.c | 3 +-- drivers/iio/dac/max517.c | 4 +--- drivers/iio/dac/mcp4725.c | 4 +--- drivers/iio/gyro/bmg160_core.c | 4 +--- drivers/iio/health/max30100.c | 3 +-- drivers/iio/health/max30102.c | 3 +-- drivers/iio/humidity/dht11.c | 4 +--- drivers/iio/imu/kmx61.c | 7 ++----- drivers/iio/light/adux1020.c | 3 +-- drivers/iio/light/apds9160.c | 4 +--- drivers/iio/light/apds9300.c | 3 +-- drivers/iio/light/apds9960.c | 3 +-- drivers/iio/light/jsa1212.c | 3 +-- drivers/iio/light/ltr501.c | 8 ++------ drivers/iio/light/rpr0521.c | 6 ++---- drivers/iio/light/stk3310.c | 6 ++---- drivers/iio/light/vcnl4035.c | 6 ++---- drivers/iio/magnetometer/bmc150_magn.c | 5 +---- drivers/iio/magnetometer/mmc35240.c | 3 +-- drivers/iio/proximity/sx9500.c | 3 +-- drivers/iio/resolver/ad2s1200.c | 3 +-- 34 files changed, 42 insertions(+), 106 deletions(-)base-commit:
914873bc7df913db988284876c16257e6ab772c6