mfd: kempld: A few cleanups
cover mfd: kempld: A few cleanups
Just a set of ad-hoc cleanups. No functional change intended.
Andy Shevchenko (6):
mfd: kempld: Replace ACPI code with agnostic one
mfd: kempld: Use device core to create driver-specific device
attributes
mfd: kempld: Simplify device registration
mfd: kempld: Use PLATFORM_DEVID_NONE instead of -1
mfd: kempld: Drop duplicate NULL check in ->exit()
mfd: kempld: Remove dead code
drivers/mfd/kempld-core.c | 105 ++++++++++++-------------------------- 1 file changed, 33 insertions(+), 72 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 1/6 mfd: kempld: Replace ACPI code with agnostic one
There is no need to include and use entire ACPI stack in the driver. Replace respective pieces by agnostic code. No functional change indented.
--- drivers/mfd/kempld-core.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-)
drivers/mfd/kempld-core.c +11 -27
@@ -9,11 +9,12 @@#include <linux/platform_device.h> #include <linux/mfd/core.h> #include <linux/mfd/kempld.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> +#include <linux/property.h> #include <linux/dmi.h> #include <linux/io.h> #include <linux/delay.h> -#include <linux/acpi.h> #define MAX_ID_LEN 4static char force_device_id[MAX_ID_LEN +1 ] ="" ;
@@ -425,26 +426,6 @@ static int kempld_detect_device(struct kempld_device_data *pld)return ret; } -#ifdef CONFIG_ACPI -static int kempld_get_acpi_data (struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -const struct kempld_platform_data *pdata; -int ret; - - pdata =acpi_device_get_match_data (dev); - ret =platform_device_add_data (pdev, pdata, -sizeof (struct kempld_platform_data )); - -return ret; -} -#else -static int kempld_get_acpi_data (struct platform_device *pdev) -{ -return -ENODEV ; -} -#endif /* CONFIG_ACPI */ -static int kempld_probe (struct platform_device *pdev) {const struct kempld_platform_data *pdata;
@@ -458,10 +439,16 @@ static int kempld_probe(struct platform_device *pdev)* No kempld_pdev device has been registered in kempld_init, * so we seem to be probing an ACPI platform device. */ - ret =kempld_get_acpi_data (pdev); + pdata =device_get_match_data (dev); +if (!pdata) +return -ENODEV ; + + ret =platform_device_add_data (pdev, pdata,sizeof (*pdata));if (ret)return ret; - }else if (kempld_pdev != pdev) { + }else if (kempld_pdev == pdev) { + pdata =dev_get_platdata (dev); + }else {/* * The platform device we are probing is not the one we * registered in kempld_init using the DMI table, so this one
@@ -472,7 +459,6 @@ static int kempld_probe(struct platform_device *pdev)dev_notice (dev,"platform device exists - not using ACPI\n" );return -ENODEV ; } - pdata =dev_get_platdata (dev); pld =devm_kzalloc (dev,sizeof (*pld),GFP_KERNEL );if (!pld)
@@ -509,19 +495,17 @@ static void kempld_remove(struct platform_device *pdev) pdata->release_hardware_mutex (pld); } -#ifdef CONFIG_ACPI static const struct acpi_device_id kempld_acpi_table[] = { {"KEM0000" , (kernel_ulong_t)&kempld_platform_data_generic }, {"KEM0001" , (kernel_ulong_t)&kempld_platform_data_generic }, {} };MODULE_DEVICE_TABLE (acpi, kempld_acpi_table); -#endif static struct platform_driver kempld_driver = { .driver = { .name ="kempld" , - .acpi_match_table =ACPI_PTR (kempld_acpi_table), + .acpi_match_table = kempld_acpi_table, }, .probe = kempld_probe, .remove_new = kempld_remove,
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 2/6 mfd: kempld: Use device core to create driver-specific device attributes
In reply to Andy ShevchenkoInstead of creating driver-specific device attributes with sysfs_create_group() have device core do this by setting up dev_groups pointer in the driver structure.
--- drivers/mfd/kempld-core.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/mfd/kempld-core.c +5 -16
@@ -15,6 +15,7 @@#include <linux/dmi.h> #include <linux/io.h> #include <linux/delay.h> +#include <linux/sysfs.h> #define MAX_ID_LEN 4static char force_device_id[MAX_ID_LEN +1 ] ="" ;
@@ -373,16 +374,13 @@ static DEVICE_ATTR_RO(pld_version);static DEVICE_ATTR_RO (pld_specification);static DEVICE_ATTR_RO (pld_type); -static struct attribute *pld_attributes[] = { +static struct attribute *pld_attrs[] = { &dev_attr_pld_version.attr, &dev_attr_pld_specification.attr, &dev_attr_pld_type.attr,NULL }; - -static const struct attribute_group pld_attr_group = { - .attrs = pld_attributes, -}; +ATTRIBUTE_GROUPS (pld);static int kempld_detect_device (struct kempld_device_data *pld) {
@@ -415,15 +413,7 @@ static int kempld_detect_device(struct kempld_device_data *pld) pld->info.version,kempld_get_type_string (pld), pld->info.spec_major, pld->info.spec_minor); - ret =sysfs_create_group (&pld->dev->kobj, &pld_attr_group); -if (ret) -return ret; - - ret =kempld_register_cells (pld); -if (ret) -sysfs_remove_group (&pld->dev->kobj, &pld_attr_group); - -return ret; +return kempld_register_cells (pld); }static int kempld_probe (struct platform_device *pdev)
@@ -489,8 +479,6 @@ static void kempld_remove(struct platform_device *pdev)struct kempld_device_data *pld =platform_get_drvdata (pdev);const struct kempld_platform_data *pdata =dev_get_platdata (pld->dev); -sysfs_remove_group (&pld->dev->kobj, &pld_attr_group); -mfd_remove_devices (&pdev->dev); pdata->release_hardware_mutex (pld); }
@@ -506,6 +494,7 @@ static struct platform_driver kempld_driver = { .driver = { .name = "kempld", .acpi_match_table = kempld_acpi_table, + .dev_groups = pld_groups, }, .probe = kempld_probe, .remove_new = kempld_remove,
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 3/6 mfd: kempld: Simplify device registration
In reply to Andy ShevchenkoUse platform_device_register_full() instead of open coding this function.
--- drivers/mfd/kempld-core.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/mfd/kempld-core.c +13 -20
@@ -6,6 +6,7 @@* Author: Michael Brunner <[email protected]> */ +#include <linux/err.h> #include <linux/platform_device.h> #include <linux/mfd/core.h> #include <linux/mfd/kempld.h>
@@ -131,28 +132,20 @@ static struct platform_device *kempld_pdev;static int kempld_create_platform_device (const struct dmi_system_id *id) {const struct kempld_platform_data *pdata = id->driver_data; -int ret; +const struct platform_device_info pdevinfo = { + .name ="kempld" , + .id =PLATFORM_DEVID_NONE , + .res = pdata->ioresource, + .num_res =1 , + .data = pdata, + .size_data =sizeof (*pdata), + }; - kempld_pdev =platform_device_alloc ("kempld" ,-1 ); -if (!kempld_pdev) -return -ENOMEM ; - - ret =platform_device_add_data (kempld_pdev, pdata,sizeof (*pdata)); -if (ret) - goto err; - - ret =platform_device_add_resources (kempld_pdev, pdata->ioresource,1 ); -if (ret) - goto err; - - ret =platform_device_add (kempld_pdev); -if (ret) - goto err; + kempld_pdev =platform_device_register_full (&pdevinfo); +if (IS_ERR (kempld_pdev)) +return PTR_ERR (kempld_pdev);return 0 ; -err: -platform_device_put (kempld_pdev); -return ret; }/**
@@ -424,7 +417,7 @@ static int kempld_probe(struct platform_device *pdev)struct resource *ioport;int ret; -if (kempld_pdev ==NULL ) { +if (IS_ERR_OR_NULL (kempld_pdev)) {/* * No kempld_pdev device has been registered in kempld_init, * so we seem to be probing an ACPI platform device.
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 4/6 mfd: kempld: Use PLATFORM_DEVID_NONE instead of -1
In reply to Andy ShevchenkoUse the PLATFORM_DEVID_NONE constant instead of hard-coding -1 when creating a platform device.
No functional changes are intended.
--- drivers/mfd/kempld-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/kempld-core.c +1 -1
@@ -109,7 +109,7 @@ static int kempld_register_cells_generic(struct kempld_device_data *pld)if (pld->feature_mask &KEMPLD_FEATURE_MASK_UART ) devs[i++].name = kempld_dev_names[KEMPLD_UART ]; -return mfd_add_devices (pld->dev,-1 , devs, i,NULL ,0 ,NULL ); +return mfd_add_devices (pld->dev,PLATFORM_DEVID_NONE , devs, i,NULL ,0 ,NULL ); }static struct resource kempld_ioresource = {
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 6/6 mfd: kempld: Remove dead code
In reply to Andy Shevchenkoscnprintf() never returns negative value, drop the respective dead code.
--- drivers/mfd/kempld-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/kempld-core.c +2 -5
@@ -294,11 +294,8 @@ static int kempld_get_info(struct kempld_device_data *pld)else minor = (pld->info.minor -10 ) +'A' ; - ret =scnprintf (pld->info.version,sizeof (pld->info.version), -"P%X%c%c.%04X" , pld->info.number, major, minor, - pld->info.buildnr); -if (ret <0 ) -return ret; +scnprintf (pld->info.version,sizeof (pld->info.version),"P%X%c%c.%04X" , + pld->info.number, major, minor, pld->info.buildnr);return 0 ; }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 5/6 mfd: kempld: Drop duplicate NULL check in ->exit()
In reply to Andy ShevchenkoSince platform_device_unregister() is NULL-aware, we don't need to duplicate this check. Remove it and fold the rest of the code.
--- drivers/mfd/kempld-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mfd/kempld-core.c +1 -3
@@ -895,9 +895,7 @@ static int __init kempld_init(void) static void __exit kempld_exit(void) { -if (kempld_pdev) -platform_device_unregister (kempld_pdev); - +platform_device_unregister (kempld_pdev);platform_driver_unregister (&kempld_driver); }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Quoted 1 line · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Any comments?
(I assume the 6+ weeks in the mailing list is enough for all kind of CIs
to complain. But they hadn't AFAICS.)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Lee Jones
maintainerQuoted 7 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Any comments?
(I assume the 6+ weeks in the mailing list is enough for all kind of CIs
to complain. But they hadn't AFAICS.)
Not sure why these were dropped from my queue.
Likely another Mutt "feature".
Back in the queue.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 11 lines · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Andy Shevchenko (6):
mfd: kempld: Replace ACPI code with agnostic one
mfd: kempld: Use device core to create driver-specific device
attributes
mfd: kempld: Simplify device registration
mfd: kempld: UsePLATFORM_DEVID_NONEinstead of -1
mfd: kempld: Drop duplicate NULL check in ->exit()
mfd: kempld: Remove dead code
Quoted 1 line
[...]
Applied, thanks!
[1/6] mfd: kempld: Replace ACPI code with agnostic one
commit: 2757d27d24b6c92b2476caaceca1e2666b0945be
[2/6] mfd: kempld: Use device core to create driver-specific device attributes
commit: 28a8ad605b6b5819514467da6925b2e5b3f77c3e
[3/6] mfd: kempld: Simplify device registration
commit: 3f3f569bea415066618f9680278f26d341ddf23d
[4/6] mfd: kempld: Use PLATFORM_DEVID_NONE instead of -1
commit: c1a0b1194c5e0a5c2f027578439fdea009275bf9
[5/6] mfd: kempld: Drop duplicate NULL check in ->exit()
commit: bb42768bd22196976acb217d1748b37ea55f8f3a
[6/6] mfd: kempld: Remove dead code
commit: b89163d2e1235677f766895b596b3cd7447b69a3--
Lee Jones [李琼斯]
Quoted 4 lines · Lee Jones
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Quoted 8 lines
Quoted 4 lines
Any comments?
(I assume the 6+ weeks in the mailing list is enough for all kind of CIs
to complain. But they hadn't AFAICS.)Not sure why these were dropped from my queue.
Likely another Mutt "feature".
Hmm... Using mutt as well, but probably not in advanced way.
Quoted 1 line
Back in the queue.
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Lee Jones
maintainerQuoted 7 lines · Andy Shevchenko
Quoted 6 lines · Lee Jones
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Any comments?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
(I assume the 6+ weeks in the mailing list is enough for all kind of CIs
to complain. But they hadn't AFAICS.)Not sure why these were dropped from my queue.
Likely another Mutt "feature".
Hmm... Using mutt as well, but probably not in advanced way.
I use:
I flag-message toggle a message's 'important' flag
... to mark messages as requiring review.
Sometimes Mutt drops them for seemingly no reason. It's also not uncommon for me to fetch new mail or open Mutt to find 300 unread mails which I've already parsed. When that happens, all of the mails that I've previously flagged have also been (not so) helpfully unflagged!
It's just something that I've grown accustomed to.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 15 lines · Lee Jones
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Lee Jones
Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
Just a set of ad-hoc cleanups. No functional change intended.
Any comments?
(I assume the 6+ weeks in the mailing list is enough for all kind of CIs
to complain. But they hadn't AFAICS.)Not sure why these were dropped from my queue.
Likely another Mutt "feature".
Quoted 7 lines
Quoted 1 line
Hmm... Using mutt as well, but probably not in advanced way.
I use:
I flag-message toggle a message's 'important' flag
... to mark messages as requiring review.
I don't (yet?).
Quoted 6 lines
Sometimes Mutt drops them for seemingly no reason. It's also not uncommon for me to fetch new mail or open Mutt to find 300 unread mails which I've already parsed. When that happens, all of the mails that I've previously flagged have also been (not so) helpfully unflagged!
It's just something that I've grown accustomed to.
Okay, thanks for sharing your experience.
Signature · 2 lines
With Best Regards, Andy Shevchenko