hwmon, fam15h_power: Make actual power reporting conditional
PATCH 1/2 hwmon, fam15h_power: Make actual power reporting conditional
power1_input should only be reported for Fam15h, Models 00h-0fh So, introduce a is_visible function to take care of this.
As suggested by Guenter here:
http://marc.info/?l=linux-kernel&m=141038145616437&w=2
--- drivers/hwmon/fam15h_power.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/hwmon/fam15h_power.c +18 -1
@@ -93,13 +93,30 @@ static ssize_t show_power_crit(struct device *dev, } static DEVICE_ATTR(power1_crit, S_IRUGO, show_power_crit, NULL); +static umode_t fam15h_power_is_visible (struct kobject *kobj, +struct attribute *attr, +int index) +{ +/* power1_input is only reported for Fam15h, Models 00h-0fh */ +if (!strcmp (attr->name,"power1_input" ) && + (boot_cpu_data.x86 !=0x15 || boot_cpu_data.x86_model >0xf )) { +return 0 ; + } + +return attr->mode; +} +static struct attribute *fam15h_power_attrs[] = { &dev_attr_power1_input.attr, &dev_attr_power1_crit.attr,NULL }; -ATTRIBUTE_GROUPS (fam15h_power); +static const struct attribute_group fam15h_power_group = { + .attrs = fam15h_power_attrs, + .is_visible = fam15h_power_is_visible, +}; +__ATTRIBUTE_GROUPS (fam15h_power);static bool fam15h_power_is_internal_node0 (struct pci_dev *f4) {
Signature · 1 line
2.0.2
Guenter Roeck
maintainerQuoted 17 lines · Aravind Gopalakrishnan
power1_inputshould only be reported for Fam15h, Models 00h-0fh So, introduce ais_visiblefunction to take care of this.As suggested by Guenter here:
http://marc.info/?l=linux-kernel&m=141038145616437&w=2Suggested-by Guenter Roeck <[email protected]>Signed-off-by Aravind Gopalakrishnan <[email protected]>--- drivers/hwmon/fam15h_power.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)drivers/hwmon/fam15h_power.c +0
-0
drivers/hwmon/fam15h_power.c static ssize_t show_power_crit(struct device *dev, · line 101
Quoted 9 lines
drivers/hwmon/fam15h_power.c +6
-0@@ -93,13 +93,30 @@ static ssize_t show_power_crit(struct device *dev, } static DEVICE_ATTR(power1_crit, S_IRUGO, show_power_crit, NULL); +static umode_t fam15h_power_is_visible (struct kobject *kobj, +struct attribute *attr, +int index) +{ +/* power1_input is only reported for Fam15h, Models 00h-0fh */ + if (!strcmp(attr->name, "power1_input") &&
if (attr == &dev_attr_power1_input.attr &&
works just as well and is simpler.
Quoted 25 lines
drivers/hwmon/fam15h_power.c +12
-1+ (boot_cpu_data.x86 != 0x15 || boot_cpu_data.x86_model > 0xf)) { +return 0 ; + } + +return attr->mode; +} +static struct attribute *fam15h_power_attrs[] = { &dev_attr_power1_input.attr, &dev_attr_power1_crit.attr,NULL }; -ATTRIBUTE_GROUPS (fam15h_power); +static const struct attribute_group fam15h_power_group = { + .attrs = fam15h_power_attrs, + .is_visible = fam15h_power_is_visible, +}; +__ATTRIBUTE_GROUPS (fam15h_power);static bool fam15h_power_is_internal_node0 (struct pci_dev *f4) {Signature · 1 line
2.0.2
Quoted 29 lines · Guenter Roeck
Quoted 17 lines · Aravind Gopalakrishnan
power1_inputshould only be reported for Fam15h, Models 00h-0fh So, introduce ais_visiblefunction to take care of this.As suggested by Guenter here:
http://marc.info/?l=linux-kernel&m=141038145616437&w=2Suggested-by Guenter Roeck <[email protected]>Signed-off-by Aravind Gopalakrishnan <[email protected]>--- drivers/hwmon/fam15h_power.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)drivers/hwmon/fam15h_power.c +0
-0drivers/hwmon/fam15h_power.c static ssize_t show_power_crit(struct device *dev, · line 101
Quoted 9 lines
drivers/hwmon/fam15h_power.c +6
-0@@ -93,13 +93,30 @@ static ssize_t show_power_crit(struct device *dev, } static DEVICE_ATTR(power1_crit, S_IRUGO, show_power_crit, NULL); +static umode_t fam15h_power_is_visible (struct kobject *kobj, +struct attribute *attr, +int index) +{ +/* power1_input is only reported for Fam15h, Models 00h-0fh */ + if (!strcmp(attr->name, "power1_input") &&if (attr == &dev_attr_power1_input.attr &&
Quoted 1 line
works just as well and is simpler.
Ok.
Quoted 4 lines
drivers/hwmon/fam15h_power.c static ssize_t show_power_crit(struct device *dev, · line 105
Quoted 4 lines
drivers/hwmon/fam15h_power.c +4
-0+ (boot_cpu_data.x86 != 0x15 || boot_cpu_data.x86_model > 0xf)) { +return 0 ; + } +
I just noticed: I don't really need opening/closing parenthesis here. Shall fix and send V2.
Quoted 4 lines
drivers/hwmon/fam15h_power.c static ssize_t show_power_crit(struct device *dev, · line 114
Quoted 4 lines
drivers/hwmon/fam15h_power.c +3
-0+return attr->mode; +} +
Thanks,
-Aravind.