From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Lee Jones <lee.jones@linaro.org>
Cc: linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH] mfd: mc13xxx: Use bitfield helpers
Date: Mon, 22 Nov 2021 16:54:07 +0100 [thread overview]
Message-ID: <afa46868cf8c1666e9cbbbec42767ca2294b024d.1637593297.git.geert+renesas@glider.be> (raw)
In-Reply-To: <a1445d3abb45cfc95cb1b03180fd53caf122035b.1637593297.git.geert+renesas@glider.be>
Use the FIELD_GET() helper, instead of defining a custom macro
implementing the same operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
See "[PATCH 00/17] Non-const bitfield helper conversions"
(https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
for background and more conversions.
---
drivers/mfd/mc13xxx-core.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 8a4f1d90dcfd1c33..a9b7cf23c9079882 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -7,6 +7,7 @@
* Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
*/
+#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -174,28 +175,27 @@ int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev)
}
EXPORT_SYMBOL(mc13xxx_irq_free);
-#define maskval(reg, mask) (((reg) & (mask)) >> __ffs(mask))
static void mc13xxx_print_revision(struct mc13xxx *mc13xxx, u32 revision)
{
dev_info(mc13xxx->dev, "%s: rev: %d.%d, "
"fin: %d, fab: %d, icid: %d/%d\n",
mc13xxx->variant->name,
- maskval(revision, MC13XXX_REVISION_REVFULL),
- maskval(revision, MC13XXX_REVISION_REVMETAL),
- maskval(revision, MC13XXX_REVISION_FIN),
- maskval(revision, MC13XXX_REVISION_FAB),
- maskval(revision, MC13XXX_REVISION_ICID),
- maskval(revision, MC13XXX_REVISION_ICIDCODE));
+ FIELD_GET(MC13XXX_REVISION_REVFULL, revision),
+ FIELD_GET(MC13XXX_REVISION_REVMETAL, revision),
+ FIELD_GET(MC13XXX_REVISION_FIN, revision),
+ FIELD_GET(MC13XXX_REVISION_FAB, revision),
+ FIELD_GET(MC13XXX_REVISION_ICID, revision),
+ FIELD_GET(MC13XXX_REVISION_ICIDCODE, revision));
}
static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
{
dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n",
mc13xxx->variant->name,
- maskval(revision, MC34708_REVISION_REVFULL),
- maskval(revision, MC34708_REVISION_REVMETAL),
- maskval(revision, MC34708_REVISION_FIN),
- maskval(revision, MC34708_REVISION_FAB));
+ FIELD_GET(MC34708_REVISION_REVFULL, revision),
+ FIELD_GET(MC34708_REVISION_REVMETAL, revision),
+ FIELD_GET(MC34708_REVISION_FIN, revision),
+ FIELD_GET(MC34708_REVISION_FAB, revision));
}
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */
--
2.25.1
next prev parent reply other threads:[~2021-11-22 15:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 15:53 [PATCH] ARM: ptrace: Use bitfield helpers Geert Uytterhoeven
2021-11-22 15:53 ` [PATCH] MIPS: CPC: " Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:54 ` [PATCH] crypto: sa2ul - " Geert Uytterhoeven
2021-12-03 5:07 ` Herbert Xu
2021-11-22 15:54 ` [PATCH] dmaengine: stm32-mdma: " Geert Uytterhoeven
2021-11-26 11:02 ` [Linux-stm32] " Amelie DELAUNAY
2021-12-13 9:05 ` Vinod Koul
2021-11-22 15:54 ` [PATCH] intel_th: " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] Input: palmas-pwrbutton - use " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] irqchip/mips-gic: Use " Geert Uytterhoeven
2021-11-22 15:54 ` Geert Uytterhoeven [this message]
2021-11-22 15:54 ` [PATCH] regulator: lp873x: " Geert Uytterhoeven
2021-11-22 16:32 ` Mark Brown
2021-11-22 15:54 ` [PATCH] regulator: lp87565: " Geert Uytterhoeven
2021-11-22 16:33 ` Mark Brown
2021-11-22 16:17 ` [PATCH] ARM: ptrace: " Russell King (Oracle)
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=afa46868cf8c1666e9cbbbec42767ca2294b024d.1637593297.git.geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=lee.jones@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).