iio: light: si1133: prefer complex macros enclosed in parenthesis
PATCH 1/1 iio: light: si1133: prefer complex macros enclosed in parenthesis
Enclose complex macros in parenthesis per checkpatch.pl error to improve code style.
Signed-off-by Joshua Crofts <[email protected]>
--- drivers/iio/light/si1133.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/iio/light/si1133.c +9 -9
@@ -50,23 +50,23 @@#define SI1133_MAX_CMD_CTR 0xF#define SI1133_PARAM_REG_CHAN_LIST 0x01 -#define SI1133_PARAM_REG_ADCCONFIG (x) ((x) * 4) + 2 -#define SI1133_PARAM_REG_ADCSENS (x) ((x) * 4) + 3 -#define SI1133_PARAM_REG_ADCPOST (x) ((x) * 4) + 4 +#define SI1133_PARAM_REG_ADCCONFIG (x) (((x) * 4) + 2) +#define SI1133_PARAM_REG_ADCSENS (x) (((x) * 4) + 3) +#define SI1133_PARAM_REG_ADCPOST (x) (((x) * 4) + 4)#define SI1133_ADCMUX_MASK 0x1F -#define SI1133_ADCCONFIG_DECIM_RATE (x) (x) << 5 +#define SI1133_ADCCONFIG_DECIM_RATE (x) ((x) << 5)#define SI1133_ADCSENS_SCALE_MASK 0x70#define SI1133_ADCSENS_SCALE_SHIFT 4#define SI1133_ADCSENS_HSIG_MASK BIT(7)#define SI1133_ADCSENS_HSIG_SHIFT 7#define SI1133_ADCSENS_HW_GAIN_MASK 0xF -#define SI1133_ADCSENS_NB_MEAS (x) fls(x) << SI1133_ADCSENS_SCALE_SHIFT +#define SI1133_ADCSENS_NB_MEAS (x) (fls(x) << SI1133_ADCSENS_SCALE_SHIFT)#define SI1133_ADCPOST_24BIT_EN BIT(6) -#define SI1133_ADCPOST_POSTSHIFT_BITQTY (x) (x & GENMASK(2, 0)) << 3 +#define SI1133_ADCPOST_POSTSHIFT_BITQTY (x) (((x) & GENMASK(2, 0)) << 3)#define SI1133_PARAM_ADCMUX_SMALL_IR 0x0#define SI1133_PARAM_ADCMUX_MED_IR 0x1
@@ -87,15 +87,15 @@#define SI1133_CMD_MINSLEEP_US_HIGH 7500#define SI1133_CMD_TIMEOUT_MS 25#define SI1133_CMD_LUX_TIMEOUT_MS 5000 -#define SI1133_CMD_TIMEOUT_US SI1133_CMD_TIMEOUT_MS * 1000 +#define SI1133_CMD_TIMEOUT_US (SI1133_CMD_TIMEOUT_MS * 1000) -#define SI1133_REG_HOSTOUT (x) (x) + 0x13 +#define SI1133_REG_HOSTOUT (x) ((x) + 0x13)#define SI1133_MEASUREMENT_FREQUENCY 1250#define SI1133_X_ORDER_MASK 0x0070#define SI1133_Y_ORDER_MASK 0x0007 -#define si1133_get_x_order (m) ((m) & SI1133_X_ORDER_MASK) >> 4 +#define si1133_get_x_order (m) (((m) & SI1133_X_ORDER_MASK) >> 4)#define si1133_get_y_order (m) ((m) & SI1133_Y_ORDER_MASK)#define SI1133_LUX_ADC_MASK 0xE
---
base-commit: d86db1905add39f905cf9f04252804b359914ed6
change-id: 20260427-si1133-checkup-abcc5280adf3
Best regards,
Signature · 1 line
Joshua Crofts <[email protected]>
Quoted 2 lines · On Mon, Apr 27, 2026 at 04:08:37PM +0200, Joshua Crofts via B4 Relay wrote:
Enclose complex macros in parenthesis per checkpatch.pl error to improve code style.
...
drivers/iio/light/si1133.c line 66
Quoted 2 lines
drivers/iio/light/si1133.c +1
-1-#define SI1133_ADCSENS_NB_MEAS (x) fls(x) << SI1133_ADCSENS_SCALE_SHIFT +#define SI1133_ADCSENS_NB_MEAS (x) (fls(x) << SI1133_ADCSENS_SCALE_SHIFT)
Wow, this is used with bitwise OR, which probably works fine due to operator precedence.
...
drivers/iio/light/si1133.c line 90
Quoted 2 lines
drivers/iio/light/si1133.c +1
-1-#define SI1133_CMD_TIMEOUT_US SI1133_CMD_TIMEOUT_MS * 1000 +#define SI1133_CMD_TIMEOUT_US (SI1133_CMD_TIMEOUT_MS * 1000)
Is it used at all?
I would drop unused macros (that are Linux only, not directly related to HW) in a separate patch.
Signature · 2 lines
With Best Regards, Andy Shevchenko