platform/x86: intel_pmc_core: convert to DEFINE_SHOW_ATTRIBUTE
PATCH 1/2 platform/x86: intel_pmc_core: convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by Yangtao Li <[email protected]>
--- drivers/platform/x86/intel_pmc_core.c | 49 +++++---------------------- 1 file changed, 8 insertions(+), 41 deletions(-)
drivers/platform/x86/intel_pmc_core.c +8 -41
@@ -367,7 +367,7 @@ static void pmc_core_display_map(struct seq_file *s, int index, pf_map[index].bit_mask & pf_reg ? "Off" : "On"); } -static int pmc_core_ppfear_sts_show (struct seq_file *s,void *unused) +static int pmc_core_ppfear_show (struct seq_file *s,void *unused) {struct pmc_dev *pmcdev = s->private;const struct pmc_bit_map *map = pmcdev->map->pfear_sts;
@@ -385,18 +385,7 @@ static int pmc_core_ppfear_sts_show(struct seq_file *s, void *unused)return 0 ; } - -static int pmc_core_ppfear_sts_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_ppfear_sts_show, inode->i_private); -} - -static const struct file_operations pmc_core_ppfear_ops = { - .open = pmc_core_ppfear_sts_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_ppfear);/* This function should return link status, 0 means ready */ static int pmc_core_mtpmc_link_status (void )
@@ -428,7 +417,7 @@ static int pmc_core_send_msg(u32 *addr_xram)return 0 ; } -static int pmc_core_mphy_pg_sts_show (struct seq_file *s,void *unused) +static int pmc_core_mphy_pg_show (struct seq_file *s,void *unused) {struct pmc_dev *pmcdev = s->private;const struct pmc_bit_map *map = pmcdev->map->mphy_sts;
@@ -480,18 +469,7 @@ static int pmc_core_mphy_pg_sts_show(struct seq_file *s, void *unused)mutex_unlock (&pmcdev->lock);return err; } - -static int pmc_core_mphy_pg_sts_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_mphy_pg_sts_show, inode->i_private); -} - -static const struct file_operations pmc_core_mphy_pg_ops = { - .open = pmc_core_mphy_pg_sts_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_mphy_pg);static int pmc_core_pll_show (struct seq_file *s,void *unused) {
@@ -527,18 +505,7 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)mutex_unlock (&pmcdev->lock);return err; } - -static int pmc_core_pll_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_pll_show, inode->i_private); -} - -static const struct file_operations pmc_core_pll_ops = { - .open = pmc_core_pll_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_pll);static ssize_t pmc_core_ltr_ignore_write (struct file *file,const char __user *userbuf,size_t count,loff_t *ppos)
@@ -729,7 +696,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev) &pmc_core_dev_state);debugfs_create_file ("pch_ip_power_gating_status" ,0444 , dir, pmcdev, - &pmc_core_ppfear_ops); + &pmc_core_ppfear_fops);debugfs_create_file ("ltr_ignore" ,0644 , dir, pmcdev, &pmc_core_ltr_ignore_ops);
@@ -738,12 +705,12 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)if (pmcdev->map->pll_sts)debugfs_create_file ("pll_status" ,0444 , dir, pmcdev, - &pmc_core_pll_ops); + &pmc_core_pll_fops);if (pmcdev->map->mphy_sts)debugfs_create_file ("mphy_core_lanes_power_gating_status" ,0444 , dir, pmcdev, - &pmc_core_mphy_pg_ops); + &pmc_core_mphy_pg_fops);if (pmcdev->map->slps0_dbg_maps) { debugfs_create_file("slp_s0_debug_status", 0444,
Signature · 1 line
2.17.0
PATCH 2/2 platform/x86: intel_telemetry: convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by Yangtao Li <[email protected]>
--- .../platform/x86/intel_telemetry_debugfs.c | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-)
drivers/platform/x86/intel_telemetry_debugfs.c +6 -36
@@ -466,17 +466,7 @@ static int telem_pss_states_show(struct seq_file *s, void *unused)return 0 ; } -static int telem_pss_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, telem_pss_states_show, inode->i_private); -} - -static const struct file_operations telem_pss_ops = { - .open = telem_pss_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (telem_pss_states);static int telem_ioss_states_show (struct seq_file *s,void *unused) {
@@ -505,17 +495,7 @@ static int telem_ioss_states_show(struct seq_file *s, void *unused)return 0 ; } -static int telem_ioss_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, telem_ioss_states_show, inode->i_private); -} - -static const struct file_operations telem_ioss_ops = { - .open = telem_ioss_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (telem_ioss_states);static int telem_soc_states_show (struct seq_file *s,void *unused) {
@@ -664,17 +644,7 @@ static int telem_soc_states_show(struct seq_file *s, void *unused)return 0 ; } -static int telem_soc_state_open (struct inode *inode,struct file *file) -{ -return single_open (file, telem_soc_states_show, inode->i_private); -} - -static const struct file_operations telem_socstate_ops = { - .open = telem_soc_state_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (telem_soc_states);static int telem_s0ix_res_get (void *data,u64 *val) {
@@ -960,7 +930,7 @@ static int __init telemetry_debugfs_init(void) f =debugfs_create_file ("pss_info" ,S_IFREG |S_IRUGO , debugfs_conf->telemetry_dbg_dir,NULL , - &telem_pss_ops); + &telem_pss_states_fops);if (!f) {pr_err ("pss_sample_info debugfs register failed\n" ); goto out;
@@ -968,7 +938,7 @@ static int __init telemetry_debugfs_init(void) f =debugfs_create_file ("ioss_info" ,S_IFREG |S_IRUGO , debugfs_conf->telemetry_dbg_dir,NULL , - &telem_ioss_ops); + &telem_ioss_states_fops);if (!f) {pr_err ("ioss_sample_info debugfs register failed\n" ); goto out;
@@ -976,7 +946,7 @@ static int __init telemetry_debugfs_init(void) f =debugfs_create_file ("soc_states" ,S_IFREG |S_IRUGO , debugfs_conf->telemetry_dbg_dir, -NULL , &telem_socstate_ops); +NULL , &telem_soc_states_fops);if (!f) {pr_err ("ioss_sample_info debugfs register failed\n" ); goto out;
Signature · 1 line
2.17.0
Quoted 3 lines · Yangtao Li
Use
DEFINE_SHOW_ATTRIBUTEmacro to simplify the code.
Both patches had been pushed, thanks!
Quoted 114 lines
Signed-off-by Yangtao Li <[email protected]>--- drivers/platform/x86/intel_pmc_core.c | 49 +++++---------------------- 1 file changed, 8 insertions(+), 41 deletions(-)drivers/platform/x86/intel_pmc_core.c +8
-42@@ -367,7 +367,7 @@ static void pmc_core_display_map(struct seq_file *s, int index, pf_map[index].bit_mask & pf_reg ? "Off" : "On"); } -static int pmc_core_ppfear_sts_show (struct seq_file *s,void *unused) +static int pmc_core_ppfear_show (struct seq_file *s,void *unused) {struct pmc_dev *pmcdev = s->private;const struct pmc_bit_map *map = pmcdev->map->pfear_sts;@@ -385,18 +385,7 @@ static int pmc_core_ppfear_sts_show(struct seq_file *s, void *unused)return 0 ; } - -static int pmc_core_ppfear_sts_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_ppfear_sts_show, inode->i_private); -} - -static const struct file_operations pmc_core_ppfear_ops = { - .open = pmc_core_ppfear_sts_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_ppfear);/* This function should return link status, 0 means ready */ static int pmc_core_mtpmc_link_status (void )@@ -428,7 +417,7 @@ static int pmc_core_send_msg(u32 *addr_xram)return 0 ; } -static int pmc_core_mphy_pg_sts_show (struct seq_file *s,void *unused) +static int pmc_core_mphy_pg_show (struct seq_file *s,void *unused) {struct pmc_dev *pmcdev = s->private;const struct pmc_bit_map *map = pmcdev->map->mphy_sts;@@ -480,18 +469,7 @@ static int pmc_core_mphy_pg_sts_show(struct seq_file *s, void *unused)mutex_unlock (&pmcdev->lock);return err; } - -static int pmc_core_mphy_pg_sts_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_mphy_pg_sts_show, inode->i_private); -} - -static const struct file_operations pmc_core_mphy_pg_ops = { - .open = pmc_core_mphy_pg_sts_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_mphy_pg);static int pmc_core_pll_show (struct seq_file *s,void *unused) {@@ -527,18 +505,7 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)mutex_unlock (&pmcdev->lock);return err; } - -static int pmc_core_pll_open (struct inode *inode,struct file *file) -{ -return single_open (file, pmc_core_pll_show, inode->i_private); -} - -static const struct file_operations pmc_core_pll_ops = { - .open = pmc_core_pll_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (pmc_core_pll);static ssize_t pmc_core_ltr_ignore_write (struct file *file,const char __user *userbuf,size_t count,loff_t *ppos)@@ -729,7 +696,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev) &pmc_core_dev_state);debugfs_create_file ("pch_ip_power_gating_status" ,0444 , dir, pmcdev, - &pmc_core_ppfear_ops); + &pmc_core_ppfear_fops);debugfs_create_file ("ltr_ignore" ,0644 , dir, pmcdev, &pmc_core_ltr_ignore_ops);@@ -738,12 +705,12 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev)if (pmcdev->map->pll_sts)debugfs_create_file ("pll_status" ,0444 , dir, pmcdev, - &pmc_core_pll_ops); + &pmc_core_pll_fops);if (pmcdev->map->mphy_sts)debugfs_create_file ("mphy_core_lanes_power_gating_status" ,0444 , dir, pmcdev, - &pmc_core_mphy_pg_ops); + &pmc_core_mphy_pg_fops);if (pmcdev->map->slps0_dbg_maps) { debugfs_create_file("slp_s0_debug_status", 0444, --2.17.0
Signature · 2 lines
With Best Regards, Andy Shevchenko