Skip to contentSkip to conversation

platform/x86: convert to DEFINE_SHOW_ATTRIBUTE

PATCH In review Yangtao Li 3 participants 12 messages Dec 1, 2018 – Dec 5, 2018 x86 platform drivers

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 platform/x86: convert to DEFINE_SHOW_ATTRIBUTE

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---
 drivers/platform/x86/intel_pmc_core.c         | 46 ++++---------------
 .../platform/x86/intel_telemetry_debugfs.c    | 42 +++--------------
 2 files changed, 14 insertions(+), 74 deletions(-)
drivers/platform/x86/intel_pmc_core.c +8 -38
index 6b31d410cb09..95311ad6ec6f 100644
@@ -311,7 +311,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;
@@ -330,17 +330,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)
@@ -372,7 +362,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;
@@ -425,17 +415,7 @@ static int pmc_core_mphy_pg_sts_show(struct seq_file *s, void *unused)
 	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)
 {
@@ -472,17 +452,7 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
 	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)
@@ -602,19 +572,19 @@ 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);
 
 	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,
drivers/platform/x86/intel_telemetry_debugfs.c +6 -36

78 lines not on this page · raw message

Signature · 1 line
2.17.0
#1 lore raw
Quoted 2 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

Quoted 200 lines
---
 drivers/platform/x86/intel_pmc_core.c         | 46 ++++---------------
 .../platform/x86/intel_telemetry_debugfs.c    | 42 +++--------------
 2 files changed, 14 insertions(+), 74 deletions(-)
drivers/platform/x86/intel_pmc_core.c +8 -38
index 6b31d410cb09..95311ad6ec6f 100644
@@ -311,7 +311,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;
@@ -330,17 +330,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)
@@ -372,7 +362,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;
@@ -425,17 +415,7 @@ static int pmc_core_mphy_pg_sts_show(struct seq_file *s, void *unused)
        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)
 {
@@ -472,17 +452,7 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
        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)
@@ -602,19 +572,19 @@ 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);
 
        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,
drivers/platform/x86/intel_telemetry_debugfs.c +6 -37
index 40bce560eb30..98ba9185a27b 100644
@@ -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;
--

2.17.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#2 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

For what reason?
I thought that for-next branch has not changed much.

Yours,
Yangtao

#3 lore raw
Quoted 8 lines · Frank Lee
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

I like your patch, but...

Quoted 4 lines
Quoted 2 lines

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

For what reason?

...because I can't apply it, it fails with conflicts.

Quoted 1 line

I thought that for-next branch has not changed much.

That's correct, it's updated only by approved patch series which is not many _this_ cycle.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#4 lore raw
Quoted 16 lines · Andy Shevchenko
Quoted 8 lines · Frank Lee
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

I like your patch, but...

Quoted 2 lines
Quoted 2 lines

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

Quoted 8 lines
Quoted 1 line

For what reason?

...because I can't apply it, it fails with conflicts.

Quoted 1 line

I thought that for-next branch has not changed much.

That's correct, it's updated only by approved patch series which is not many _this_ cycle.

I am confused about what you said.
Because I pulled your .git down, there is no conflicts when apply it.......

MBR,
Yangtao

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

#5 lore raw
Quoted 15 lines · Frank Lee
Quoted 13 lines · Andy Shevchenko
Quoted 4 lines · Frank Lee
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

I like your patch, but...

Quoted 4 lines
Quoted 2 lines

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

For what reason?

Quoted 8 lines
Quoted 6 lines

...because I can't apply it, it fails with conflicts.

Quoted 1 line

I thought that for-next branch has not changed much.

That's correct, it's updated only by approved patch series which is not many _this_ cycle.

I am confused about what you said.
Because I pulled your .git down, there is no conflicts when apply it.......

linux(for-next)

$ git pw patch apply 10707735 -s
error: patch failed: drivers/platform/x86/intel_pmc_core.c:602
error: drivers/platform/x86/intel_pmc_core.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: platform/x86: convert to DEFINE_SHOW_ATTRIBUTE
Patch failed at 0001 platform/x86: convert to DEFINE_SHOW_ATTRIBUTE
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#6 lore raw
Quoted 27 lines · Andy Shevchenko
Quoted 15 lines · Frank Lee
Quoted 13 lines · Andy Shevchenko
Quoted 4 lines · Frank Lee
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

I like your patch, but...

Quoted 4 lines
Quoted 2 lines

By some reason it's not applicable.
Please, rebase on top of our for-next branch, thanks!

For what reason?

Quoted 8 lines
Quoted 6 lines

...because I can't apply it, it fails with conflicts.

Quoted 1 line

I thought that for-next branch has not changed much.

That's correct, it's updated only by approved patch series which is not many _this_ cycle.

I am confused about what you said.
Because I pulled your .git down, there is no conflicts when apply it.......

linux(for-next)

Quoted 9 lines
$ git pw patch apply 10707735 -s
error: patch failed: drivers/platform/x86/intel_pmc_core.c:602
error: drivers/platform/x86/intel_pmc_core.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: platform/x86: convert to DEFINE_SHOW_ATTRIBUTE
Patch failed at 0001 platform/x86: convert to DEFINE_SHOW_ATTRIBUTE
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
$ git br -r
  origin/HEAD -> origin/master
  origin/fixes
  origin/for-next
  origin/master
  origin/review-andy
