mfd: intel-lpss: Set of cleanups
Andy Shevchenko
reviewercover mfd: intel-lpss: Set of cleanups
After looking into the latest changes in the driver I noticed one wrong patch. That induced looking closer to the current state of affairs in the driver. It appears that some code is outdated and may be cleaned up. Hence this series.
Andy Shevchenko (5):
mfd: intel-lpss: Revert "Add missing check for platform_get_resource"
mfd: intel-lpss: Use device_get_match_data()
mfd: intel-lpss: Adjust header inclusions
mfd: intel-lpss: Move exported symbols to INTEL_LPSS namespace
mfd: intel-lpss: Provide Intel LPSS PM ops structure
drivers/mfd/intel-lpss-acpi.c | 27 ++++++++++++------------ drivers/mfd/intel-lpss-pci.c | 19 ++++++++++------- drivers/mfd/intel-lpss.c | 39 +++++++++++++++++++++-------------- drivers/mfd/intel-lpss.h | 28 +------------------------ 4 files changed, 51 insertions(+), 62 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH 1/5 mfd: intel-lpss: Revert "Add missing check for platform_get_resource"
This reverts commit d918e0d5824495a75d00b879118b098fcab36fdb.
The commit in question does not fix anything and only introduces a duplication in the code. The main intel_lpss_probe() performs all necessary checks.
While at it and in order of avoiding similar patches to come, add a comment.
--- drivers/mfd/intel-lpss-acpi.c | 4 +--- drivers/mfd/intel-lpss-pci.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/intel-lpss-acpi.c +1 -3
@@ -182,10 +182,8 @@ static int intel_lpss_acpi_probe(struct platform_device *pdev)if (!info)return -ENOMEM ; +/* No need to check mem and irq here as intel_lpss_probe() does it for us */ info->mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!info->mem) -return -ENODEV ; - info->irq =platform_get_irq (pdev,0 ); ret =intel_lpss_probe (&pdev->dev, info);
drivers/mfd/intel-lpss-pci.c +1 -0
@@ -46,6 +46,7 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev,if (!info)return -ENOMEM ; +/* No need to check mem and irq here as intel_lpss_probe() does it for us */ info->mem =pci_resource_n (pdev,0 ); info->irq =pci_irq_vector (pdev,0 );
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH 2/5 mfd: intel-lpss: Use device_get_match_data()
In reply to Andy ShevchenkoUse preferred device_get_match_data() instead of acpi_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers.
Introduce a temporary variable in PCI glue driver to be consistent with ACPI one on the same matter.
--- drivers/mfd/intel-lpss-acpi.c | 11 +++++------ drivers/mfd/intel-lpss-pci.c | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/mfd/intel-lpss-acpi.c +5 -6
@@ -8,9 +8,9 @@* Mika Westerberg <[email protected]> */ -#include <linux/acpi.h> #include <linux/ioport.h> #include <linux/kernel.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h>
@@ -169,16 +169,15 @@ MODULE_DEVICE_TABLE(acpi, intel_lpss_acpi_ids);static int intel_lpss_acpi_probe (struct platform_device *pdev) { +const struct intel_lpss_platform_info *data;struct intel_lpss_platform_info *info; -const struct acpi_device_id *id;int ret; - id =acpi_match_device (intel_lpss_acpi_ids, &pdev->dev); -if (!id) + data =device_get_match_data (&pdev->dev); +if (!data)return -ENODEV ; - info =devm_kmemdup (&pdev->dev, (void *)id->driver_data,sizeof (*info), -GFP_KERNEL ); + info =devm_kmemdup (&pdev->dev, data,sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
drivers/mfd/intel-lpss-pci.c +2 -2
@@ -30,6 +30,7 @@ static const struct pci_device_id ignore_resource_conflicts_ids[] = {static int intel_lpss_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +const struct intel_lpss_platform_info *data = (void *)id->driver_data;struct intel_lpss_platform_info *info;int ret;
@@ -41,8 +42,7 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev,if (ret)return ret; - info =devm_kmemdup (&pdev->dev, (void *)id->driver_data,sizeof (*info), -GFP_KERNEL ); + info =devm_kmemdup (&pdev->dev, data,sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH 3/5 mfd: intel-lpss: Adjust header inclusions
In reply to Andy ShevchenkoAdjust header inclusions to avoid "proxy" headers and explicitly include what we are using.
--- drivers/mfd/intel-lpss-acpi.c | 6 +++++- drivers/mfd/intel-lpss-pci.c | 8 ++++++-- drivers/mfd/intel-lpss.c | 17 ++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-)
drivers/mfd/intel-lpss-acpi.c +5 -1
@@ -8,15 +8,19 @@* Mika Westerberg <[email protected]> */ +#include <linux/device.h> +#include <linux/gfp_types.h> #include <linux/ioport.h> -#include <linux/kernel.h> #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h> #include <linux/property.h> +#include <linux/pxa2xx_ssp.h> +#include <asm/errno.h> +#include "intel-lpss.h" static const struct property_entry spt_spi_properties[] = {
drivers/mfd/intel-lpss-pci.c +6 -2
@@ -8,14 +8,18 @@* Mika Westerberg <[email protected]> */ -#include <linux/ioport.h> -#include <linux/kernel.h> +#include <linux/device.h> +#include <linux/gfp_types.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/pm_runtime.h> #include <linux/property.h> +#include <linux/pxa2xx_ssp.h> +#include <asm/errno.h> +#include "intel-lpss.h" /* Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources */
drivers/mfd/intel-lpss.c +12 -5
@@ -10,26 +10,33 @@* Jarkko Nikula <[email protected]> */ -#include <linux/clk.h> +#include <linux/array_size.h> +#include <linux/bits.h> #include <linux/clkdev.h> +#include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/debugfs.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/gfp_types.h> #include <linux/idr.h> #include <linux/io.h> #include <linux/ioport.h> -#include <linux/kernel.h> -#include <linux/module.h> #include <linux/mfd/core.h> +#include <linux/module.h> #include <linux/pm_qos.h> #include <linux/pm_runtime.h> -#include <linux/property.h> -#include <linux/seq_file.h> +#include <linux/sprintf.h> +#include <linux/types.h> +#include <linux/io-64-nonatomic-lo-hi.h> #include <linux/dma/idma64.h> #include "intel-lpss.h" +struct dentry ; +#define LPSS_DEV_OFFSET 0x000#define LPSS_DEV_SIZE 0x200#define LPSS_PRIV_OFFSET 0x200
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH 4/5 mfd: intel-lpss: Move exported symbols to INTEL_LPSS namespace
In reply to Andy ShevchenkoAvoid unnecessary pollution of the global symbol namespace by moving library functions in to a specific namespace and import that into the drivers that make use of the functions.
For more info: https://lwn.net/Articles/760045/
--- drivers/mfd/intel-lpss-acpi.c | 1 + drivers/mfd/intel-lpss-pci.c | 1 + drivers/mfd/intel-lpss.c | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/mfd/intel-lpss-acpi.c +1 -0
@@ -223,3 +223,4 @@ MODULE_AUTHOR("Andy Shevchenko <[email protected]>");MODULE_AUTHOR ("Mika Westerberg <[email protected]>" );MODULE_DESCRIPTION ("Intel LPSS ACPI driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (INTEL_LPSS );
drivers/mfd/intel-lpss-pci.c +1 -0
@@ -603,3 +603,4 @@ MODULE_AUTHOR("Andy Shevchenko <[email protected]>");MODULE_AUTHOR ("Mika Westerberg <[email protected]>" );MODULE_DESCRIPTION ("Intel LPSS PCI driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_IMPORT_NS (INTEL_LPSS );
drivers/mfd/intel-lpss.c +5 -5
@@ -456,7 +456,7 @@ int intel_lpss_probe(struct device *dev,return ret; } -EXPORT_SYMBOL_GPL (intel_lpss_probe); +EXPORT_SYMBOL_NS_GPL (intel_lpss_probe,INTEL_LPSS );void intel_lpss_remove (struct device *dev) {
@@ -468,7 +468,7 @@ void intel_lpss_remove(struct device *dev)intel_lpss_unregister_clock (lpss);ida_free (&intel_lpss_devid_ida, lpss->devid); } -EXPORT_SYMBOL_GPL (intel_lpss_remove); +EXPORT_SYMBOL_NS_GPL (intel_lpss_remove,INTEL_LPSS );#ifdef CONFIG_PM static int resume_lpss_device (struct device *dev,void *data)
@@ -488,7 +488,7 @@ int intel_lpss_prepare(struct device *dev)device_for_each_child_reverse (dev,NULL , resume_lpss_device);return 0 ; } -EXPORT_SYMBOL_GPL (intel_lpss_prepare); +EXPORT_SYMBOL_NS_GPL (intel_lpss_prepare,INTEL_LPSS );int intel_lpss_suspend (struct device *dev) {
@@ -509,7 +509,7 @@ int intel_lpss_suspend(struct device *dev)return 0 ; } -EXPORT_SYMBOL_GPL (intel_lpss_suspend); +EXPORT_SYMBOL_NS_GPL (intel_lpss_suspend,INTEL_LPSS );int intel_lpss_resume (struct device *dev) {
@@ -524,7 +524,7 @@ int intel_lpss_resume(struct device *dev) return 0; } -EXPORT_SYMBOL_GPL (intel_lpss_resume); +EXPORT_SYMBOL_NS_GPL (intel_lpss_resume,INTEL_LPSS );#endif static int __init intel_lpss_init (void )
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH 5/5 mfd: intel-lpss: Provide Intel LPSS PM ops structure
In reply to Andy ShevchenkoWith the help of EXPORT_NS_GPL_DEV_PM_OPS() and other *_PM_OPS() macros we may convert PM ops functions to become static. This also takes into account the PM configuration options such as CONFIG_PM and CONFIG_PM_SLEEP. This all removes a lot of ugly macros and ifdeffery in the driver.
--- drivers/mfd/intel-lpss-acpi.c | 5 ++--- drivers/mfd/intel-lpss-pci.c | 5 ++--- drivers/mfd/intel-lpss.c | 18 ++++++++++-------- drivers/mfd/intel-lpss.h | 28 +--------------------------- 4 files changed, 15 insertions(+), 41 deletions(-)
drivers/mfd/intel-lpss-acpi.c +2 -3
@@ -13,6 +13,7 @@#include <linux/ioport.h> #include <linux/mod_devicetable.h> #include <linux/module.h> +#include <linux/pm.h> #include <linux/pm_runtime.h> #include <linux/platform_device.h> #include <linux/property.h>
@@ -205,15 +206,13 @@ static void intel_lpss_acpi_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); } -static INTEL_LPSS_PM_OPS (intel_lpss_acpi_pm_ops); -static struct platform_driver intel_lpss_acpi_driver = { .probe = intel_lpss_acpi_probe, .remove_new = intel_lpss_acpi_remove, .driver = { .name ="intel-lpss" , .acpi_match_table = intel_lpss_acpi_ids, - .pm = &intel_lpss_acpi_pm_ops, + .pm =pm_ptr (&intel_lpss_pm_ops), }, };
drivers/mfd/intel-lpss-pci.c +2 -3
@@ -13,6 +13,7 @@#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/pm.h> #include <linux/pm_runtime.h> #include <linux/property.h>
@@ -81,8 +82,6 @@ static void intel_lpss_pci_remove(struct pci_dev *pdev)intel_lpss_remove (&pdev->dev); } -static INTEL_LPSS_PM_OPS (intel_lpss_pci_pm_ops); -static const struct property_entry spt_spi_properties[] = {PROPERTY_ENTRY_U32 ("intel,spi-pxa2xx-type" ,LPSS_SPT_SSP ), { }
@@ -593,7 +592,7 @@ static struct pci_driver intel_lpss_pci_driver = { .probe = intel_lpss_pci_probe, .remove = intel_lpss_pci_remove, .driver = { - .pm = &intel_lpss_pci_pm_ops, + .pm = pm_ptr(&intel_lpss_pm_ops), }, };
drivers/mfd/intel-lpss.c +10 -8
@@ -24,6 +24,7 @@#include <linux/ioport.h> #include <linux/mfd/core.h> #include <linux/module.h> +#include <linux/pm.h> #include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/sprintf.h>
@@ -470,7 +471,6 @@ void intel_lpss_remove(struct device *dev) }EXPORT_SYMBOL_NS_GPL (intel_lpss_remove,INTEL_LPSS ); -#ifdef CONFIG_PM static int resume_lpss_device (struct device *dev,void *data) {if (!dev_pm_test_driver_flags (dev,DPM_FLAG_SMART_SUSPEND ))
@@ -479,7 +479,7 @@ static int resume_lpss_device(struct device *dev, void *data)return 0 ; } -int intel_lpss_prepare (struct device *dev) +static int intel_lpss_prepare (struct device *dev) {/* * Resume both child devices before entering system sleep. This
@@ -488,9 +488,8 @@ int intel_lpss_prepare(struct device *dev)device_for_each_child_reverse (dev,NULL , resume_lpss_device);return 0 ; } -EXPORT_SYMBOL_NS_GPL (intel_lpss_prepare,INTEL_LPSS ); -int intel_lpss_suspend (struct device *dev) +static int intel_lpss_suspend (struct device *dev) {struct intel_lpss *lpss =dev_get_drvdata (dev);unsigned int i;
@@ -509,9 +508,8 @@ int intel_lpss_suspend(struct device *dev)return 0 ; } -EXPORT_SYMBOL_NS_GPL (intel_lpss_suspend,INTEL_LPSS ); -int intel_lpss_resume (struct device *dev) +static int intel_lpss_resume (struct device *dev) {struct intel_lpss *lpss =dev_get_drvdata (dev);unsigned int i;
@@ -524,8 +522,12 @@ int intel_lpss_resume(struct device *dev)return 0 ; } -EXPORT_SYMBOL_NS_GPL (intel_lpss_resume,INTEL_LPSS ); -#endif + +EXPORT_NS_GPL_DEV_PM_OPS(intel_lpss_pm_ops, INTEL_LPSS) = { + .prepare =pm_sleep_ptr (&intel_lpss_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume) +RUNTIME_PM_OPS (intel_lpss_suspend, intel_lpss_resume,NULL ) +};static int __init intel_lpss_init (void ) {
drivers/mfd/intel-lpss.h +1 -27
@@ -30,32 +30,6 @@ int intel_lpss_probe(struct device *dev, const struct intel_lpss_platform_info *info);void intel_lpss_remove (struct device *dev); -#ifdef CONFIG_PM -int intel_lpss_prepare (struct device *dev); -int intel_lpss_suspend (struct device *dev); -int intel_lpss_resume (struct device *dev); - -#ifdef CONFIG_PM_SLEEP -#define INTEL_LPSS_SLEEP_PM_OPS \ - .prepare = intel_lpss_prepare, \ - SET_LATE_SYSTEM_SLEEP_PM_OPS(intel_lpss_suspend, intel_lpss_resume) -#else -#define INTEL_LPSS_SLEEP_PM_OPS -#endif - -#define INTEL_LPSS_RUNTIME_PM_OPS \ - .runtime_suspend = intel_lpss_suspend, \ - .runtime_resume = intel_lpss_resume, - -#else /* !CONFIG_PM */ -#define INTEL_LPSS_SLEEP_PM_OPS -#define INTEL_LPSS_RUNTIME_PM_OPS -#endif /* CONFIG_PM */ - -#define INTEL_LPSS_PM_OPS (name) \ -const struct dev_pm_ops name = { \ - INTEL_LPSS_SLEEP_PM_OPS \ - INTEL_LPSS_RUNTIME_PM_OPS \ -} +extern const struct dev_pm_ops intel_lpss_pm_ops;#endif /* __MFD_INTEL_LPSS_H */
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Quoted 5 lines · Andy Shevchenko
After looking into the latest changes in the driver I noticed one wrong patch. That induced looking closer to the current state of affairs in the driver. It appears that some code is outdated and may be cleaned up. Hence this series.
Quoted 8 lines
Andy Shevchenko (5):
mfd: intel-lpss: Revert "Add missing check forplatform_get_resource"
mfd: intel-lpss: Usedevice_get_match_data()
mfd: intel-lpss: Adjust header inclusions
mfd: intel-lpss: Move exported symbols toINTEL_LPSSnamespace
mfd: intel-lpss: Provide Intel LPSS PM ops structure[...]
Applied, thanks!
[1/5] mfd: intel-lpss: Revert "Add missing check for platform_get_resource"
commit: ad85d36c6770f21d961f5e5e47dc25f56d50c96e
[2/5] mfd: intel-lpss: Use device_get_match_data()
commit: 403c475743959f787156fc2120c1e5c557f8357d
[3/5] mfd: intel-lpss: Adjust header inclusions
commit: 62b2a4b3fb4922cb5201ff3787efd84186b0699c
[4/5] mfd: intel-lpss: Move exported symbols to INTEL_LPSS namespace
commit: 2221afc08e16bf0cbc5234107cc5c9edb850e0bb
[5/5] mfd: intel-lpss: Provide Intel LPSS PM ops structure
commit: 41e15f246791772c312caa8662368191d5b7289a--
Lee Jones [李琼斯]