All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Ferry Toth <ftoth@exalondelft.nl>
Subject: [PATCH v1 04/11] iio: light: tsl2563: Make use of the macros from bits.h
Date: Wed,  7 Dec 2022 21:03:41 +0200	[thread overview]
Message-ID: <20221207190348.9347-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20221207190348.9347-1-andriy.shevchenko@linux.intel.com>

Make use of BIT() and GENMASK() where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Ferry Toth <ftoth@exalondelft.nl>
---
 drivers/iio/light/tsl2563.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index d071805239ef..3b60d8000351 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -11,6 +11,7 @@
  * Amit Kucheria <amit.kucheria@verdurent.com>
  */
 
+#include <linux/bits.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/property.h>
@@ -33,19 +34,19 @@
 #define ADC_FRAC_BITS		14
 
 /* Given number of 1/10000's in ADC_FRAC_BITS precision. */
-#define FRAC10K(f)		(((f) * (1L << (ADC_FRAC_BITS))) / (10000))
+#define FRAC10K(f)		(((f) * BIT(ADC_FRAC_BITS)) / (10000))
 
 /* Bits used for fraction in calibration coefficients.*/
 #define CALIB_FRAC_BITS		10
 /* 0.5 in CALIB_FRAC_BITS precision */
-#define CALIB_FRAC_HALF		(1 << (CALIB_FRAC_BITS - 1))
+#define CALIB_FRAC_HALF		BIT(CALIB_FRAC_BITS - 1)
 /* Make a fraction from a number n that was multiplied with b. */
 #define CALIB_FRAC(n, b)	(((n) << CALIB_FRAC_BITS) / (b))
 /* Decimal 10^(digits in sysfs presentation) */
 #define CALIB_BASE_SYSFS	1000
 
-#define TSL2563_CMD		0x80
-#define TSL2563_CLEARINT	0x40
+#define TSL2563_CMD		BIT(7)
+#define TSL2563_CLEARINT	BIT(6)
 
 #define TSL2563_REG_CTRL	0x00
 #define TSL2563_REG_TIMING	0x01
@@ -58,19 +59,19 @@
 
 #define TSL2563_CMD_POWER_ON	0x03
 #define TSL2563_CMD_POWER_OFF	0x00
-#define TSL2563_CTRL_POWER_MASK	0x03
+#define TSL2563_CTRL_POWER_MASK	GENMASK(1, 0)
 
 #define TSL2563_TIMING_13MS	0x00
 #define TSL2563_TIMING_100MS	0x01
 #define TSL2563_TIMING_400MS	0x02
-#define TSL2563_TIMING_MASK	0x03
+#define TSL2563_TIMING_MASK	GENMASK(1, 0)
 #define TSL2563_TIMING_GAIN16	0x10
 #define TSL2563_TIMING_GAIN1	0x00
 
 #define TSL2563_INT_DISABLED	0x00
 #define TSL2563_INT_LEVEL	0x10
-#define TSL2563_INT_MASK	0x30
-#define TSL2563_INT_PERSIST(n)	((n) & 0x0F)
+#define TSL2563_INT_MASK	GENMASK(5, 4)
+#define TSL2563_INT_PERSIST(n)	((n) & GENMASK(3, 0))
 
 struct tsl2563_gainlevel_coeff {
 	u8 gaintime;
-- 
2.35.1


  parent reply	other threads:[~2022-12-07 19:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 19:03 [PATCH v1 01/11] iio: light: tsl2563: Do not hardcode interrupt trigger type Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 02/11] iio: light: tsl2563: Use i2c_smbus_write_word_data() in tsl2563_configure() Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 03/11] iio: light: tsl2563: Configure INT in one place Andy Shevchenko
2022-12-11 13:17   ` Jonathan Cameron
2022-12-07 19:03 ` Andy Shevchenko [this message]
2022-12-11 13:19   ` [PATCH v1 04/11] iio: light: tsl2563: Make use of the macros from bits.h Jonathan Cameron
2022-12-07 19:03 ` [PATCH v1 05/11] iio: light: tsl2563: Drop unused defintion(s) Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 06/11] iio: light: tsl2563: Simplify with dev_err_probe Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 07/11] iio: light: tsl2563: Drop legacy platform data code Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 08/11] iio: light: tsl2563: Utilise temporary variable for struct device Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 09/11] iio: light: tsl2563: Use dev_get_drvdata() directly in PM callbacks Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 10/11] iio: light: tsl2563: sort header inclusion alphabetically Andy Shevchenko
2022-12-07 19:03 ` [PATCH v1 11/11] iio: light: tsl2563: Keep Makefile sorted by module name Andy Shevchenko
2022-12-11 13:26 ` [PATCH v1 01/11] iio: light: tsl2563: Do not hardcode interrupt trigger type Jonathan Cameron
2022-12-11 17:14   ` Ferry Toth
2022-12-12 10:59     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221207190348.9347-4-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=ftoth@exalondelft.nl \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.