linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] siox: two cleanups
@ 2020-11-25  9:31 Uwe Kleine-König
  2020-11-25  9:31 ` [PATCH v3 1/2] siox: Use bus_type functions for probe, remove and shutdown Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2020-11-25  9:31 UTC (permalink / raw)
  To: Thorsten Scherer, Greg Kroah-Hartman
  Cc: linux-kernel, Pengutronix Kernel Team

Hello,

compared to v2 sent starting with Message-Id:
20201124141834.3096325-1-u.kleine-koenig@pengutronix.de:

 - fix typo in commit log of patch 1
 - add Ack by Thorsten for patch 1

Uwe Kleine-König (2):
  siox: Use bus_type functions for probe, remove and shutdown
  siox: Make remove callback return void

 drivers/siox/siox-core.c | 50 ++++++++++++++++++++--------------------
 include/linux/siox.h     |  2 +-
 2 files changed, 26 insertions(+), 26 deletions(-)


base-commit: 418baf2c28f3473039f2f7377760bd8f6897ae18
-- 
2.29.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/2] siox: Use bus_type functions for probe, remove and shutdown
  2020-11-25  9:31 [PATCH v3 0/2] siox: two cleanups Uwe Kleine-König
@ 2020-11-25  9:31 ` Uwe Kleine-König
  2020-11-25  9:31 ` [PATCH v3 2/2] siox: Make remove callback return void Uwe Kleine-König
  2020-11-25 14:47 ` [PATCH v3 0/2] siox: two cleanups Thorsten Scherer
  2 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2020-11-25  9:31 UTC (permalink / raw)
  To: Thorsten Scherer, Greg Kroah-Hartman
  Cc: linux-kernel, Pengutronix Kernel Team

The eventual goal is to get rid of the callbacks in struct
device_driver.

Acked-by: Thorsten Scherer <t.scherer@eckelmann.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/siox/siox-core.c | 49 ++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index f8c08fb9891d..b56cdcb52967 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -512,41 +512,48 @@ 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;
 
-	ret = sdriver->probe(sdevice);
-	return ret;
+	return sdriver->probe(sdevice);
 }
 
-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);
+	struct siox_driver *sdriver;
 
