From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thorsten Scherer <t.scherer@eckelmann.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] siox: Use bus_type functions for probe, remote and shutdown
Date: Thu, 19 Nov 2020 14:23:10 +0100 [thread overview]
Message-ID: <20201119132311.2604232-1-u.kleine-koenig@pengutronix.de> (raw)
The eventual goal is to get rid of the callbacks in struct
device_driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/siox/siox-core.c | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index f8c08fb9891d..7b3a2b63304b 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -512,41 +512,49 @@ static int siox_match(struct device *dev, struct device_driver *drv)
return 1;
}
-static struct bus_type siox_bus_type = {
- .name = "siox",
- .match = siox_match,
-};
-
-static int siox_driver_probe(struct device *dev)
+static int siox_probe(struct device *dev)
{
struct siox_driver *sdriver = to_siox_driver(dev->driver);
struct siox_device *sdevice = to_siox_device(dev);
- int ret;
+ int ret = 0;
+
+ if (sdriver->probe)
+ ret = sdriver->probe(sdevice);
- ret = sdriver->probe(sdevice);
return ret;
}
-static int siox_driver_remove(struct device *dev)
+static int siox_remove(struct device *dev)
{
struct siox_driver *sdriver =
container_of(dev->driver, struct siox_driver, driver);
struct siox_device *sdevice = to_siox_device(dev);
- int ret;
+ int ret = 0;
+
+ if (sdriver->remove)
+ ret = sdriver->remove(sdevice);
- ret = sdriver->remove(sdevice);
return ret;
}
-static void siox_driver_shutdown(struct device *dev)
+static void siox_shutdown(struct device *dev)
{
struct siox_driver *sdriver =
container_of(dev->driver, struct siox_driver, driver);
struct siox_device *sdevice = to_siox_device(dev);
- sdriver->shutdown(sdevice);
+ if (sdriver->shutdown)
+ sdriver->shutdown(sdevice);
}
+static struct bus_type siox_bus_type = {
+ .name = "siox",
+ .match = siox_match,
+ .probe = siox_probe,
+ .remove = siox_remove,
+ .shutdown = siox_shutdown,
+};
+
static ssize_t active_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -892,11 +900,6 @@ int __siox_driver_register(struct siox_driver *sdriver, struct module *owner)
sdriver->driver.bus = &siox_bus_type;
if (sdriver->probe)
- sdriver->driver.probe = siox_driver_probe;
- if (sdriver->remove)
- sdriver->driver.remove = siox_driver_remove;
- if (sdriver->shutdown)
- sdriver->driver.shutdown = siox_driver_shutdown;
ret = driver_register(&sdriver->driver);
if (ret)
--
2.28.0
next reply other threads:[~2020-11-19 13:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 13:23 Uwe Kleine-König [this message]
2020-11-19 13:23 ` [PATCH 2/2] siox: Make remove callback return void Uwe Kleine-König
2020-11-24 17:36 ` [PATCH 1/2] siox: Use bus_type functions for probe, remote and shutdown 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=20201119132311.2604232-1-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=gregkh@linuxfoundation.org \
--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).