mfd: mc13xxx: Use bitfield helpers

Use the FIELD_GET() helper, instead of defining a custom macro
implementing the same operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/ef7d5fc3d867338520392417cdf2b67ba19aecde.1708002264.git.geert+renesas@glider.be
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Geert Uytterhoeven 2024-02-15 14:07:13 +01:00 committed by Lee Jones
parent a2caf6036c
commit 3e038941c5

View File

@ -7,6 +7,7 @@
* Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
*/ */
#include <linux/bitfield.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.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); EXPORT_SYMBOL(mc13xxx_irq_free);
#define maskval(reg, mask) (((reg) & (mask)) >> __ffs(mask))
static void mc13xxx_print_revision(struct mc13xxx *mc13xxx, u32 revision) static void mc13xxx_print_revision(struct mc13xxx *mc13xxx, u32 revision)
{ {
dev_info(mc13xxx->dev, "%s: rev: %d.%d, " dev_info(mc13xxx->dev, "%s: rev: %d.%d, "
"fin: %d, fab: %d, icid: %d/%d\n", "fin: %d, fab: %d, icid: %d/%d\n",
mc13xxx->variant->name, mc13xxx->variant->name,
maskval(revision, MC13XXX_REVISION_REVFULL), FIELD_GET(MC13XXX_REVISION_REVFULL, revision),
maskval(revision, MC13XXX_REVISION_REVMETAL), FIELD_GET(MC13XXX_REVISION_REVMETAL, revision),
maskval(revision, MC13XXX_REVISION_FIN), FIELD_GET(MC13XXX_REVISION_FIN, revision),
maskval(revision, MC13XXX_REVISION_FAB), FIELD_GET(MC13XXX_REVISION_FAB, revision),
maskval(revision, MC13XXX_REVISION_ICID), FIELD_GET(MC13XXX_REVISION_ICID, revision),
maskval(revision, MC13XXX_REVISION_ICIDCODE)); FIELD_GET(MC13XXX_REVISION_ICIDCODE, revision));
} }
static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision) static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
{ {
dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n", dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n",
mc13xxx->variant->name, mc13xxx->variant->name,
maskval(revision, MC34708_REVISION_REVFULL), FIELD_GET(MC34708_REVISION_REVFULL, revision),
maskval(revision, MC34708_REVISION_REVMETAL), FIELD_GET(MC34708_REVISION_REVMETAL, revision),
maskval(revision, MC34708_REVISION_FIN), FIELD_GET(MC34708_REVISION_FIN, revision),
maskval(revision, MC34708_REVISION_FAB)); FIELD_GET(MC34708_REVISION_FAB, revision));
} }
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */ /* These are only exported for mc13xxx-i2c and mc13xxx-spi */