From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thorsten Scherer <t.scherer@eckelmann.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] siox: Provide a devm variant of siox_master_register()
Date: Mon, 19 Feb 2024 08:46:31 +0100 [thread overview]
Message-ID: <e961dfb3e94f106b16f5eacff2110fc7fa0cab13.1708328466.git.u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <cover.1708328466.git.u.kleine-koenig@pengutronix.de>
This allows to simplify siox master drivers in the next step.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/siox/siox-core.c | 19 +++++++++++++++++++
drivers/siox/siox.h | 2 ++
2 files changed, 21 insertions(+)
diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index 9dd0bda03db3..8d7cb9e24efb 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -794,6 +794,25 @@ void siox_master_unregister(struct siox_master *smaster)
}
EXPORT_SYMBOL_GPL(siox_master_unregister);
+static void devm_siox_master_unregister(void *data)
+{
+ struct siox_master *smaster = data;
+
+ siox_master_unregister(smaster);
+}
+
+int devm_siox_master_register(struct device *dev, struct siox_master *smaster)
+{
+ int ret;
+
+ ret = siox_master_register(smaster);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, devm_siox_master_unregister, smaster);
+}
+EXPORT_SYMBOL_GPL(devm_siox_master_register);
+
static struct siox_device *siox_device_add(struct siox_master *smaster,
const char *type, size_t inbytes,
size_t outbytes, u8 statustype)
diff --git a/drivers/siox/siox.h b/drivers/siox/siox.h
index b227e18b697a..513f2c8312f7 100644
--- a/drivers/siox/siox.h
+++ b/drivers/siox/siox.h
@@ -49,3 +49,5 @@ struct siox_master *devm_siox_master_alloc(struct device *dev, size_t size);
int siox_master_register(struct siox_master *smaster);
void siox_master_unregister(struct siox_master *smaster);
+
+int devm_siox_master_register(struct device *dev, struct siox_master *smaster);
--
2.43.0
next prev parent reply other threads:[~2024-02-19 7:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 7:46 [PATCH 0/4] siox: Move some complexity into the core Uwe Kleine-König
2024-02-19 7:46 ` [PATCH 1/4] siox: Don't pass the reference on a master in siox_master_register() Uwe Kleine-König
2024-02-19 7:46 ` [PATCH 2/4] siox: Provide a devm variant of siox_master_alloc() Uwe Kleine-König
2024-03-07 7:13 ` Uwe Kleine-König
2024-03-07 7:29 ` Greg Kroah-Hartman
2024-03-07 8:38 ` Uwe Kleine-König
2024-03-08 21:20 ` [PULL] siox changes for 6.9 Uwe Kleine-König
2024-03-16 7:37 ` Uwe Kleine-König
2024-03-22 7:22 ` Uwe Kleine-König
2024-03-22 7:31 ` Greg Kroah-Hartman
2024-03-23 9:21 ` Uwe Kleine-König
2024-02-19 7:46 ` Uwe Kleine-König [this message]
2024-02-19 7:46 ` [PATCH 4/4] siox: bus-gpio: Simplify using devm_siox_* functions Uwe Kleine-König
2024-02-27 10:21 ` [PATCH 0/4] siox: Move some complexity into the core Thorsten Scherer
2024-03-06 18:24 ` siox patches for next development cycle [Re: [PATCH 0/4] siox: Move some complexity into the core] Uwe Kleine-König
2024-03-06 21:34 ` Stephen Rothwell
2024-03-06 22:46 ` Greg Kroah-Hartman
2024-03-07 7:08 ` Uwe Kleine-König
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=e961dfb3e94f106b16f5eacff2110fc7fa0cab13.1708328466.git.u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=t.scherer@eckelmann.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;
as well as URLs for NNTP newsgroup(s).