SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
       [not found] <20230313182918.1312597-1-gregkh@linuxfoundation.org>
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:38   ` John Paul Adrian Glaubitz
  2023-03-13 18:48   ` John Paul Adrian Glaubitz
  2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
  1 sibling, 2 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Yoshinori Sato, Rich Felker, linux-sh

Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.

 arch/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 8ef318150f84..431bc18f0a41 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
 
 static int __init dma_subsys_init(void)
 {
+	struct device *dev_root;
 	int ret;
 
 	ret = subsys_system_register(&dma_subsys, NULL);
 	if (unlikely(ret))
 		return ret;
 
-	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
+	dev_root = bus_get_dev_root(&dma_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &dev_attr_devices);
+		put_device(dev_root);
+	}
+	return ret;
 }
 postcore_initcall(dma_subsys_init);
 
-- 
2.39.2


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

* [PATCH 17/36] sh: intc: move to use bus_get_dev_root()
       [not found] <20230313182918.1312597-1-gregkh@linuxfoundation.org>
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:39   ` John Paul Adrian Glaubitz
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Yoshinori Sato, Rich Felker, linux-sh

Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.

 drivers/sh/intc/userimask.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
index f9f043a3d90a..abe9091827cd 100644
--- a/drivers/sh/intc/userimask.c
+++ b/drivers/sh/intc/userimask.c
@@ -61,10 +61,18 @@ static DEVICE_ATTR(userimask, S_IRUSR | S_IWUSR,
 
 static int __init userimask_sysdev_init(void)
 {
+	struct device *dev_root;
+	int ret = 0;
+
 	if (unlikely(!uimask))
 		return -ENXIO;
 
-	return device_create_file(intc_subsys.dev_root, &dev_attr_userimask);
+	dev_root = bus_get_dev_root(&intc_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &dev_attr_userimask);
+		put_device(dev_root);
+	}
+	return ret;
 }
 late_initcall(userimask_sysdev_init);
 
-- 
2.39.2


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

* Re: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:38   ` John Paul Adrian Glaubitz
  2023-03-13 18:48   ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

On Mon, 2023-03-13 at 19:28 +0100, Greg Kroah-Hartman wrote:
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
> 
>  arch/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
> index 8ef318150f84..431bc18f0a41 100644
> --- a/arch/sh/drivers/dma/dma-sysfs.c
> +++ b/arch/sh/drivers/dma/dma-sysfs.c
> @@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
>  
>  static int __init dma_subsys_init(void)
>  {
> +	struct device *dev_root;
>  	int ret;
>  
>  	ret = subsys_system_register(&dma_subsys, NULL);
>  	if (unlikely(ret))
>  		return ret;
>  
> -	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
> +	dev_root = bus_get_dev_root(&dma_subsys);
> +	if (dev_root) {
> +		ret = device_create_file(dev_root, &dev_attr_devices);
> +		put_device(dev_root);
> +	}
> +	return ret;
>  }
>  postcore_initcall(dma_subsys_init);
>  

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 17/36] sh: intc: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
@ 2023-03-13 18:39   ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

On Mon, 2023-03-13 at 19:28 +0100, Greg Kroah-Hartman wrote:
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
> 
>  drivers/sh/intc/userimask.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
> index f9f043a3d90a..abe9091827cd 100644
> --- a/drivers/sh/intc/userimask.c
> +++ b/drivers/sh/intc/userimask.c
> @@ -61,10 +61,18 @@ static DEVICE_ATTR(userimask, S_IRUSR | S_IWUSR,
>  
>  static int __init userimask_sysdev_init(void)
>  {
> +	struct device *dev_root;
> +	int ret = 0;
> +
>  	if (unlikely(!uimask))
>  		return -ENXIO;
>  
> -	return device_create_file(intc_subsys.dev_root, &dev_attr_userimask);
> +	dev_root = bus_get_dev_root(&intc_subsys);
> +	if (dev_root) {
> +		ret = device_create_file(dev_root, &dev_attr_userimask);
> +		put_device(dev_root);
> +	}
> +	return ret;
>  }
>  late_initcall(userimask_sysdev_init);
>  

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
  2023-03-13 18:38   ` John Paul Adrian Glaubitz
@ 2023-03-13 18:48   ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 5+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

Hi Greg!

On Mon, 2023-03-13 at 19:28 +0100, Greg Kroah-Hartman wrote:
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes.  It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
> 
>  arch/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
> index 8ef318150f84..431bc18f0a41 100644
> --- a/arch/sh/drivers/dma/dma-sysfs.c
> +++ b/arch/sh/drivers/dma/dma-sysfs.c
> @@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
>  
>  static int __init dma_subsys_init(void)
>  {
> +	struct device *dev_root;
>  	int ret;
>  
>  	ret = subsys_system_register(&dma_subsys, NULL);
>  	if (unlikely(ret))
>  		return ret;
>  
> -	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
> +	dev_root = bus_get_dev_root(&dma_subsys);
> +	if (dev_root) {
> +		ret = device_create_file(dev_root, &dev_attr_devices);
> +		put_device(dev_root);
> +	}
> +	return ret;
>  }
>  postcore_initcall(dma_subsys_init);
>  

After acking this, I noticed that if bus_get_dev_root() fails, "ret" remains
set to the value by subsys_system_register() which might confuse the caller
thinking that dma_subsys_init() succeeded unless I am missing something?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

end of thread, other threads:[~2023-03-13 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230313182918.1312597-1-gregkh@linuxfoundation.org>
2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
2023-03-13 18:38   ` John Paul Adrian Glaubitz
2023-03-13 18:48   ` John Paul Adrian Glaubitz
2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
2023-03-13 18:39   ` John Paul Adrian Glaubitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox