[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250531161225.5c9658e9@jic23-huawei>
Date: Sat, 31 May 2025 16:12:25 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Waqar Hameed <waqar.hameed@...s.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, Michael Hennerich
<Michael.Hennerich@...log.com>, Haibo Chen <haibo.chen@....com>,
<kernel@...s.com>, <linux-iio@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 0/4] iio: Clean up macro definitions
On Tue, 27 May 2025 16:45:41 +0200
Waqar Hameed <waqar.hameed@...s.com> 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 `.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.
Thanks for tidying all these up!
Applied to the testing branch of iio.git which will be rebased on rc1
once available.
Jonathan
>
> 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
Powered by blists - more mailing lists