* [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function
@ 2017-11-15 21:00 Guenter Roeck
2017-11-15 21:00 ` [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime Guenter Roeck
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Guenter Roeck @ 2017-11-15 21:00 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dmitry Torokhov, linux-kernel, Randy Dunlap, Wei-Ning Huang,
Guenter Roeck
vpd sections are initialized during probe and thus should be destroyed
in the remove function.
Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/firmware/google/vpd.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index 35e553b3b190..84217172297b 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -298,8 +298,17 @@ static int vpd_probe(struct platform_device *pdev)
return vpd_sections_init(entry.cbmem_addr);
}
+static int vpd_remove(struct platform_device *pdev)
+{
+ vpd_section_destroy(&ro_vpd);
+ vpd_section_destroy(&rw_vpd);
+
+ return 0;
+}
+
static struct platform_driver vpd_driver = {
.probe = vpd_probe,
+ .remove = vpd_remove,
.driver = {
.name = "vpd",
},
@@ -324,8 +333,6 @@ static int __init vpd_platform_init(void)
static void __exit vpd_platform_exit(void)
{
- vpd_section_destroy(&ro_vpd);
- vpd_section_destroy(&rw_vpd);
kobject_put(vpd_kobj);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime
2017-11-15 21:00 [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Guenter Roeck
@ 2017-11-15 21:00 ` Guenter Roeck
2017-11-15 22:28 ` Dmitry Torokhov
2017-11-15 21:00 ` [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration Guenter Roeck
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2017-11-15 21:00 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dmitry Torokhov, linux-kernel, Randy Dunlap, Wei-Ning Huang,
Guenter Roeck
It doesn't make sense to have /sys/firmware/vpd if the device is not
instantiated, so tie its lifetime to the device.
Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/firmware/google/vpd.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index 84217172297b..942e358efa60 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -295,7 +295,17 @@ static int vpd_probe(struct platform_device *pdev)
if (ret)
return ret;
- return vpd_sections_init(entry.cbmem_addr);
+ vpd_kobj = kobject_create_and_add("vpd", firmware_kobj);
+ if (!vpd_kobj)
+ return -ENOMEM;
+
+ ret = vpd_sections_init(entry.cbmem_addr);
+ if (ret) {
+ kobject_put(vpd_kobj);
+ return ret;
+ }
+
+ return 0;
}
static int vpd_remove(struct platform_device *pdev)
@@ -303,6 +313,8 @@ static int vpd_remove(struct platform_device *pdev)
vpd_section_destroy(&ro_vpd);
vpd_section_destroy(&rw_vpd);
+ kobject_put(vpd_kobj);
+
return 0;
}
@@ -322,10 +334,6 @@ static int __init vpd_platform_init(void)
if (IS_ERR(pdev))
return PTR_ERR(pdev);
- vpd_kobj = kobject_create_and_add("vpd", firmware_kobj);
- if (!vpd_kobj)
- return -ENOMEM;
-
platform_driver_register(&vpd_driver);
return 0;
@@ -333,7 +341,6 @@ static int __init vpd_platform_init(void)
static void __exit vpd_platform_exit(void)
{
- kobject_put(vpd_kobj);
}
module_init(vpd_platform_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration
2017-11-15 21:00 [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Guenter Roeck
2017-11-15 21:00 ` [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime Guenter Roeck
@ 2017-11-15 21:00 ` Guenter Roeck
2017-11-15 22:28 ` Dmitry Torokhov
2017-11-15 22:27 ` [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Dmitry Torokhov
2017-11-16 1:08 ` Randy Dunlap
3 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2017-11-15 21:00 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dmitry Torokhov, linux-kernel, Randy Dunlap, Wei-Ning Huang,
Guenter Roeck
The driver exit function needs to unregister both platform device and
driver. Also, during registration, register driver first and perform
error checks.
Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/firmware/google/vpd.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index 942e358efa60..e4b40f2b4627 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -326,21 +326,29 @@ static struct platform_driver vpd_driver = {
},
};
+static struct platform_device *vpd_pdev;
+
static int __init vpd_platform_init(void)
{
- struct platform_device *pdev;
+ int ret;
- pdev = platform_device_register_simple("vpd", -1, NULL, 0);
- if (IS_ERR(pdev))
- return PTR_ERR(pdev);
+ ret = platform_driver_register(&vpd_driver);
+ if (ret)
+ return ret;
- platform_driver_register(&vpd_driver);
+ vpd_pdev = platform_device_register_simple("vpd", -1, NULL, 0);
+ if (IS_ERR(vpd_pdev)) {
+ platform_driver_unregister(&vpd_driver);
+ return PTR_ERR(vpd_pdev);
+ }
return 0;
}
static void __exit vpd_platform_exit(void)
{
+ platform_device_unregister(vpd_pdev);
+ platform_driver_unregister(&vpd_driver);
}
module_init(vpd_platform_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function
2017-11-15 21:00 [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Guenter Roeck
2017-11-15 21:00 ` [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime Guenter Roeck
2017-11-15 21:00 ` [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration Guenter Roeck
@ 2017-11-15 22:27 ` Dmitry Torokhov
2017-11-16 1:08 ` Randy Dunlap
3 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2017-11-15 22:27 UTC (permalink / raw)
To: Guenter Roeck
Cc: Greg Kroah-Hartman, linux-kernel, Randy Dunlap, Wei-Ning Huang
On Wed, Nov 15, 2017 at 01:00:43PM -0800, Guenter Roeck wrote:
> vpd sections are initialized during probe and thus should be destroyed
> in the remove function.
>
> Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/firmware/google/vpd.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
> index 35e553b3b190..84217172297b 100644
> --- a/drivers/firmware/google/vpd.c
> +++ b/drivers/firmware/google/vpd.c
> @@ -298,8 +298,17 @@ static int vpd_probe(struct platform_device *pdev)
> return vpd_sections_init(entry.cbmem_addr);
> }
>
> +static int vpd_remove(struct platform_device *pdev)
> +{
> + vpd_section_destroy(&ro_vpd);
> + vpd_section_destroy(&rw_vpd);
> +
> + return 0;
> +}
> +
> static struct platform_driver vpd_driver = {
> .probe = vpd_probe,
> + .remove = vpd_remove,
> .driver = {
> .name = "vpd",
> },
> @@ -324,8 +333,6 @@ static int __init vpd_platform_init(void)
>
> static void __exit vpd_platform_exit(void)
> {
> - vpd_section_destroy(&ro_vpd);
> - vpd_section_destroy(&rw_vpd);
> kobject_put(vpd_kobj);
> }
>
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime
2017-11-15 21:00 ` [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime Guenter Roeck
@ 2017-11-15 22:28 ` Dmitry Torokhov
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2017-11-15 22:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: Greg Kroah-Hartman, linux-kernel, Randy Dunlap, Wei-Ning Huang
On Wed, Nov 15, 2017 at 01:00:44PM -0800, Guenter Roeck wrote:
> It doesn't make sense to have /sys/firmware/vpd if the device is not
> instantiated, so tie its lifetime to the device.
>
> Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/firmware/google/vpd.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
> index 84217172297b..942e358efa60 100644
> --- a/drivers/firmware/google/vpd.c
> +++ b/drivers/firmware/google/vpd.c
> @@ -295,7 +295,17 @@ static int vpd_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - return vpd_sections_init(entry.cbmem_addr);
> + vpd_kobj = kobject_create_and_add("vpd", firmware_kobj);
> + if (!vpd_kobj)
> + return -ENOMEM;
> +
> + ret = vpd_sections_init(entry.cbmem_addr);
> + if (ret) {
> + kobject_put(vpd_kobj);
> + return ret;
> + }
> +
> + return 0;
> }
>
> static int vpd_remove(struct platform_device *pdev)
> @@ -303,6 +313,8 @@ static int vpd_remove(struct platform_device *pdev)
> vpd_section_destroy(&ro_vpd);
> vpd_section_destroy(&rw_vpd);
>
> + kobject_put(vpd_kobj);
> +
> return 0;
> }
>
> @@ -322,10 +334,6 @@ static int __init vpd_platform_init(void)
> if (IS_ERR(pdev))
> return PTR_ERR(pdev);
>
> - vpd_kobj = kobject_create_and_add("vpd", firmware_kobj);
> - if (!vpd_kobj)
> - return -ENOMEM;
> -
> platform_driver_register(&vpd_driver);
>
> return 0;
> @@ -333,7 +341,6 @@ static int __init vpd_platform_init(void)
>
> static void __exit vpd_platform_exit(void)
> {
> - kobject_put(vpd_kobj);
> }
>
> module_init(vpd_platform_init);
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration
2017-11-15 21:00 ` [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration Guenter Roeck
@ 2017-11-15 22:28 ` Dmitry Torokhov
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2017-11-15 22:28 UTC (permalink / raw)
To: Guenter Roeck
Cc: Greg Kroah-Hartman, linux-kernel, Randy Dunlap, Wei-Ning Huang
On Wed, Nov 15, 2017 at 01:00:45PM -0800, Guenter Roeck wrote:
> The driver exit function needs to unregister both platform device and
> driver. Also, during registration, register driver first and perform
> error checks.
>
> Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/firmware/google/vpd.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
> index 942e358efa60..e4b40f2b4627 100644
> --- a/drivers/firmware/google/vpd.c
> +++ b/drivers/firmware/google/vpd.c
> @@ -326,21 +326,29 @@ static struct platform_driver vpd_driver = {
> },
> };
>
> +static struct platform_device *vpd_pdev;
> +
> static int __init vpd_platform_init(void)
> {
> - struct platform_device *pdev;
> + int ret;
>
> - pdev = platform_device_register_simple("vpd", -1, NULL, 0);
> - if (IS_ERR(pdev))
> - return PTR_ERR(pdev);
> + ret = platform_driver_register(&vpd_driver);
> + if (ret)
> + return ret;
>
> - platform_driver_register(&vpd_driver);
> + vpd_pdev = platform_device_register_simple("vpd", -1, NULL, 0);
> + if (IS_ERR(vpd_pdev)) {
> + platform_driver_unregister(&vpd_driver);
> + return PTR_ERR(vpd_pdev);
> + }
>
> return 0;
> }
>
> static void __exit vpd_platform_exit(void)
> {
> + platform_device_unregister(vpd_pdev);
> + platform_driver_unregister(&vpd_driver);
> }
>
> module_init(vpd_platform_init);
> --
> 2.7.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function
2017-11-15 21:00 [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Guenter Roeck
` (2 preceding siblings ...)
2017-11-15 22:27 ` [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Dmitry Torokhov
@ 2017-11-16 1:08 ` Randy Dunlap
3 siblings, 0 replies; 7+ messages in thread
From: Randy Dunlap @ 2017-11-16 1:08 UTC (permalink / raw)
To: Guenter Roeck, Greg Kroah-Hartman
Cc: Dmitry Torokhov, linux-kernel, Wei-Ning Huang
On 11/15/17 13:00, Guenter Roeck wrote:
> vpd sections are initialized during probe and thus should be destroyed
> in the remove function.
>
> Fixes: 049a59db34eb ("firmware: Google VPD sysfs driver")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/firmware/google/vpd.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
For all 3 patches:
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
--
~Randy
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-11-16 1:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-15 21:00 [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Guenter Roeck
2017-11-15 21:00 ` [PATCH 2/3] firmware: vpd: Tie firmware kobject to device lifetime Guenter Roeck
2017-11-15 22:28 ` Dmitry Torokhov
2017-11-15 21:00 ` [PATCH 3/3] firmware: vpd: Fix platform driver and device registration/unregistration Guenter Roeck
2017-11-15 22:28 ` Dmitry Torokhov
2017-11-15 22:27 ` [PATCH 1/3] firmware: vpd: Destroy vpd sections in remove function Dmitry Torokhov
2017-11-16 1:08 ` Randy Dunlap
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.