$ git remote set-branches --add origin for-next
$ git br -vv
* for-next 651022382c7f [origin/for-next] Linux 4.20-rc1
$ git apply ../../0001-platform-x86-convert-to-DEFINE_SHOW_ATTRIBUTE.patch
$ git st
On branch for-next
Your branch is up to date with 'origin/for-next'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)

modified: drivers/platform/x86/intel_pmc_core.c
modified: drivers/platform/x86/intel_telemetry_debugfs.c

no changes added to commit (use "git add" and/or "git commit -a")

Andy,I don't know why.
Is there a problem with my operation?

Thanks,
Yangtao

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

#7 lore raw
Quoted 9 lines · Frank Lee
$ git br -r
  origin/HEAD -> origin/master
  origin/fixes
  origin/for-next
  origin/master
  origin/review-andy
$ git remote set-branches --add origin for-next
$ git br -vv
* for-next 651022382c7f [origin/for-next] Linux 4.20-rc1

Here is the problem,

For a few days at least we have
4ecd94b8e13b (HEAD -> for-next) platform/x86: dell-laptop: Mark expected switch fall-throughs

Quoted 9 lines
$ git apply ../../0001-platform-x86-convert-to-DEFINE_SHOW_ATTRIBUTE.patch
$ git st
On branch for-next
Your branch is up to date with 'origin/for-next'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)

Quoted 7 lines

modified: drivers/platform/x86/intel_pmc_core.c
modified: drivers/platform/x86/intel_telemetry_debugfs.c

no changes added to commit (use "git add" and/or "git commit -a")

Andy,I don't know why.
Is there a problem with my operation?

Definitely.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#8 lore raw
Quoted 31 lines · Andy Shevchenko
Quoted 9 lines · Frank Lee
$ git br -r
  origin/HEAD -> origin/master
  origin/fixes
  origin/for-next
  origin/master
  origin/review-andy
$ git remote set-branches --add origin for-next
$ git br -vv
* for-next 651022382c7f [origin/for-next] Linux 4.20-rc1

Here is the problem,

For a few days at least we have
4ecd94b8e13b (HEAD -> for-next) platform/x86: dell-laptop: Mark expected switch fall-throughs

Quoted 12 lines
$ git apply ../../0001-platform-x86-convert-to-DEFINE_SHOW_ATTRIBUTE.patch
$ git st
On branch for-next
Your branch is up to date with 'origin/for-next'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)

modified: drivers/platform/x86/intel_pmc_core.c
modified: drivers/platform/x86/intel_telemetry_debugfs.c

Quoted 6 lines
Quoted 4 lines

no changes added to commit (use "git add" and/or "git commit -a")

Andy,I don't know why.
Is there a problem with my operation?

Definitely.

Where can I find the correct git repository?
I haven't found the correct one for a long time,
which include the commit(4ecd94b8e13b ) you said.

MBR,
Yangtao

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

#9 lore raw
Quoted 8 lines · Frank Lee
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Frank Lee
$ git remote set-branches --add origin for-next
$ git br -vv
* for-next 651022382c7f [origin/for-next] Linux 4.20-rc1
Quoted 7 lines
Quoted 5 lines

Here is the problem,

For a few days at least we have
4ecd94b8e13b (HEAD -> for-next) platform/x86: dell-laptop: Mark expected switch fall-throughs

Where can I find the correct git repository?

I think even old address still exists:
http://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git

Quoted 2 lines

I haven't found the correct one for a long time,
which include the commit(4ecd94b8e13b ) you said.

And newest one is available via
http://git.infradead.org/linux-platform-drivers-x86.git

http://git.infradead.org/linux-platform-drivers-x86.git/commit/4ecd94b8e13b014a28be48c94f751fb62f7c749e

Though it's already advanced to contain new portion of accepted patches (doesn't matter for you, because they don't touch file in question).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw
Quoted 23 lines · Andy Shevchenko
Quoted 8 lines · Frank Lee
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Frank Lee
$ git remote set-branches --add origin for-next
$ git br -vv
* for-next 651022382c7f [origin/for-next] Linux 4.20-rc1
Quoted 7 lines
Quoted 5 lines

Here is the problem,

For a few days at least we have
4ecd94b8e13b (HEAD -> for-next) platform/x86: dell-laptop: Mark expected switch fall-throughs

Where can I find the correct git repository?

I think even old address still exists:
http://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git

Quoted 2 lines

I haven't found the correct one for a long time,
which include the commit(4ecd94b8e13b ) you said.

Quoted 8 lines

And newest one is available via
http://git.infradead.org/linux-platform-drivers-x86.git

http://git.infradead.org/linux-platform-drivers-x86.git/commit/4ecd94b8e13b014a28be48c94f751fb62f7c749e

Though it's already advanced to contain new portion of accepted patches (doesn't matter for you, because they don't touch file in question).

Hi Andy, i was thinking of having it split into two patches as it touches two unrelated files. What is your opinion?

Functionality wise, it looks good to me.

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
Signature · 2 lines
Best Regards,
Rajneesh
#11 lore raw
Quoted 2 lines · Rajneesh Bhardwaj

Hi Andy, i was thinking of having it split into two patches as it touches two unrelated files. What is your opinion?

If it is the case, I agree with you.
Since patch didn't applied clearly I even had no chance to look at it closer.

Quoted 1 line

Functionality wise, it looks good to me.

Thanks.

Signature · 2 lines
With Best Regards,
Andy Shevchenko