platform/x86: intel_pmc_ipc: Cleanups
Subsystems (2)
cover platform/x86: intel_pmc_ipc: Cleanups
Hi,
This is another independent cleanup series that I split out from my SCU/PMC IPC rework patch set [1] as suggested by Greg. This removes code that is not used anywhere and makes certain functions static as they are not called outside of the driver. We also make the driver to use driver->dev_groups to expose sysfs attributes.
[1] https://lkml.org/lkml/2020/1/21/678
Mika Westerberg (9):
platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write() platform/x86: intel_pmc_ipc: Drop ipc_data_readb()
platform/x86: intel_pmc_ipc: Get rid of unnecessary includes platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes platform/x86: intel_pmc_ipc: Propagate error from kstrtoul() platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups
arch/x86/include/asm/intel_pmc_ipc.h | 32 -------- drivers/platform/x86/intel_pmc_ipc.c | 114 ++++----------------------- 2 files changed, 16 insertions(+), 130 deletions(-)
Signature · 1 line
2.24.1
PATCH 1/9 platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static
This function is not called outside of intel_pmc_ipc.c so we can make it static instead.
--- arch/x86/include/asm/intel_pmc_ipc.h | 6 ------ drivers/platform/x86/intel_pmc_ipc.c | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-)
arch/x86/include/asm/intel_pmc_ipc.h +0 -6
@@ -40,7 +40,6 @@ int intel_pmc_s0ix_counter_read(u64 *data);int intel_pmc_gcr_read (u32 offset,u32 *data);int intel_pmc_gcr_read64 (u32 offset,u64 *data);int intel_pmc_gcr_write (u32 offset,u32 data); -int intel_pmc_gcr_update (u32 offset,u32 mask,u32 val);#else
@@ -81,11 +80,6 @@ static inline int intel_pmc_gcr_write(u32 offset, u32 data)return -EINVAL ; } -static inline int intel_pmc_gcr_update (u32 offset,u32 mask,u32 val) -{ -return -EINVAL ; -} -#endif /*CONFIG_INTEL_PMC_IPC*/ #endif
drivers/platform/x86/intel_pmc_ipc.c +1 -2
@@ -309,7 +309,7 @@ EXPORT_SYMBOL_GPL(intel_pmc_gcr_write);* * Return: negative value on error or 0 on success. */ -int intel_pmc_gcr_update (u32 offset,u32 mask,u32 val) +static int intel_pmc_gcr_update (u32 offset,u32 mask,u32 val) {u32 new_val;int ret =0 ;
@@ -339,7 +339,6 @@ int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val)spin_unlock (&ipcdev.gcr_lock);return ret; } -EXPORT_SYMBOL_GPL (intel_pmc_gcr_update);static int update_no_reboot_bit (void *priv,bool set) {
Signature · 1 line
2.24.1
PATCH 2/9 platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static
In reply to Mika WesterbergThis function is not called outside of intel_pmc_ipc.c so we can make it static instead.
--- arch/x86/include/asm/intel_pmc_ipc.h | 6 ------ drivers/platform/x86/intel_pmc_ipc.c | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-)
arch/x86/include/asm/intel_pmc_ipc.h +0 -6
@@ -31,7 +31,6 @@#if IS_ENABLED (CONFIG_INTEL_PMC_IPC ) -int intel_pmc_ipc_simple_command (int cmd,int sub);int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out,u32 outlen,u32 dptr,u32 sptr); int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
@@ -43,11 +42,6 @@ int intel_pmc_gcr_write(u32 offset, u32 data);#else -static inline int intel_pmc_ipc_simple_command (int cmd,int sub) -{ -return -EINVAL ; -} -static inline int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out,u32 outlen,u32 dptr,u32 sptr) {
drivers/platform/x86/intel_pmc_ipc.c +1 -2
@@ -404,7 +404,7 @@ static int intel_pmc_ipc_check_status(void)* * Return: an IPC error code or 0 on success. */ -int intel_pmc_ipc_simple_command (int cmd,int sub) +static int intel_pmc_ipc_simple_command (int cmd,int sub) {int ret;
@@ -419,7 +419,6 @@ int intel_pmc_ipc_simple_command(int cmd, int sub)return ret; } -EXPORT_SYMBOL_GPL (intel_pmc_ipc_simple_command);/** * intel_pmc_ipc_raw_cmd() - IPC command with data and pointers
Signature · 1 line
2.24.1
PATCH 3/9 platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static
In reply to Mika WesterbergThis function is not called outside of intel_pmc_ipc.c so we can make it static instead.
--- arch/x86/include/asm/intel_pmc_ipc.h | 8 -------- drivers/platform/x86/intel_pmc_ipc.c | 5 ++--- 2 files changed, 2 insertions(+), 11 deletions(-)
arch/x86/include/asm/intel_pmc_ipc.h +0 -8
@@ -31,8 +31,6 @@#if IS_ENABLED (CONFIG_INTEL_PMC_IPC ) -int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen, -u32 *out,u32 outlen,u32 dptr,u32 sptr);int intel_pmc_ipc_command (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out,u32 outlen);int intel_pmc_s0ix_counter_read (u64 *data);
@@ -42,12 +40,6 @@ int intel_pmc_gcr_write(u32 offset, u32 data);#else -static inline int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen, -u32 *out,u32 outlen,u32 dptr,u32 sptr) -{ -return -EINVAL ; -} -static inline int intel_pmc_ipc_command (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out,u32 outlen) {
drivers/platform/x86/intel_pmc_ipc.c +2 -3
@@ -435,8 +435,8 @@ static int intel_pmc_ipc_simple_command(int cmd, int sub)* * Return: an IPC error code or 0 on success. */ -int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out, -u32 outlen,u32 dptr,u32 sptr) +static int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out, +u32 outlen,u32 dptr,u32 sptr) {u32 wbuf[4 ] = {0 };int ret;
@@ -468,7 +468,6 @@ int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out,return ret; } -EXPORT_SYMBOL_GPL (intel_pmc_ipc_raw_cmd);/** * intel_pmc_ipc_command() - IPC command with input/output data
Signature · 1 line
2.24.1
PATCH 4/9 platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write()
In reply to Mika WesterbergThese functions are not used anywhere so drop them completely.
--- arch/x86/include/asm/intel_pmc_ipc.h | 12 ------ drivers/platform/x86/intel_pmc_ipc.c | 59 ---------------------------- 2 files changed, 71 deletions(-)
arch/x86/include/asm/intel_pmc_ipc.h +0 -12
@@ -34,9 +34,7 @@int intel_pmc_ipc_command (u32 cmd,u32 sub,u8 *in,u32 inlen,u32 *out,u32 outlen);int intel_pmc_s0ix_counter_read (u64 *data); -int intel_pmc_gcr_read (u32 offset,u32 *data);int intel_pmc_gcr_read64 (u32 offset,u64 *data); -int intel_pmc_gcr_write (u32 offset,u32 data);#else
@@ -51,21 +49,11 @@ static inline int intel_pmc_s0ix_counter_read(u64 *data)return -EINVAL ; } -static inline int intel_pmc_gcr_read (u32 offset,u32 *data) -{ -return -EINVAL ; -} -static inline int intel_pmc_gcr_read64 (u32 offset,u64 *data) {return -EINVAL ; } -static inline int intel_pmc_gcr_write (u32 offset,u32 data) -{ -return -EINVAL ; -} -#endif /*CONFIG_INTEL_PMC_IPC*/ #endif
drivers/platform/x86/intel_pmc_ipc.c +0 -59
71 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 5/9 platform/x86: intel_pmc_ipc: Drop ipc_data_readb()
In reply to Mika WesterbergThis function is not used anywhere so drop it completely.
--- drivers/platform/x86/intel_pmc_ipc.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/platform/x86/intel_pmc_ipc.c +0 -5
@@ -184,11 +184,6 @@ static inline void ipc_data_writel(u32 data, u32 offset)writel (data, ipcdev.ipc_base +IPC_WRITE_BUFFER + offset); } -static inline u8 __maybe_unused ipc_data_readb (u32 offset) -{ -return readb (ipcdev.ipc_base +IPC_READ_BUFFER + offset); -} -static inline u32 ipc_data_readl (u32 offset) {return readl (ipcdev.ipc_base +IPC_READ_BUFFER + offset);
Signature · 1 line
2.24.1
PATCH 6/9 platform/x86: intel_pmc_ipc: Get rid of unnecessary includes
In reply to Mika WesterbergThere is no point including headers that are not needed in the driver so drop them.
--- drivers/platform/x86/intel_pmc_ipc.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/platform/x86/intel_pmc_ipc.c +0 -10
@@ -12,23 +12,13 @@*/ #include <linux/acpi.h> -#include <linux/atomic.h> -#include <linux/bitops.h> #include <linux/delay.h> -#include <linux/device.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/io-64-nonatomic-lo-hi.h> -#include <linux/kernel.h> #include <linux/module.h> -#include <linux/notifier.h> #include <linux/pci.h> #include <linux/platform_device.h> -#include <linux/pm.h> -#include <linux/pm_qos.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/suspend.h> #include <asm/intel_pmc_ipc.h>
Signature · 1 line
2.24.1
PATCH 7/9 platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes
In reply to Mika WesterbergThis is the current preferred way so replace the S_IWUSR with the corresponding octal value. While there move the attributes to follow directly their store functions.
--- drivers/platform/x86/intel_pmc_ipc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/platform/x86/intel_pmc_ipc.c +2 -5
@@ -502,6 +502,7 @@ static ssize_t intel_pmc_ipc_simple_cmd_store(struct device *dev, }return (ssize_t )count; } +static DEVICE_ATTR(simplecmd, 0200, NULL, intel_pmc_ipc_simple_cmd_store); static ssize_t intel_pmc_ipc_northpeak_store(struct device *dev, struct device_attribute *attr,
@@ -525,11 +526,7 @@ static ssize_t intel_pmc_ipc_northpeak_store(struct device *dev, }return (ssize_t )count; } - -static DEVICE_ATTR(simplecmd, S_IWUSR, - NULL, intel_pmc_ipc_simple_cmd_store); -static DEVICE_ATTR(northpeak, S_IWUSR, - NULL, intel_pmc_ipc_northpeak_store); +static DEVICE_ATTR(northpeak, 0200, NULL, intel_pmc_ipc_northpeak_store);static struct attribute *intel_ipc_attrs[] = { &dev_attr_northpeak.attr,
Signature · 1 line
2.24.1
PATCH 8/9 platform/x86: intel_pmc_ipc: Propagate error from kstrtoul()
In reply to Mika Westerbergkstrtoul() already returns negative error if the input was not valid so return it directly.
--- drivers/platform/x86/intel_pmc_ipc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/intel_pmc_ipc.c +3 -2
@@ -512,8 +512,9 @@ static ssize_t intel_pmc_ipc_northpeak_store(struct device *dev,int subcmd;int ret; -if (kstrtoul (buf,0 , &val)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &val); +if (ret) +return ret;if (val) subcmd =1 ;
Signature · 1 line
2.24.1
PATCH 9/9 platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups
In reply to Mika WesterbergThe driver core provides support for adding additional attributes for devices via new ->dev_groups member of struct device_driver. Convert the driver to use that instead of adding the attributes manually.
--- drivers/platform/x86/intel_pmc_ipc.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/platform/x86/intel_pmc_ipc.c +7 -10
@@ -539,6 +539,11 @@ static const struct attribute_group intel_ipc_group = { .attrs = intel_ipc_attrs, }; +static const struct attribute_group *intel_ipc_groups[] = { + &intel_ipc_group, +NULL +}; +static struct resource punit_res_array[] = {/* Punit BIOS */ {
@@ -879,18 +884,10 @@ static int ipc_plat_probe(struct platform_device *pdev) goto err_irq; } - ret =sysfs_create_group (&pdev->dev.kobj, &intel_ipc_group); -if (ret) { -dev_err (&pdev->dev,"Failed to create sysfs group %d\n" , - ret); - goto err_sys; - } - ipcdev.has_gcr_regs = true;return 0 ; -err_sys: -devm_free_irq (&pdev->dev, ipcdev.irq, &ipcdev); + err_irq:platform_device_unregister (ipcdev.tco_dev);platform_device_unregister (ipcdev.punit_dev);
@@ -901,7 +898,6 @@ static int ipc_plat_probe(struct platform_device *pdev)static int ipc_plat_remove (struct platform_device *pdev) { -sysfs_remove_group (&pdev->dev.kobj, &intel_ipc_group);devm_free_irq (&pdev->dev, ipcdev.irq, &ipcdev);platform_device_unregister (ipcdev.tco_dev);platform_device_unregister (ipcdev.punit_dev);
@@ -916,6 +912,7 @@ static struct platform_driver ipc_plat_driver = { .driver = { .name = "pmc-ipc-plat", .acpi_match_table = ACPI_PTR(ipc_acpi_ids), + .dev_groups = intel_ipc_groups, }, };
Signature · 1 line
2.24.1
Quoted 11 lines · Mika Westerberg
Hi,
This is another independent cleanup series that I split out from my SCU/PMC IPC rework patch set [1] as suggested by Greg. This removes code that is not used anywhere and makes certain functions static as they are not called outside of the driver. We also make the driver to use
driver->dev_groupsto expose sysfs attributes.
Pushed to my review and testing queue, thanks!
Quoted 18 lines
Mika Westerberg (9):
platform/x86:intel_pmc_ipc: Makeintel_pmc_gcr_update()static platform/x86:intel_pmc_ipc: Makeintel_pmc_ipc_simple_command()static platform/x86:intel_pmc_ipc: Makeintel_pmc_ipc_raw_cmd()static platform/x86:intel_pmc_ipc: Dropintel_pmc_gcr_read()andintel_pmc_gcr_write()platform/x86:intel_pmc_ipc: Dropipc_data_readb()
platform/x86:intel_pmc_ipc: Get rid of unnecessary includes platform/x86:intel_pmc_ipc: Use octal permissions in sysfs attributes platform/x86:intel_pmc_ipc: Propagate error fromkstrtoul()platform/x86:intel_pmc_ipc: Switch to usedriver->dev_groupsarch/x86/include/asm/intel_pmc_ipc.h | 32 -------- drivers/platform/x86/intel_pmc_ipc.c | 114 ++++----------------------- 2 files changed, 16 insertions(+), 130 deletions(-)--
2.24.1
Signature · 2 lines
With Best Regards, Andy Shevchenko