platform/x86/intel_pmc_core: Convert to DEFINE_DEBUGFS_ATTRIBUTE
PATCH 1/1 platform/x86/intel_pmc_core: Convert to DEFINE_DEBUGFS_ATTRIBUTE
This patch does the following:
- refactors code to use recently introduced DEFINE_DEBUGFS_ATTRIBUTE() macro
- makes absence of DEBUG_FS non-fatal error
--- drivers/platform/x86/intel_pmc_core.c | 45 ++++++++--------------------------- drivers/platform/x86/intel_pmc_core.h | 5 ++-- 2 files changed, 13 insertions(+), 37 deletions(-)
drivers/platform/x86/intel_pmc_core.c +10 -35
@@ -23,7 +23,6 @@#include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> -#include <linux/seq_file.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h>
@@ -78,30 +77,18 @@ int intel_pmc_slp_s0_counter_read(u32 *data) }EXPORT_SYMBOL_GPL (intel_pmc_slp_s0_counter_read); -#if IS_ENABLED (CONFIG_DEBUG_FS ) -static int pmc_core_dev_state_show (struct seq_file *s,void *unused) +static int pmc_core_dev_state_get (void *data,u64 *val) { -struct pmc_dev *pmcdev = s->private; -u32 counter_val; +struct pmc_dev *pmcdev = data; +u32 value; - counter_val =pmc_core_reg_read (pmcdev, -SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); -seq_printf (s,"%u\n" ,pmc_core_adjust_slp_s0_step (counter_val)); + value =pmc_core_reg_read (pmcdev,SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); + *val =pmc_core_adjust_slp_s0_step (value);return 0 ; } -static int pmc_core_dev_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_dev_state_show, inode->i_private); -} - -static const struct file_operations pmc_core_dev_state_ops = { - .open = pmc_core_dev_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_DEBUGFS_ATTRIBUTE (pmc_core_dev_state, pmc_core_dev_state_get,NULL ,"%llu" );static void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) {
@@ -113,12 +100,12 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)struct dentry *dir, *file; dir =debugfs_create_dir ("pmc_core" ,NULL ); -if (!dir) +if (IS_ERR_OR_NULL (dir))return -ENOMEM ; pmcdev->dbgfs_dir = dir; file =debugfs_create_file ("slp_s0_residency_usec" ,S_IFREG |S_IRUGO , - dir, pmcdev, &pmc_core_dev_state_ops); + dir, pmcdev, &pmc_core_dev_state);if (!file) {pmc_core_dbgfs_unregister (pmcdev);
@@ -127,16 +114,6 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)return 0 ; } -#else -static inline int pmc_core_dbgfs_register (struct pmc_dev *pmcdev) -{ -return 0 ; -} - -static inline void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) -{ -} -#endif /* CONFIG_DEBUG_FS */ static const struct x86_cpu_id intel_pmc_core_ids[] = { {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_SKYLAKE_MOBILE ,X86_FEATURE_MWAIT ,
@@ -183,10 +160,8 @@ static int pmc_core_probe(struct pci_dev *dev, const struct pci_device_id *id) } err =pmc_core_dbgfs_register (pmcdev); -if (err <0 ) { -dev_err (&dev->dev,"PMC Core: debugfs register failed.\n" ); -return err; - } +if (err <0 ) +dev_warn (&dev->dev,"PMC Core: debugfs register failed.\n" ); pmc.has_slp_s0_res = true;return 0 ;
drivers/platform/x86/intel_pmc_core.h +3 -2
@@ -23,11 +23,14 @@/* Sunrise Point Power Management Controller PCI Device ID */ #define SPT_PMC_PCI_DEVICE_ID 0x9d21 +#define SPT_PMC_BASE_ADDR_OFFSET 0x48#define SPT_PMC_SLP_S0_RES_COUNTER_OFFSET 0x13c#define SPT_PMC_MMIO_REG_LEN 0x100#define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 +struct dentry ; +/** * struct pmc_dev - pmc device structure * @base_addr: comtains pmc base address
@@ -42,9 +45,7 @@struct pmc_dev {u32 base_addr;void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS )struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */ bool has_slp_s0_res; };
Signature · 1 line
2.8.1
On Mon, Jun 13, 2016 at 08:56:49PM +0300, Andy Shevchenko wrote:
Sorry for the late reply. I compiled/tested this on linux-next on a Skylake system and it looks ok to me except for a couple of minor comments.
Quoted 23 lines
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorSigned-off-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel_pmc_core.c | 45 ++++++++--------------------------- drivers/platform/x86/intel_pmc_core.h | 5 ++-- 2 files changed, 13 insertions(+), 37 deletions(-)drivers/platform/x86/intel_pmc_core.c +0
-1@@ -23,7 +23,6 @@#include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> -#include <linux/seq_file.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h>
drivers/platform/x86/intel_pmc_core.c int intel_pmc_slp_s0_counter_read(u32 *data) · line 82
Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c +2
-4@@ -78,30 +77,18 @@ int intel_pmc_slp_s0_counter_read(u32 *data) }EXPORT_SYMBOL_GPL (intel_pmc_slp_s0_counter_read); -#if IS_ENABLED (CONFIG_DEBUG_FS ) -static int pmc_core_dev_state_show (struct seq_file *s,void *unused) +static int pmc_core_dev_state_get (void *data,u64 *val) { -struct pmc_dev *pmcdev = s->private; -u32 counter_val; +struct pmc_dev *pmcdev = data;
I am hoping that data being passed here is similar to inode.i_private so that we get the address of pmc struct here.
Quoted 27 lines
drivers/platform/x86/intel_pmc_core.c +4
-14+u32 value; - counter_val =pmc_core_reg_read (pmcdev, -SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); -seq_printf (s,"%u\n" ,pmc_core_adjust_slp_s0_step (counter_val)); + value =pmc_core_reg_read (pmcdev,SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); + *val =pmc_core_adjust_slp_s0_step (value);return 0 ; } -static int pmc_core_dev_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_dev_state_show, inode->i_private); -} - -static const struct file_operations pmc_core_dev_state_ops = { - .open = pmc_core_dev_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_DEBUGFS_ATTRIBUTE (pmc_core_dev_state, pmc_core_dev_state_get,NULL ,"%llu" );static void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) {
drivers/platform/x86/intel_pmc_core.c static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev) · line 107
Quoted 9 lines
drivers/platform/x86/intel_pmc_core.c +1
-1@@ -113,12 +100,12 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)struct dentry *dir, *file; dir =debugfs_create_dir ("pmc_core" ,NULL ); -if (!dir) +if (IS_ERR_OR_NULL (dir))return -ENOMEM ; pmcdev->dbgfs_dir = dir; file = debugfs_create_file("slp_s0_residency_usec", S_IFREG | S_IRUGO,
Should we consider using debugfs_create_file_unsafe ?
Quoted 67 lines
drivers/platform/x86/intel_pmc_core.c +3
-15- dir, pmcdev, &pmc_core_dev_state_ops); + dir, pmcdev, &pmc_core_dev_state);if (!file) {pmc_core_dbgfs_unregister (pmcdev);@@ -127,16 +114,6 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)return 0 ; } -#else -static inline int pmc_core_dbgfs_register (struct pmc_dev *pmcdev) -{ -return 0 ; -} - -static inline void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) -{ -} -#endif /* CONFIG_DEBUG_FS */ static const struct x86_cpu_id intel_pmc_core_ids[] = { {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_SKYLAKE_MOBILE ,X86_FEATURE_MWAIT ,@@ -183,10 +160,8 @@ static int pmc_core_probe(struct pci_dev *dev, const struct pci_device_id *id) } err =pmc_core_dbgfs_register (pmcdev); -if (err <0 ) { -dev_err (&dev->dev,"PMC Core: debugfs register failed.\n" ); -return err; - } +if (err <0 ) +dev_warn (&dev->dev,"PMC Core: debugfs register failed.\n" ); pmc.has_slp_s0_res = true;return 0 ;drivers/platform/x86/intel_pmc_core.h +3
-2@@ -23,11 +23,14 @@/* Sunrise Point Power Management Controller PCI Device ID */ #define SPT_PMC_PCI_DEVICE_ID 0x9d21 +#define SPT_PMC_BASE_ADDR_OFFSET 0x48#define SPT_PMC_SLP_S0_RES_COUNTER_OFFSET 0x13c#define SPT_PMC_MMIO_REG_LEN 0x100#define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 +struct dentry ; +/** * struct pmc_dev - pmc device structure * @base_addr: comtains pmc base address @@ -42,9 +45,7 @@struct pmc_dev {u32 base_addr;void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS )struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */ bool has_slp_s0_res; };Signature · 1 line
2.8.1
Signature · 2 lines
Best Regards, Rajneesh
Quoted 6 lines · Rajneesh Bhardwaj
On Mon, Jun 13, 2016 at 08:56:49PM +0300, Andy Shevchenko wrote:
Sorry for the late reply. I compiled/tested this on linux-next on a Skylake
system and it looks ok to me except for a couple of minor comments.
Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c int intel_pmc_slp_s0_counter_read(u32 *data) · line 82
Quoted 5 lines
+static int
pmc_core_dev_state_get(void *data, u64 *val){drivers/platform/x86/intel_pmc_core.c +1
-2-struct pmc_dev *pmcdev = s->private; -u32 counter_val; +struct pmc_dev *pmcdev = data;I am hoping that data being passed here is similar to inode.i_private so that we get the address of pmc struct here.
Yes, I went through the debugfs support code to be sure.
Quoted 8 lines
Quoted 6 lines
+DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state,
pmc_core_dev_state_get, NULL, "%llu");
pmcdev->dbgfs_dir= dir;
file = debugfs_create_file("slp_s0_residency_usec",S_IFREG|S_IRUGO,Should we consider using
debugfs_create_file_unsafe?
But why? I would choose safest option among others if there is no strong objection and explanation.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 31 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorSigned-off-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel_pmc_core.c | 45 ++++++++--------------------------- drivers/platform/x86/intel_pmc_core.h | 5 ++-- 2 files changed, 13 insertions(+), 37 deletions(-)drivers/platform/x86/intel_pmc_core.c +1
-4@@ -23,7 +23,6 @@#include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> -#include <linux/seq_file.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h> @@ -78,30 +77,18 @@ int intel_pmc_slp_s0_counter_read(u32 *data) }EXPORT_SYMBOL_GPL (intel_pmc_slp_s0_counter_read); -#if IS_ENABLED (CONFIG_DEBUG_FS ) -static int pmc_core_dev_state_show (struct seq_file *s,void *unused) +static int pmc_core_dev_state_get (void *data,u64 *val) { -struct pmc_dev *pmcdev = s->private;
drivers/platform/x86/intel_pmc_core.c int intel_pmc_slp_s0_counter_read(u32 *data) · line 87
Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c +4
-4-u32 counter_val; +struct pmc_dev *pmcdev = data; +u32 value; - counter_val =pmc_core_reg_read (pmcdev, -SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); -seq_printf (s,"%u\n" ,pmc_core_adjust_slp_s0_step (counter_val)); + value =pmc_core_reg_read (pmcdev,SPT_PMC_SLP_S0_RES_COUNTER_OFFSET ); + *val =pmc_core_adjust_slp_s0_step (value);
We were ensuring a new line for printing the output value with seq_printf whereas in this case the output is printed along with the shell prompt. Sometimes this could be harder to read.
Quoted 69 lines
drivers/platform/x86/intel_pmc_core.c +5
-27return 0 ; } -static int pmc_core_dev_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_dev_state_show, inode->i_private); -} - -static const struct file_operations pmc_core_dev_state_ops = { - .open = pmc_core_dev_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_DEBUGFS_ATTRIBUTE (pmc_core_dev_state, pmc_core_dev_state_get,NULL ,"%llu" );static void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) {@@ -113,12 +100,12 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)struct dentry *dir, *file; dir =debugfs_create_dir ("pmc_core" ,NULL ); -if (!dir) +if (IS_ERR_OR_NULL (dir))return -ENOMEM ; pmcdev->dbgfs_dir = dir; file =debugfs_create_file ("slp_s0_residency_usec" ,S_IFREG |S_IRUGO , - dir, pmcdev, &pmc_core_dev_state_ops); + dir, pmcdev, &pmc_core_dev_state);if (!file) {pmc_core_dbgfs_unregister (pmcdev);@@ -127,16 +114,6 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)return 0 ; } -#else -static inline int pmc_core_dbgfs_register (struct pmc_dev *pmcdev) -{ -return 0 ; -} - -static inline void pmc_core_dbgfs_unregister (struct pmc_dev *pmcdev) -{ -} -#endif /* CONFIG_DEBUG_FS */ static const struct x86_cpu_id intel_pmc_core_ids[] = { {X86_VENDOR_INTEL ,6 ,INTEL_FAM6_SKYLAKE_MOBILE ,X86_FEATURE_MWAIT ,@@ -183,10 +160,8 @@ static int pmc_core_probe(struct pci_dev *dev, const struct pci_device_id *id) } err =pmc_core_dbgfs_register (pmcdev); -if (err <0 ) { -dev_err (&dev->dev,"PMC Core: debugfs register failed.\n" ); -return err; - } +if (err <0 ) +dev_warn (&dev->dev,"PMC Core: debugfs register failed.\n" ); pmc.has_slp_s0_res = true;return 0 ;drivers/platform/x86/intel_pmc_core.h +0
-0@@ -23,11 +23,14 @@
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 10 lines
drivers/platform/x86/intel_pmc_core.h +3
-0/* Sunrise Point Power Management Controller PCI Device ID */ #define SPT_PMC_PCI_DEVICE_ID 0x9d21 +#define SPT_PMC_BASE_ADDR_OFFSET 0x48#define SPT_PMC_SLP_S0_RES_COUNTER_OFFSET 0x13c#define SPT_PMC_MMIO_REG_LEN 0x100#define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 +struct dentry ; +
Why do we need this ?
Quoted 16 lines
drivers/platform/x86/intel_pmc_core.h +0
-2/** * struct pmc_dev - pmc device structure * @base_addr: comtains pmc base address @@ -42,9 +45,7 @@struct pmc_dev {u32 base_addr;void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS )struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */ bool has_slp_s0_res; };Signature · 1 line
2.8.1
Signature · 2 lines
Best Regards, Rajneesh
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal error
Quoted 15 lines
Quoted 9 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);
(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.
This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
Quoted 5 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
Quoted 11 lines
Quoted 11 lines
/**
* structpmc_dev- pmc device structure
* @base_addr: comtains pmc base addressdrivers/platform/x86/intel_pmc_core.h +0
-2@@ -42,9 +45,7 @@ struct pmc_dev { u32 base_addr; void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS ) struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 24 lines · Andy Shevchenko
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorQuoted 15 lines
Quoted 9 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);
(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.
Quoted 9 lines
This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
While this is good for simple attributes i see a potential issue with this approch when we want to display multiple attributes for a single debugfs entry. We typically use seq_printf in a loop and display multiline output for a single debugfs entry. How do we go about the scenarios where we want to display formatted multiline debug information?
Quoted 8 lines
Quoted 5 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
I think we can omit this line if we chose to take this approach.
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
/**
* structpmc_dev- pmc device structure
* @base_addr: comtains pmc base addressdrivers/platform/x86/intel_pmc_core.h +0
-2@@ -42,9 +45,7 @@ struct pmc_dev { u32 base_addr; void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS ) struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */ Signature · 6 lines
Andy Shevchenko <[email protected]> Intel Finland Oy -- To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards, Rajneesh
Quoted 37 lines · Rajneesh Bhardwaj
Quoted 31 lines · Andy Shevchenko
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorQuoted 16 lines
Quoted 10 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUN
TER_
OFFSET);(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes
under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.Quoted 4 lines
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
Quoted 9 lines
While this is good for simple attributes i see a potential issue with this
approch when we want to display multiple attributes for a single debugfs
entry.
We typically useseq_printfin a loop and display multiline output
for a single debugfs entry. How do we go about the scenarios where we want
to display formatted multiline debug information?
We are talking about abstract case or is it change coming to this very driver?
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
I think we can omit this line if we chose to take this approach.
Yeah, it does not produce a warning on new compilers, though I think Darren can share his opinion.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 48 lines · Andy Shevchenko
Quoted 37 lines · Rajneesh Bhardwaj
Quoted 31 lines · Andy Shevchenko
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorQuoted 16 lines
Quoted 10 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUN
TER_
OFFSET);(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes
under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.Quoted 4 lines
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
Quoted 9 lines
While this is good for simple attributes i see a potential issue with this
approch when we want to display multiple attributes for a single debugfs
entry.
We typically useseq_printfin a loop and display multiline output
for a single debugfs entry. How do we go about the scenarios where we want
to display formatted multiline debug information?
Quoted 3 lines
We are talking about abstract case or is it change coming to this very driver?
We will be sending few patches for this very driver shortly and one such feature would require multiline formatted output for a single debugfs entry.
Can we have seq_printf for such cases and use DEFINE_DEBUGFS_ATTRIBUTE for other simple attributes? Doing this might raise some coding style consistency concerns though so lets wait to hear Darren's opinion on this patch.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Since we are using pointer to undefined type.
I think we can omit this line if we chose to take this approach.
Yeah, it does not produce a warning on new compilers, though I think Darren can share his opinion.
Sure.
Quoted 5 lines
Signature · 4 lines
-- Andy Shevchenko <[email protected]> Intel Finland Oy
i> --
Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards, Rajneesh
Quoted 22 lines · Rajneesh Bhardwaj
Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Rajneesh Bhardwaj
On Tue, Jun 28, 2016 at 01:05:07PM +0300, Andy Shevchenko wrote:
While this is good for simple attributes i see a potential issue with
this
approch when we want to display multiple attributes for a single debugfs
entry.
We typically useseq_printfin a loop and display multiline output
for a single debugfs entry. How do we go about the scenarios where we
want
to display formatted multiline debug information?Quoted 4 lines
We are talking about abstract case or is it change coming to this very
driver?
Quoted 4 lines
We will be sending few patches for this very driver shortly and one such
feature would require multiline formatted output for a single debugfs entry.
If it touches the same attribute it needs to be seen first before applying this one.
Quoted 6 lines
Can we have
seq_printffor such cases and useDEFINE_DEBUGFS_ATTRIBUTEfor
other simple attributes? Doing this might raise some coding style consistency
concerns though so lets wait to hear Darren's opinion on this patch.
For the rest we have to see the implementation and decide how to proceed (since it's a debugfs dedicated for _debugging_) we might change it in the way we like. Though I don't encourage people to do this. I like interfaces on which people thought before implementing.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 23 lines · Andy Shevchenko
Quoted 22 lines · Rajneesh Bhardwaj
Quoted 20 lines · Andy Shevchenko
Quoted 14 lines · Rajneesh Bhardwaj
On Tue, Jun 28, 2016 at 01:05:07PM +0300, Andy Shevchenko wrote:
While this is good for simple attributes i see a potential issue with
this
approch when we want to display multiple attributes for a single debugfs
entry.
We typically useseq_printfin a loop and display multiline output
for a single debugfs entry. How do we go about the scenarios where we
want
to display formatted multiline debug information?We are talking about abstract case or is it change coming to this very
driver?
Quoted 8 lines
Quoted 4 lines
We will be sending few patches for this very driver shortly and one such
feature would require multiline formatted output for a single debugfs entry.If it touches the same attribute it needs to be seen first before applying this one.
No, this attribute wont be touched.
Quoted 7 lines
Quoted 6 lines
Can we have
seq_printffor such cases and useDEFINE_DEBUGFS_ATTRIBUTEfor
other simple attributes? Doing this might raise some coding style consistency
concerns though so lets wait to hear Darren's opinion on this patch.
Quoted 5 lines
For the rest we have to see the implementation and decide how to proceed (since it's a debugfs dedicated for _debugging_) we might change it in the way we like. Though I don't encourage people to do this. I like interfaces on which people thought before implementing.
Sure, i am fine with DEFINE_DEBUGFS_ATTRIBUTE but would like to leave the scope for having seq_printf for future patches i.e. linux/seq_file.h and thus would have a dependency on struct file_operations for seq_read.
Quoted 4 lines
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 2 lines
Best Regards, Rajneesh
Quoted 10 lines · Rajneesh Bhardwaj
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Rajneesh Bhardwaj
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Rajneesh Bhardwaj
On Tue, Jun 28, 2016 at 01:05:07PM +0300, Andy Shevchenko wrote:
Quoted 5 lines
Quoted 3 lines
If it touches the same attribute it needs to be seen first before applying this one.
No, this attribute wont be touched.
So, if there is no objections (taking into consideration minors you mentioned) I think the patch can be applied.
Quoted 16 lines
Can we have
seq_printffor such cases and useQuoted 7 lines
Quoted 6 lines
DEFINE_DEBUGFS_ATTRIBUTE
for
other simple attributes? Doing this might raise some coding style consistency
concerns though so lets wait to hear Darren's opinion on this patch.Quoted 7 lines
For the rest we have to see the implementation and decide how to proceed
(since it's a debugfs dedicated for _debugging_) we might change it in
the way we like. Though I don't encourage people to do this. I like interfaces on which people thought before implementing.
Quoted 5 lines
Sure, i am fine with
DEFINE_DEBUGFS_ATTRIBUTEbut would like to leave the scope
for havingseq_printffor future patches i.e.linux/seq_file.hand thus would
have a dependency on structfile_operationsforseq_read.
Of course! No-one is insisting to use only the macro and simple attributes.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 36 lines · Andy Shevchenko
Quoted 10 lines · Rajneesh Bhardwaj
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Rajneesh Bhardwaj
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Rajneesh Bhardwaj
On Tue, Jun 28, 2016 at 01:05:07PM +0300, Andy Shevchenko wrote:
Quoted 5 lines
Quoted 3 lines
If it touches the same attribute it needs to be seen first before applying this one.
No, this attribute wont be touched.
So, if there is no objections (taking into consideration minors you mentioned) I think the patch can be applied.
Quoted 16 lines
Can we have
seq_printffor such cases and useQuoted 14 lines
Quoted 6 lines
DEFINE_DEBUGFS_ATTRIBUTE
for
other simple attributes? Doing this might raise some coding style consistency
concerns though so lets wait to hear Darren's opinion on this patch.For the rest we have to see the implementation and decide how to proceed
(since it's a debugfs dedicated for _debugging_) we might change it in
the way we like. Though I don't encourage people to do this. I like interfaces on which people thought before implementing.
Quoted 8 lines
Quoted 5 lines
Sure, i am fine with
DEFINE_DEBUGFS_ATTRIBUTEbut would like to leave the scope
for havingseq_printffor future patches i.e.linux/seq_file.hand thus would
have a dependency on structfile_operationsforseq_read.Of course! No-one is insisting to use only the macro and simple attributes.
Agreed. I do wonder if some of the newer debugfs types like array and regset would be sufficient for your needs. Whenever you can reuse an abstraction of the subsystem through higher level interfaces, I encourage you to do so as it reduces code size and potential programming errors.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 4 lines
So, if there is no objections (taking into consideration minors you mentioned) I think the patch can be applied.
I think we still need to address a couple of minor issues and might need a version 2 of this patch. In case we want to apply this one here is one patch that can applied on top of this one. Please see the proposed changes below.
From 42d899968c8c07f103390fcaebdaf2ba54cb3363 Mon Sep 17 00:00:00 2001
From: Rajneesh Bhardwaj <[email protected]>
Date: Mon, 4 Jul 2016 16:22:31 +0530
Subject: [PATCH] platform/x86/intel_pmc_core: Enhances debugfs attribute patch
Refines "convert to DEFINE_DEBUGFS_ATTRIBUTE" patch for PMC Core.
This change can be applied over the Convert to DEFINE_DEBUGFS_ATTRIBUTE patch sent by Andy Shevchenko to the platform drivers mailing list. This helps preserve usage of seq_file.h in the pmc_core driver. This also caters to some minor cosmetic changes suggested during the code review process.
--- drivers/platform/x86/intel_pmc_core.c | 4 +++- drivers/platform/x86/intel_pmc_core.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0
b/drivers/platform/x86/intel_pmc_core.c
index c29f59b..18af49f 100644
drivers/platform/x86/intel_pmc_core.c +1 -1
@@ -23,6 +23,7 @@#include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> +#include <linux/seq_file.h> #include <asm/cpu_device_id.h> #include <asm/intel-family.h>
@@ -88,7 +89,8 @@ static int pmc_core_dev_state_get(void *data, u64 *val)return 0 ; } -DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get, NULL,
"%llu");
+DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get, NULL,
+ "%llu\n");
static void pmc_core_dbgfs_unregister(struct pmc_dev *pmcdev) {
(quoted diff) +0 -0
b/drivers/platform/x86/intel_pmc_core.h
index 9689b92..6265480 100644
drivers/platform/x86/intel_pmc_core.h +0 -1
@@ -29,7 +29,6 @@#define SPT_PMC_MMIO_REG_LEN 0x100#define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 -struct dentry ;/** * struct pmc_dev - pmc device structure
--
1.9.1
Quoted 4 lines
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 2 lines
Best Regards, Rajneesh
drivers/platform/x86/intel_pmc_core.c line 26
Quoted 13 lines · Rajneesh Bhardwaj
Quoted 5 lines
So, if there is no objections (taking into consideration minors you mentioned) I think the patch can be applied.
drivers/platform/x86/intel_pmc_core.c +1
-0@@ -23,6 +23,7 @@ #include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> +#include <linux/seq_file.h>
What is this for?
Quoted 12 lines
drivers/platform/x86/intel_pmc_core.c +1
-1#include <asm/cpu_device_id.h> #include <asm/intel-family.h>@@ -88,7 +89,8 @@ static int pmc_core_dev_state_get(void *data, u64 *val) return 0; } -DEFINE_DEBUGFS_ATTRIBUTE (pmc_core_dev_state, pmc_core_dev_state_get,NULL , "%llu"); +DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get,
Quoted 2 lines
NULL,
+ "%llu\n");
Okay, since debugfs is actually using them in standard code, we may add it here as well.
drivers/platform/x86/intel_pmc_core.h line 32
Quoted 7 lines
drivers/platform/x86/intel_pmc_core.h +0
-1@@ -29,7 +29,6 @@ #define SPT_PMC_MMIO_REG_LEN 0x100 #define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 -struct dentry ;
Agreed.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Rajneesh Bhardwaj
Quoted 5 lines
So, if there is no objections (taking into consideration minors you mentioned) I think the patch can be applied.
Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c line 26
Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +1
-0@@ -23,6 +23,7 @@ #include <linux/init.h> #include <linux/io.h> #include <linux/pci.h> +#include <linux/seq_file.h> What is this for?
At this point it may be redundant as there will be no consumer for this. We may add it later when it's needed for seq_printf / seq_* etc. So i think we might just do away with this for v2.
Quoted 32 lines
Quoted 12 lines
drivers/platform/x86/intel_pmc_core.c +1
-1#include <asm/cpu_device_id.h> #include <asm/intel-family.h>@@ -88,7 +89,8 @@ static int pmc_core_dev_state_get(void *data, u64 *val) return 0; } -DEFINE_DEBUGFS_ATTRIBUTE (pmc_core_dev_state, pmc_core_dev_state_get,NULL , "%llu"); +DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get,Quoted 2 lines
NULL,
+ "%llu\n");Okay, since debugfs is actually using them in standard code, we may add it here as well.
drivers/platform/x86/intel_pmc_core.h line 32
Quoted 7 lines
drivers/platform/x86/intel_pmc_core.h +0
-1@@ -29,7 +29,6 @@ #define SPT_PMC_MMIO_REG_LEN 0x100 #define SPT_PMC_SLP_S0_RES_COUNTER_STEP 0x64 -struct dentry ;Agreed.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 2 lines
Best Regards, Rajneesh
Quoted 70 lines · Rajneesh Bhardwaj
Quoted 48 lines · Andy Shevchenko
Quoted 37 lines · Rajneesh Bhardwaj
Quoted 31 lines · Andy Shevchenko
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorQuoted 16 lines
Quoted 10 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUN
TER_
OFFSET);(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes
under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.Quoted 4 lines
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
Quoted 9 lines
While this is good for simple attributes i see a potential issue with this
approch when we want to display multiple attributes for a single debugfs
entry.
We typically useseq_printfin a loop and display multiline output
for a single debugfs entry. How do we go about the scenarios where we want
to display formatted multiline debug information?Quoted 3 lines
We are talking about abstract case or is it change coming to this very driver?
We will be sending few patches for this very driver shortly and one such feature would require multiline formatted output for a single debugfs entry.
Can we have
seq_printffor such cases and useDEFINE_DEBUGFS_ATTRIBUTEfor other simple attributes? Doing this might raise some coding style consistency concerns though so lets wait to hear Darren's opinion on this patch.Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I think we can omit this line if we chose to take this approach.
Yeah, it does not produce a warning on new compilers, though I think Darren can share his opinion.
Sure.
I'm not sure why we need it. dentry isn't debugfs specific. When is it undefined?
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 24 lines · Andy Shevchenko
Quoted 7 lines · Rajneesh Bhardwaj
Quoted 4 lines · Andy Shevchenko
This patch does the following:
- refactors code to use recently introducedDEFINE_DEBUGFS_ATTRIBUTE()macro
- makes absence ofDEBUG_FSnon-fatal errorQuoted 15 lines
Quoted 9 lines
(quoted diff) +0
-2- counter_val = pmc_core_reg_read(pmcdev, - SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);
(quoted diff) +0
-1- seq_printf(s, "%u\n",
pmc_core_adjust_slp_s0_step(counter_val));(quoted diff) +1
-0+ value = pmc_core_reg_read(pmcdev,
SPT_PMC_SLP_S0_RES_COUNTER_OFFSET);drivers/platform/x86/intel_pmc_core.c +1
-0+ *val =pmc_core_adjust_slp_s0_step (value);We were ensuring a new line for printing the output value with
seq_printf
whereas in this case the output is printed along with the shell prompt.
Sometimes this could be harder to read.
Quoted 4 lines
This would be a difference in the behaviour to a generic assumption (since this new macro is going to be used by plenty of simple attributes under debugfs). If you still consider it's inappropriate I would recommend to propose a fix globally then.
Agreed.
Quoted 4 lines
Regarding to change behaviour of the current implementation I think Darren can tell his opinion. (For me at least pros and cons of new format quite obvious).
We should use the available subsystem tools for boilerplate reduction whenever possible. Fortunately, debugfs is debug, and we do not require that it provide a consistent user interface like with sysfs (via a version attribute).
Quoted 8 lines
Quoted 6 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
Erm... why is dentry an undefined type?
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines
/**
* structpmc_dev- pmc device structure
* @base_addr: comtains pmc base addressdrivers/platform/x86/intel_pmc_core.h +0
-2@@ -42,9 +45,7 @@ struct pmc_dev { u32 base_addr; void __iomem *regbase; -#if IS_ENABLED (CONFIG_DEBUG_FS ) struct dentry *dbgfs_dir; -#endif /* CONFIG_DEBUG_FS */ Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
On Fri, 2016-07-01 at 14:24 -0700, Darren Hart wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
drivers/platform/x86/intel_pmc_core.h line 33
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.h +2
-0+struct dentry ; +Why do we need this ?
Since we are using pointer to undefined type.
Erm... why is dentry an undefined type?
In this header it's undefined. Though I can't get any warning using recent compilers, thus the change is not needed.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy