Skip to content

Commit

Permalink
hwmon: (fam15h_power) Make actual power reporting conditional
Browse files Browse the repository at this point in the history
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

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 22e32f4 ('x86,AMD: Power driver support for AMD's family 16h processors')
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Aravind Gopalakrishnan authored and Guenter Roeck committed Sep 17, 2014
1 parent 9e82bf0 commit 961a237
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/hwmon/fam15h_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,29 @@ 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 (attr == &dev_attr_power1_input.attr &&
(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)
{
Expand Down

0 comments on commit 961a237

Please sign in to comment.