[PATCH v9 06/11] iio: accel: adxl345: replace magic numbers by unit expressions

Lothar Rubusch posted 11 patches 6 months, 1 week ago
There is a newer version of this series
[PATCH v9 06/11] iio: accel: adxl345: replace magic numbers by unit expressions
Posted by Lothar Rubusch 6 months, 1 week ago
Replace absolute numbers by their expressions from units.h to avoid
using magic numbers. Use uniform expressions to clarify their usage.

This is a refactoring change and should not impact functionality.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
 drivers/iio/accel/adxl345_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index dcfbfe4cac0f..2c4f045c741c 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -706,15 +706,15 @@ static int adxl345_read_event_value(struct iio_dev *indio_dev,
 			return IIO_VAL_FRACTIONAL;
 		case IIO_EV_INFO_TIMEOUT:
 			*val = st->tap_duration_us;
-			*val2 = 1000000;
+			*val2 = MICRO;
 			return IIO_VAL_FRACTIONAL;
 		case IIO_EV_INFO_RESET_TIMEOUT:
 			*val = st->tap_window_us;
-			*val2 = 1000000;
+			*val2 = MICRO;
 			return IIO_VAL_FRACTIONAL;
 		case IIO_EV_INFO_TAP2_MIN_DELAY:
 			*val = st->tap_latent_us;
-			*val2 = 1000000;
+			*val2 = MICRO;
 			return IIO_VAL_FRACTIONAL;
 		default:
 			return -EINVAL;
-- 
2.39.5
Re: [PATCH v9 06/11] iio: accel: adxl345: replace magic numbers by unit expressions
Posted by Jonathan Cameron 6 months ago
On Tue, 10 Jun 2025 21:59:28 +0000
Lothar Rubusch <l.rubusch@gmail.com> wrote:

> Replace absolute numbers by their expressions from units.h to avoid
> using magic numbers. Use uniform expressions to clarify their usage.
> 
> This is a refactoring change and should not impact functionality.
> 
> Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Nice. Applied with a little fuzz due to the earlier patches that I haven't
picked up yet.

Thanks,

J
> ---
>  drivers/iio/accel/adxl345_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
> index dcfbfe4cac0f..2c4f045c741c 100644
> --- a/drivers/iio/accel/adxl345_core.c
> +++ b/drivers/iio/accel/adxl345_core.c
> @@ -706,15 +706,15 @@ static int adxl345_read_event_value(struct iio_dev *indio_dev,
>  			return IIO_VAL_FRACTIONAL;
>  		case IIO_EV_INFO_TIMEOUT:
>  			*val = st->tap_duration_us;
> -			*val2 = 1000000;
> +			*val2 = MICRO;
>  			return IIO_VAL_FRACTIONAL;
>  		case IIO_EV_INFO_RESET_TIMEOUT:
>  			*val = st->tap_window_us;
> -			*val2 = 1000000;
> +			*val2 = MICRO;
>  			return IIO_VAL_FRACTIONAL;
>  		case IIO_EV_INFO_TAP2_MIN_DELAY:
>  			*val = st->tap_latent_us;
> -			*val2 = 1000000;
> +			*val2 = MICRO;
>  			return IIO_VAL_FRACTIONAL;
>  		default:
>  			return -EINVAL;