-	sdriver->shutdown(sdevice);
+	if (!dev->driver)
+		return;
+
+	sdriver = container_of(dev->driver, struct siox_driver, driver);
+	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)
 {
@@ -882,7 +889,8 @@ int __siox_driver_register(struct siox_driver *sdriver, struct module *owner)
 	if (unlikely(!siox_is_registered))
 		return -EPROBE_DEFER;
 
-	if (!sdriver->set_data && !sdriver->get_data) {
+	if (!sdriver->probe ||
+	    (!sdriver->set_data && !sdriver->get_data)) {
 		pr_err("Driver %s doesn't provide needed callbacks\n",
 		       sdriver->driver.name);
 		return -EINVAL;
@@ -891,13 +899,6 @@ int __siox_driver_register(struct siox_driver *sdriver, struct module *owner)
 	sdriver->driver.owner = 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)
 		pr_err("Failed to register siox driver %s (%d)\n",
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/2] siox: Make remove callback return void
  2020-11-25  9:31 [PATCH v3 0/2] siox: two cleanups Uwe Kleine-König
  2020-11-25  9:31 ` [PATCH v3 1/2] siox: Use bus_type functions for probe, remove and shutdown Uwe Kleine-König
@ 2020-11-25  9:31 ` Uwe Kleine-König
  2020-11-25 14:42   ` Thorsten Scherer
  2020-11-25 14:47 ` [PATCH v3 0/2] siox: two cleanups Thorsten Scherer
  2 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2020-11-25  9:31 UTC (permalink / raw)
  To: Thorsten Scherer, Greg Kroah-Hartman
  Cc: linux-kernel, Pengutronix Kernel Team

The driver core ignores the return value of the remove callback, so
don't give siox drivers the chance to provide a value.

All siox drivers only allocate devm-managed resources in
.probe, so there is no .remove callback to fix.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/siox/siox-core.c | 5 ++---
 include/linux/siox.h     | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index b56cdcb52967..1794ff0106bc 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -525,12 +525,11 @@ 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 = 0;
 
 	if (sdriver->remove)
-		ret = sdriver->remove(sdevice);
+		sdriver->remove(sdevice);
 
-	return ret;
+	return 0;
 }
 
 static void siox_shutdown(struct device *dev)
diff --git a/include/linux/siox.h b/include/linux/siox.h
index da7225bf1877..6bfbda3f634c 100644
--- a/include/linux/siox.h
+++ b/include/linux/siox.h
@@ -36,7 +36,7 @@ bool siox_device_connected(struct siox_device *sdevice);
 
 struct siox_driver {
 	int (*probe)(struct siox_device *sdevice);
-	int (*remove)(struct siox_device *sdevice);
+	void (*remove)(struct siox_device *sdevice);
 	void (*shutdown)(struct siox_device *sdevice);
 
 	/*
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] siox: Make remove callback return void
  2020-11-25  9:31 ` [PATCH v3 2/2] siox: Make remove callback return void Uwe Kleine-König
@ 2020-11-25 14:42   ` Thorsten Scherer
  0 siblings, 0 replies; 8+ messages in thread
From: Thorsten Scherer @ 2020-11-25 14:42 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Greg Kroah-Hartman, linux-kernel, Pengutronix Kernel Team

Hello,

On Wed, Nov 25, 2020 at 10:31:06AM +0100, Uwe Kleine-König wrote:
> The driver core ignores the return value of the remove callback, so
> don't give siox drivers the chance to provide a value.
> 
> All siox drivers only allocate devm-managed resources in
> .probe, so there is no .remove callback to fix.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Acked-by: Thorsten Scherer <t.scherer@eckelmann.de>

> ---
>  drivers/siox/siox-core.c | 5 ++---
>  include/linux/siox.h     | 2 +-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
> index b56cdcb52967..1794ff0106bc 100644
> --- a/drivers/siox/siox-core.c
> +++ b/drivers/siox/siox-core.c
> @@ -525,12 +525,11 @@ 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 = 0;
>  
>  	if (sdriver->remove)
> -		ret = sdriver->remove(sdevice);
> +		sdriver->remove(sdevice);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  static void siox_shutdown(struct device *dev)
> diff --git a/include/linux/siox.h b/include/linux/siox.h
> index da7225bf1877..6bfbda3f634c 100644
> --- a/include/linux/siox.h
> +++ b/include/linux/siox.h
> @@ -36,7 +36,7 @@ bool siox_device_connected(struct siox_device *sdevice);
>  
>  struct siox_driver {
>  	int (*probe)(struct siox_device *sdevice);
> -	int (*remove)(struct siox_device *sdevice);
> +	void (*remove)(struct siox_device *sdevice);
>  	void (*shutdown)(struct siox_device *sdevice);
>  
>  	/*
> -- 
> 2.29.2
> 

Kind regards
Thorsten

--
Thorsten Scherer | Eckelmann AG | www.eckelmann.de |

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] siox: two cleanups
  2020-11-25  9:31 [PATCH v3 0/2] siox: two cleanups Uwe Kleine-König
  2020-11-25  9:31 ` [PATCH v3 1/2] siox: Use bus_type functions for probe, remove and shutdown Uwe Kleine-König
  2020-11-25  9:31 ` [PATCH v3 2/2] siox: Make remove callback return void Uwe Kleine-König
@ 2020-11-25 14:47 ` Thorsten Scherer
  2020-12-09 18:54   ` Greg Kroah-Hartman
  2 siblings, 1 reply; 8+ messages in thread
From: Thorsten Scherer @ 2020-11-25 14:47 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Greg Kroah-Hartman, linux-kernel, Pengutronix Kernel Team

Hello,

On Wed, Nov 25, 2020 at 10:31:04AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> compared to v2 sent starting with Message-Id:
> 20201124141834.3096325-1-u.kleine-koenig@pengutronix.de:
> 
>  - fix typo in commit log of patch 1
>  - add Ack by Thorsten for patch 1
> 
> Uwe Kleine-König (2):
>   siox: Use bus_type functions for probe, remove and shutdown
>   siox: Make remove callback return void

Successfully ran our siox testcases on v3.

Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>

> 
>  drivers/siox/siox-core.c | 50 ++++++++++++++++++++--------------------
>  include/linux/siox.h     |  2 +-
>  2 files changed, 26 insertions(+), 26 deletions(-)
> 
> 
> base-commit: 418baf2c28f3473039f2f7377760bd8f6897ae18
> -- 
> 2.29.2
> 

Thanks.

Kind regards
Thorsten

--
Thorsten Scherer | Eckelmann AG | www.eckelmann.de |

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] siox: two cleanups
  2020-11-25 14:47 ` [PATCH v3 0/2] siox: two cleanups Thorsten Scherer
@ 2020-12-09 18:54   ` Greg Kroah-Hartman
  2020-12-10  8:38     ` Uwe Kleine-König
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-09 18:54 UTC (permalink / raw)
  To: Thorsten Scherer
  Cc: Uwe Kleine-König, linux-kernel, Pengutronix Kernel Team

On Wed, Nov 25, 2020 at 03:47:20PM +0100, Thorsten Scherer wrote:
> Hello,
> 
> On Wed, Nov 25, 2020 at 10:31:04AM +0100, Uwe Kleine-König wrote:
> > Hello,
> >
> > compared to v2 sent starting with Message-Id:
> > 20201124141834.3096325-1-u.kleine-koenig@pengutronix.de:
> >
> >  - fix typo in commit log of patch 1
> >  - add Ack by Thorsten for patch 1
> >
> > Uwe Kleine-König (2):
> >   siox: Use bus_type functions for probe, remove and shutdown
> >   siox: Make remove callback return void
> 
> Successfully ran our siox testcases on v3.
> 
> Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>

Are you going to take these patches, or do you need/want me to take them
through one of my trees?

Either is fine for me.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] siox: two cleanups
  2020-12-09 18:54   ` Greg Kroah-Hartman
@ 2020-12-10  8:38     ` Uwe Kleine-König
  2020-12-10  8:53       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2020-12-10  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Thorsten Scherer, linux-kernel, Pengutronix Kernel Team

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

On Wed, Dec 09, 2020 at 07:54:55PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 25, 2020 at 03:47:20PM +0100, Thorsten Scherer wrote:
> > Hello,
> > 
> > On Wed, Nov 25, 2020 at 10:31:04AM +0100, Uwe Kleine-König wrote:
> > > Hello,
> > >
> > > compared to v2 sent starting with Message-Id:
> > > 20201124141834.3096325-1-u.kleine-koenig@pengutronix.de:
> > >
> > >  - fix typo in commit log of patch 1
> > >  - add Ack by Thorsten for patch 1
> > >
> > > Uwe Kleine-König (2):
> > >   siox: Use bus_type functions for probe, remove and shutdown
> > >   siox: Make remove callback return void
> > 
> > Successfully ran our siox testcases on v3.
> > 
> > Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>
> 
> Are you going to take these patches, or do you need/want me to take them
> through one of my trees?
> 
> Either is fine for me.

There is no repo for SIOX and up to know you were our upstream. So if
you could take them that would be great.

Given that I expect that the patch volume for SIOX continues to stay low
I see little benefit in establishing a different work flow.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] siox: two cleanups
  2020-12-10  8:38     ` Uwe Kleine-König
@ 2020-12-10  8:53       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-10  8:53 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thorsten Scherer, linux-kernel, Pengutronix Kernel Team

On Thu, Dec 10, 2020 at 09:38:59AM +0100, Uwe Kleine-König wrote:
> On Wed, Dec 09, 2020 at 07:54:55PM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 25, 2020 at 03:47:20PM +0100, Thorsten Scherer wrote:
> > > Hello,
> > > 
> > > On Wed, Nov 25, 2020 at 10:31:04AM +0100, Uwe Kleine-König wrote:
> > > > Hello,
> > > >
> > > > compared to v2 sent starting with Message-Id:
> > > > 20201124141834.3096325-1-u.kleine-koenig@pengutronix.de:
> > > >
> > > >  - fix typo in commit log of patch 1
> > > >  - add Ack by Thorsten for patch 1
> > > >
> > > > Uwe Kleine-König (2):
> > > >   siox: Use bus_type functions for probe, remove and shutdown
> > > >   siox: Make remove callback return void
> > > 
> > > Successfully ran our siox testcases on v3.
> > > 
> > > Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>
> > 
> > Are you going to take these patches, or do you need/want me to take them
> > through one of my trees?
> > 
> > Either is fine for me.
> 
> There is no repo for SIOX and up to know you were our upstream. So if
> you could take them that would be great.

Ok, will do, I can't remember what trees I am "upstream" for anymore, I
seem to be collecting more and more of them these days :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-12-10  8:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25  9:31 [PATCH v3 0/2] siox: two cleanups Uwe Kleine-König
2020-11-25  9:31 ` [PATCH v3 1/2] siox: Use bus_type functions for probe, remove and shutdown Uwe Kleine-König
2020-11-25  9:31 ` [PATCH v3 2/2] siox: Make remove callback return void Uwe Kleine-König
2020-11-25 14:42   ` Thorsten Scherer
2020-11-25 14:47 ` [PATCH v3 0/2] siox: two cleanups Thorsten Scherer
2020-12-09 18:54   ` Greg Kroah-Hartman
2020-12-10  8:38     ` Uwe Kleine-König
2020-12-10  8:53       ` Greg Kroah-Hartman

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).