U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Bruce Suen <bruce_suen@163.com>,
	u-boot@lists.denx.de
Subject: [PATCH 08/14] regmap: Add regmap_set/clear_bits shorthands
Date: Wed,  2 Apr 2025 00:51:40 +0200	[thread overview]
Message-ID: <20250401225156.25790-9-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20250401225156.25790-1-ansuelsmth@gmail.com>

Port Linux kernel regmap_set/clear_bits shorthands to set and clear bits
in a regmap. These are handy if only specific bits needs to be applied
or cleared and makes it easier to port regmap based driver from kernel
upstream.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 include/regmap.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/regmap.h b/include/regmap.h
index 22b043408ac..8c6f7c1c9b1 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -361,6 +361,34 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
  */
 int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val);
 
+/**
+ * regmap_set_bits() - Set bits to a regmap
+ *
+ * @map:	Regmap to write bits to
+ * @offset:	Offset in the regmap to write to
+ * @bits:	Bits to set to the regmap at the specified offset
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int regmap_set_bits(struct regmap *map, uint offset, uint bits)
+{
+	return regmap_update_bits(map, offset, bits, bits);
+}
+
+/**
+ * regmap_clear_bits() - Clear bits to a regmap
+ *
+ * @map:	Regmap to write bits to
+ * @offset:	Offset in the regmap to write to
+ * @bits:	Bits to clear to the regmap at the specified offset
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int regmap_clear_bits(struct regmap *map, uint offset, uint bits)
+{
+	return regmap_update_bits(map, offset, bits, 0);
+}
+
 /**
  * regmap_init_mem() - Set up a new register map that uses memory access
  *
-- 
2.48.1


  parent reply	other threads:[~2025-04-01 22:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 22:51 [PATCH 00/14] airoha: add support spi/mmc/ethernet Christian Marangi
2025-04-01 22:51 ` [PATCH 01/14] arch: arm: dts: an7581: add Chip SCU node Christian Marangi
2025-04-01 22:51 ` [PATCH 02/14] net: airoha: Add Airoha Ethernet driver Christian Marangi
2025-04-02 15:19   ` Tom Rini
2025-04-02 15:21     ` Christian Marangi
2025-04-02 15:31       ` Tom Rini
2025-04-02 15:33         ` Christian Marangi
2025-04-01 22:51 ` [PATCH 03/14] airoha: Add Ethernet config to defconfig Christian Marangi
2025-04-01 22:51 ` [PATCH 04/14] arch: arm: dts: an7581: Add Ethernet nodes Christian Marangi
2025-04-01 22:51 ` [PATCH 05/14] mmc: mediatek: permit to also build for Airoha arch Christian Marangi
2025-04-01 22:51 ` [PATCH 06/14] arch: arm: dts: an7581: Add eMMC nodes Christian Marangi
2025-04-01 22:51 ` [PATCH 07/14] airoha: Add eMMC config to defconfig Christian Marangi
2025-04-01 22:51 ` Christian Marangi [this message]
2025-04-01 22:51 ` [PATCH 09/14] spi: drop unneeded spi.h header include from spinand.h Christian Marangi
2025-04-01 22:51 ` [PATCH 10/14] spi: Introduce setup_for_spinand() Christian Marangi
2025-04-01 22:51 ` [PATCH 11/14] spinand: call SPI setup_for_spinand if supported Christian Marangi
2025-04-01 22:51 ` [PATCH 12/14] spi: airoha: Add Airoha SPI NAND driver Christian Marangi
2025-04-01 22:51 ` [PATCH 13/14] arm: dts: an7581: Add SNAND node Christian Marangi
2025-04-01 22:51 ` [PATCH 14/14] configs: airoha: an7581_evb: Enable Airoha SNFI SPI config Christian Marangi

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=20250401225156.25790-9-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=bruce_suen@163.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=jagan@amarulasolutions.com \
    --cc=jh80.chung@samsung.com \
    --cc=joe.hershberger@ni.com \
    --cc=michael@amarulasolutions.com \
    --cc=peng.fan@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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