All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
@ 2024-03-29 16:13 Krzysztof Kozlowski
  2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-29 16:13 UTC (permalink / raw
  To: Srinivas Kandagatla, Miquel Raynal, Michael Walle
  Cc: linux-kernel, Krzysztof Kozlowski

Merging
=======
All further patches depend on the first patch.

Description
===========
Modules registering driver with nvmem_layout_driver_register() might
forget to set .owner field.

Solve the problem by moving this task away from the drivers to the core
code, just like we did for platform_driver in commit 9447057eaff8
("platform_device: use a macro instead of platform_driver_register").

Best regards,
Krzysztof

---
Krzysztof Kozlowski (3):
      nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
      nvmem: layouts: onie-tlv: drop driver owner initialization
      nvmem: layouts: sl28vpd: drop driver owner initialization

 drivers/nvmem/layouts.c          | 6 ++++--
 drivers/nvmem/layouts/onie-tlv.c | 1 -
 drivers/nvmem/layouts/sl28vpd.c  | 1 -
 include/linux/nvmem-provider.h   | 5 ++++-
 4 files changed, 8 insertions(+), 5 deletions(-)
---
base-commit: 7fdcff3312e16ba8d1419f8a18f465c5cc235ecf
change-id: 20240329-module-owner-nvmem-861ae7a0fc24

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


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

* [PATCH 1/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
  2024-03-29 16:13 [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Krzysztof Kozlowski
@ 2024-03-29 16:13 ` Krzysztof Kozlowski
  2024-04-02  7:16   ` Miquel Raynal
  2024-04-02  8:37   ` Michael Walle
  2024-03-29 16:13 ` [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-29 16:13 UTC (permalink / raw
  To: Srinivas Kandagatla, Miquel Raynal, Michael Walle
  Cc: linux-kernel, Krzysztof Kozlowski

Modules registering driver with nvmem_layout_driver_register() might
forget to set .owner field.  The field is used by some of other kernel
parts for reference counting (try_module_get()), so it is expected that
drivers will set it.

Solve the problem by moving this task away from the drivers to the core
code, just like we did for platform_driver in
commit 9447057eaff8 ("platform_device: use a macro instead of
platform_driver_register").

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/nvmem/layouts.c        | 6 ++++--
 include/linux/nvmem-provider.h | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c
index 8b5e2de138eb..64dc7013a098 100644
--- a/drivers/nvmem/layouts.c
+++ b/drivers/nvmem/layouts.c
@@ -52,13 +52,15 @@ static const struct bus_type nvmem_layout_bus_type = {
 	.remove		= nvmem_layout_bus_remove,
 };
 
-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv)
+int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv,
+				   struct module *owner)
 {
 	drv->driver.bus = &nvmem_layout_bus_type;
+	drv->driver.owner = owner;
 
 	return driver_register(&drv->driver);
 }
-EXPORT_SYMBOL_GPL(nvmem_layout_driver_register);
+EXPORT_SYMBOL_GPL(__nvmem_layout_driver_register);
 
 void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv)
 {
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index f0ba0e03218f..3ebeaa0ded00 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -199,7 +199,10 @@ int nvmem_add_one_cell(struct nvmem_device *nvmem,
 int nvmem_layout_register(struct nvmem_layout *layout);
 void nvmem_layout_unregister(struct nvmem_layout *layout);
 
-int nvmem_layout_driver_register(struct nvmem_layout_driver *drv);
+#define nvmem_layout_driver_register(drv) \
+	__nvmem_layout_driver_register(drv, THIS_MODULE)
+int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv,
+				   struct module *owner);
 void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv);
 #define module_nvmem_layout_driver(__nvmem_layout_driver)		\
 	module_driver(__nvmem_layout_driver, nvmem_layout_driver_register, \

-- 
2.34.1


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

* [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization
  2024-03-29 16:13 [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Krzysztof Kozlowski
  2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
@ 2024-03-29 16:13 ` Krzysztof Kozlowski
  2024-04-02  7:16   ` Miquel Raynal
  2024-04-02  8:37   ` Michael Walle
  2024-03-29 16:13 ` [PATCH 3/3] nvmem: layouts: sl28vpd: " Krzysztof Kozlowski
  2024-04-11 10:01 ` [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Srinivas Kandagatla
  3 siblings, 2 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-29 16:13 UTC (permalink / raw
  To: Srinivas Kandagatla, Miquel Raynal, Michael Walle
  Cc: linux-kernel, Krzysztof Kozlowski

Core in nvmem_layout_driver_register() already sets the .owner, so
driver does not need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Depends on the first patch.
---
 drivers/nvmem/layouts/onie-tlv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
index 9d2ad5f2dc10..0967a32319a2 100644
--- a/drivers/nvmem/layouts/onie-tlv.c
+++ b/drivers/nvmem/layouts/onie-tlv.c
@@ -247,7 +247,6 @@ MODULE_DEVICE_TABLE(of, onie_tlv_of_match_table);
 
 static struct nvmem_layout_driver onie_tlv_layout = {
 	.driver = {
-		.owner = THIS_MODULE,
 		.name = "onie-tlv-layout",
 		.of_match_table = onie_tlv_of_match_table,
 	},

-- 
2.34.1


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

* [PATCH 3/3] nvmem: layouts: sl28vpd: drop driver owner initialization
  2024-03-29 16:13 [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Krzysztof Kozlowski
  2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
  2024-03-29 16:13 ` [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization Krzysztof Kozlowski
@ 2024-03-29 16:13 ` Krzysztof Kozlowski
  2024-04-02  7:17   ` Miquel Raynal
  2024-04-02  8:38   ` Michael Walle
  2024-04-11 10:01 ` [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Srinivas Kandagatla
  3 siblings, 2 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-29 16:13 UTC (permalink / raw
  To: Srinivas Kandagatla, Miquel Raynal, Michael Walle
  Cc: linux-kernel, Krzysztof Kozlowski

Core in nvmem_layout_driver_register() already sets the .owner, so
driver does not need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/nvmem/layouts/sl28vpd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nvmem/layouts/sl28vpd.c b/drivers/nvmem/layouts/sl28vpd.c
index 53fa50f17dca..e93b020b0836 100644
--- a/drivers/nvmem/layouts/sl28vpd.c
+++ b/drivers/nvmem/layouts/sl28vpd.c
@@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(of, sl28vpd_of_match_table);
 
 static struct nvmem_layout_driver sl28vpd_layout = {
 	.driver = {
-		.owner = THIS_MODULE,
 		.name = "kontron-sl28vpd-layout",
 		.of_match_table = sl28vpd_of_match_table,
 	},

-- 
2.34.1


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

* Re: [PATCH 1/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
  2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
@ 2024-04-02  7:16   ` Miquel Raynal
  2024-04-02  8:37   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Miquel Raynal @ 2024-04-02  7:16 UTC (permalink / raw
  To: Krzysztof Kozlowski; +Cc: Srinivas Kandagatla, Michael Walle, linux-kernel

Hi Krzysztof,

krzysztof.kozlowski@linaro.org wrote on Fri, 29 Mar 2024 17:13:35 +0100:

> Modules registering driver with nvmem_layout_driver_register() might
> forget to set .owner field.  The field is used by some of other kernel
> parts for reference counting (try_module_get()), so it is expected that
> drivers will set it.
> 
> Solve the problem by moving this task away from the drivers to the core
> code, just like we did for platform_driver in
> commit 9447057eaff8 ("platform_device: use a macro instead of
> platform_driver_register").
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization
  2024-03-29 16:13 ` [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization Krzysztof Kozlowski
@ 2024-04-02  7:16   ` Miquel Raynal
  2024-04-02  8:37   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Miquel Raynal @ 2024-04-02  7:16 UTC (permalink / raw
  To: Krzysztof Kozlowski; +Cc: Srinivas Kandagatla, Michael Walle, linux-kernel

Hi Krzysztof,

krzysztof.kozlowski@linaro.org wrote on Fri, 29 Mar 2024 17:13:36 +0100:

> Core in nvmem_layout_driver_register() already sets the .owner, so
> driver does not need to.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [PATCH 3/3] nvmem: layouts: sl28vpd: drop driver owner initialization
  2024-03-29 16:13 ` [PATCH 3/3] nvmem: layouts: sl28vpd: " Krzysztof Kozlowski
@ 2024-04-02  7:17   ` Miquel Raynal
  2024-04-02  8:38   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Miquel Raynal @ 2024-04-02  7:17 UTC (permalink / raw
  To: Krzysztof Kozlowski; +Cc: Srinivas Kandagatla, Michael Walle, linux-kernel

Hi Krzysztof,

krzysztof.kozlowski@linaro.org wrote on Fri, 29 Mar 2024 17:13:37 +0100:

> Core in nvmem_layout_driver_register() already sets the .owner, so
> driver does not need to.
> 

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  drivers/nvmem/layouts/sl28vpd.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/nvmem/layouts/sl28vpd.c b/drivers/nvmem/layouts/sl28vpd.c
> index 53fa50f17dca..e93b020b0836 100644
> --- a/drivers/nvmem/layouts/sl28vpd.c
> +++ b/drivers/nvmem/layouts/sl28vpd.c
> @@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(of, sl28vpd_of_match_table);
>  
>  static struct nvmem_layout_driver sl28vpd_layout = {
>  	.driver = {
> -		.owner = THIS_MODULE,
>  		.name = "kontron-sl28vpd-layout",
>  		.of_match_table = sl28vpd_of_match_$

Thanks,
Miquèl

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

* Re: [PATCH 1/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
  2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
  2024-04-02  7:16   ` Miquel Raynal
@ 2024-04-02  8:37   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Walle @ 2024-04-02  8:37 UTC (permalink / raw
  To: Krzysztof Kozlowski, Srinivas Kandagatla, Miquel Raynal; +Cc: linux-kernel

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

On Fri Mar 29, 2024 at 5:13 PM CET, Krzysztof Kozlowski wrote:
> Modules registering driver with nvmem_layout_driver_register() might
> forget to set .owner field.  The field is used by some of other kernel
> parts for reference counting (try_module_get()), so it is expected that
> drivers will set it.
>
> Solve the problem by moving this task away from the drivers to the core
> code, just like we did for platform_driver in
> commit 9447057eaff8 ("platform_device: use a macro instead of
> platform_driver_register").
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

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

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

* Re: [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization
  2024-03-29 16:13 ` [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization Krzysztof Kozlowski
  2024-04-02  7:16   ` Miquel Raynal
@ 2024-04-02  8:37   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Walle @ 2024-04-02  8:37 UTC (permalink / raw
  To: Krzysztof Kozlowski, Srinivas Kandagatla, Miquel Raynal; +Cc: linux-kernel

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

On Fri Mar 29, 2024 at 5:13 PM CET, Krzysztof Kozlowski wrote:
> Core in nvmem_layout_driver_register() already sets the .owner, so
> driver does not need to.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

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

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

* Re: [PATCH 3/3] nvmem: layouts: sl28vpd: drop driver owner initialization
  2024-03-29 16:13 ` [PATCH 3/3] nvmem: layouts: sl28vpd: " Krzysztof Kozlowski
  2024-04-02  7:17   ` Miquel Raynal
@ 2024-04-02  8:38   ` Michael Walle
  1 sibling, 0 replies; 11+ messages in thread
From: Michael Walle @ 2024-04-02  8:38 UTC (permalink / raw
  To: Krzysztof Kozlowski, Srinivas Kandagatla, Miquel Raynal; +Cc: linux-kernel

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

On Fri Mar 29, 2024 at 5:13 PM CET, Krzysztof Kozlowski wrote:
> Core in nvmem_layout_driver_register() already sets the .owner, so
> driver does not need to.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

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

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

* Re: [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
  2024-03-29 16:13 [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2024-03-29 16:13 ` [PATCH 3/3] nvmem: layouts: sl28vpd: " Krzysztof Kozlowski
@ 2024-04-11 10:01 ` Srinivas Kandagatla
  3 siblings, 0 replies; 11+ messages in thread
From: Srinivas Kandagatla @ 2024-04-11 10:01 UTC (permalink / raw
  To: Miquel Raynal, Michael Walle, Krzysztof Kozlowski; +Cc: linux-kernel


On Fri, 29 Mar 2024 17:13:34 +0100, Krzysztof Kozlowski wrote:
> Merging
> =======
> All further patches depend on the first patch.
> 
> Description
> ===========
> Modules registering driver with nvmem_layout_driver_register() might
> forget to set .owner field.
> 
> [...]

Applied, thanks!

[1/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register()
      commit: e428f11ae8fb23c4c9e4ca7c178ca22e8b6335b6
[2/3] nvmem: layouts: onie-tlv: drop driver owner initialization
      commit: 995b22c48ed05ef2149a364e2f4025fa14f8bb70
[3/3] nvmem: layouts: sl28vpd: drop driver owner initialization
      commit: 3575d48e5d2f7fcb258f1ee951f2d4706d8ff715

Best regards,
-- 
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


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

end of thread, other threads:[~2024-04-11 10:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 16:13 [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Krzysztof Kozlowski
2024-03-29 16:13 ` [PATCH 1/3] " Krzysztof Kozlowski
2024-04-02  7:16   ` Miquel Raynal
2024-04-02  8:37   ` Michael Walle
2024-03-29 16:13 ` [PATCH 2/3] nvmem: layouts: onie-tlv: drop driver owner initialization Krzysztof Kozlowski
2024-04-02  7:16   ` Miquel Raynal
2024-04-02  8:37   ` Michael Walle
2024-03-29 16:13 ` [PATCH 3/3] nvmem: layouts: sl28vpd: " Krzysztof Kozlowski
2024-04-02  7:17   ` Miquel Raynal
2024-04-02  8:38   ` Michael Walle
2024-04-11 10:01 ` [PATCH 0/3] nvmem: layouts: store owner from modules with nvmem_layout_driver_register() Srinivas Kandagatla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.