Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 0/4] iio: Clean up macro definitions
@ 2025-05-27 14:45 Waqar Hameed
  2025-05-27 14:45 ` [PATCH 1/4] iio: Remove single use of macro definition for driver name Waqar Hameed
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Waqar Hameed @ 2025-05-27 14:45 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich,
	Haibo Chen
  Cc: kernel, linux-iio, linux-kernel

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
-- 
2.39.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-31 15:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 14:45 [PATCH 0/4] iio: Clean up macro definitions Waqar Hameed
2025-05-27 14:45 ` [PATCH 1/4] iio: Remove single use of macro definition for driver name Waqar Hameed
2025-05-27 14:45 ` [PATCH 2/4] iio: Remove single use of macro definition for IRQ name Waqar Hameed
2025-05-27 14:45 ` [PATCH 4/4] iio: Remove unused macro definition for driver and " Waqar Hameed
2025-05-27 14:45 ` [PATCH 3/4] iio: Remove single use of macro definition for regmap name Waqar Hameed
2025-05-31 15:12 ` [PATCH 0/4] iio: Clean up macro definitions Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox