linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups
@ 2020-01-22 16:46 Mika Westerberg
  2020-01-22 16:46 ` [PATCH 1/9] platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static Mika Westerberg
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

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(-)

-- 
2.24.1


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

* [PATCH 1/9] platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 2/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static Mika Westerberg
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

This function is not called outside of intel_pmc_ipc.c so we can make it
static instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/intel_pmc_ipc.h | 6 ------
 drivers/platform/x86/intel_pmc_ipc.c | 3 +--
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/intel_pmc_ipc.h b/arch/x86/include/asm/intel_pmc_ipc.h
index 9e7adcdbe031..3b2e8b461520 100644
--- a/arch/x86/include/asm/intel_pmc_ipc.h
+++ b/arch/x86/include/asm/intel_pmc_ipc.h
@@ -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
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 5c1da2bb1435..9229c7a16536 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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)
 {
-- 
2.24.1


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

* [PATCH 2/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
  2020-01-22 16:46 ` [PATCH 1/9] platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 3/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static Mika Westerberg
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

This function is not called outside of intel_pmc_ipc.c so we can make it
static instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/intel_pmc_ipc.h | 6 ------
 drivers/platform/x86/intel_pmc_ipc.c | 3 +--
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/intel_pmc_ipc.h b/arch/x86/include/asm/intel_pmc_ipc.h
index 3b2e8b461520..b4f804877651 100644
--- a/arch/x86/include/asm/intel_pmc_ipc.h
+++ b/arch/x86/include/asm/intel_pmc_ipc.h
@@ -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)
 {
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 9229c7a16536..53551f5474a7 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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
-- 
2.24.1


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

* [PATCH 3/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
  2020-01-22 16:46 ` [PATCH 1/9] platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static Mika Westerberg
  2020-01-22 16:46 ` [PATCH 2/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 4/9] platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write() Mika Westerberg
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

This function is not called outside of intel_pmc_ipc.c so we can make it
static instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/intel_pmc_ipc.h | 8 --------
 drivers/platform/x86/intel_pmc_ipc.c | 5 ++---
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/asm/intel_pmc_ipc.h b/arch/x86/include/asm/intel_pmc_ipc.h
index b4f804877651..966ff2171ff9 100644
--- a/arch/x86/include/asm/intel_pmc_ipc.h
+++ b/arch/x86/include/asm/intel_pmc_ipc.h
@@ -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)
 {
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 53551f5474a7..83f47df1c4a5 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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
-- 
2.24.1


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

* [PATCH 4/9] platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write()
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (2 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 3/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 5/9] platform/x86: intel_pmc_ipc: Drop ipc_data_readb() Mika Westerberg
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

These functions are not used anywhere so drop them completely.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/intel_pmc_ipc.h | 12 ------
 drivers/platform/x86/intel_pmc_ipc.c | 59 ----------------------------
 2 files changed, 71 deletions(-)

diff --git a/arch/x86/include/asm/intel_pmc_ipc.h b/arch/x86/include/asm/intel_pmc_ipc.h
index 966ff2171ff9..e6da1ce26256 100644
--- a/arch/x86/include/asm/intel_pmc_ipc.h
+++ b/arch/x86/include/asm/intel_pmc_ipc.h
@@ -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
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 83f47df1c4a5..677ed470e14e 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -210,35 +210,6 @@ static inline int is_gcr_valid(u32 offset)
 	return 0;
 }
 
-/**
- * intel_pmc_gcr_read() - Read a 32-bit PMC GCR register
- * @offset:	offset of GCR register from GCR address base
- * @data:	data pointer for storing the register output
- *
- * Reads the 32-bit PMC GCR register at given offset.
- *
- * Return:	negative value on error or 0 on success.
- */
-int intel_pmc_gcr_read(u32 offset, u32 *data)
-{
-	int ret;
-
-	spin_lock(&ipcdev.gcr_lock);
-
-	ret = is_gcr_valid(offset);
-	if (ret < 0) {
-		spin_unlock(&ipcdev.gcr_lock);
-		return ret;
-	}
-
-	*data = readl(ipcdev.gcr_mem_base + offset);
-
-	spin_unlock(&ipcdev.gcr_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(intel_pmc_gcr_read);
-
 /**
  * intel_pmc_gcr_read64() - Read a 64-bit PMC GCR register
  * @offset:	offset of GCR register from GCR address base
@@ -268,36 +239,6 @@ int intel_pmc_gcr_read64(u32 offset, u64 *data)
 }
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_read64);
 
-/**
- * intel_pmc_gcr_write() - Write PMC GCR register
- * @offset:	offset of GCR register from GCR address base
- * @data:	register update value
- *
- * Writes the PMC GCR register of given offset with given
- * value.
- *
- * Return:	negative value on error or 0 on success.
- */
-int intel_pmc_gcr_write(u32 offset, u32 data)
-{
-	int ret;
-
-	spin_lock(&ipcdev.gcr_lock);
-
-	ret = is_gcr_valid(offset);
-	if (ret < 0) {
-		spin_unlock(&ipcdev.gcr_lock);
-		return ret;
-	}
-
-	writel(data, ipcdev.gcr_mem_base + offset);
-
-	spin_unlock(&ipcdev.gcr_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(intel_pmc_gcr_write);
-
 /**
  * intel_pmc_gcr_update() - Update PMC GCR register bits
  * @offset:	offset of GCR register from GCR address base
-- 
2.24.1


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

* [PATCH 5/9] platform/x86: intel_pmc_ipc: Drop ipc_data_readb()
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (3 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 4/9] platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write() Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 6/9] platform/x86: intel_pmc_ipc: Get rid of unnecessary includes Mika Westerberg
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

This function is not used anywhere so drop it completely.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 677ed470e14e..83b106f66fa6 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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);
-- 
2.24.1


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

* [PATCH 6/9] platform/x86: intel_pmc_ipc: Get rid of unnecessary includes
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (4 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 5/9] platform/x86: intel_pmc_ipc: Drop ipc_data_readb() Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 7/9] platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes Mika Westerberg
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

There is no point including headers that are not needed in the driver so
drop them.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 83b106f66fa6..8527327d88c7 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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>
 
-- 
2.24.1


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

* [PATCH 7/9] platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (5 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 6/9] platform/x86: intel_pmc_ipc: Get rid of unnecessary includes Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 8/9] platform/x86: intel_pmc_ipc: Propagate error from kstrtoul() Mika Westerberg
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

This 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.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 8527327d88c7..b87036089a54 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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,
-- 
2.24.1


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

* [PATCH 8/9] platform/x86: intel_pmc_ipc: Propagate error from kstrtoul()
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (6 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 7/9] platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-22 16:46 ` [PATCH 9/9] platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups Mika Westerberg
  2020-01-23 12:31 ` [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Andy Shevchenko
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

kstrtoul() already returns negative error if the input was not valid so
return it directly.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index b87036089a54..7b180ead064a 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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;
-- 
2.24.1


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

* [PATCH 9/9] platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (7 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 8/9] platform/x86: intel_pmc_ipc: Propagate error from kstrtoul() Mika Westerberg
@ 2020-01-22 16:46 ` Mika Westerberg
  2020-01-23 12:31 ` [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Andy Shevchenko
  9 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2020-01-22 16:46 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	x86, Zha Qipeng, Greg Kroah-Hartman, Mika Westerberg,
	platform-driver-x86, linux-kernel

The 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.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 7b180ead064a..2433bf73f1ed 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -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,
 	},
 };
 
-- 
2.24.1


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

* Re: [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups
  2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
                   ` (8 preceding siblings ...)
  2020-01-22 16:46 ` [PATCH 9/9] platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups Mika Westerberg
@ 2020-01-23 12:31 ` Andy Shevchenko
  9 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2020-01-23 12:31 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Andy Shevchenko, Darren Hart, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Zha Qipeng, Greg Kroah-Hartman, Platform Driver,
	Linux Kernel Mailing List

On Wed, Jan 22, 2020 at 6:46 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> 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
>

Pushed to my review and testing queue, thanks!

> 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(-)
>
> --
> 2.24.1
>


-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2020-01-23 12:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22 16:46 [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Mika Westerberg
2020-01-22 16:46 ` [PATCH 1/9] platform/x86: intel_pmc_ipc: Make intel_pmc_gcr_update() static Mika Westerberg
2020-01-22 16:46 ` [PATCH 2/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_simple_command() static Mika Westerberg
2020-01-22 16:46 ` [PATCH 3/9] platform/x86: intel_pmc_ipc: Make intel_pmc_ipc_raw_cmd() static Mika Westerberg
2020-01-22 16:46 ` [PATCH 4/9] platform/x86: intel_pmc_ipc: Drop intel_pmc_gcr_read() and intel_pmc_gcr_write() Mika Westerberg
2020-01-22 16:46 ` [PATCH 5/9] platform/x86: intel_pmc_ipc: Drop ipc_data_readb() Mika Westerberg
2020-01-22 16:46 ` [PATCH 6/9] platform/x86: intel_pmc_ipc: Get rid of unnecessary includes Mika Westerberg
2020-01-22 16:46 ` [PATCH 7/9] platform/x86: intel_pmc_ipc: Use octal permissions in sysfs attributes Mika Westerberg
2020-01-22 16:46 ` [PATCH 8/9] platform/x86: intel_pmc_ipc: Propagate error from kstrtoul() Mika Westerberg
2020-01-22 16:46 ` [PATCH 9/9] platform/x86: intel_pmc_ipc: Switch to use driver->dev_groups Mika Westerberg
2020-01-23 12:31 ` [PATCH 0/9] platform/x86: intel_pmc_ipc: Cleanups Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).