From 961a23788c3448eec7906bd74c64c01c54fba80e Mon Sep 17 00:00:00 2001 From: Aravind Gopalakrishnan Date: Tue, 16 Sep 2014 14:58:04 -0500 Subject: [PATCH 1/3] 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 Suggested-by: Guenter Roeck Fixes: 22e32f4f5777 ('x86,AMD: Power driver support for AMD's family 16h processors') Signed-off-by: Aravind Gopalakrishnan Signed-off-by: Guenter Roeck --- drivers/hwmon/fam15h_power.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 4a7cbfad1d74..4ee0126e02d6 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -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) { From 0a0039ad541d6ecdb4028e77ac6eae49a36af82b Mon Sep 17 00:00:00 2001 From: Aravind Gopalakrishnan Date: Tue, 16 Sep 2014 14:58:16 -0500 Subject: [PATCH 2/3] hwmon: (fam15h_power) Add support for two more processors Fam16h,M30h(Mullins) and Fam15hM30h(Kaveri) processors can report 'power_crit' value. So, adding their respective device ids. Signed-off-by: Aravind Gopalakrishnan Signed-off-by: Guenter Roeck --- drivers/hwmon/fam15h_power.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 4ee0126e02d6..fcdbde4ec692 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -232,7 +232,9 @@ static int fam15h_power_probe(struct pci_dev *pdev, static const struct pci_device_id fam15h_power_id_table[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, {} }; MODULE_DEVICE_TABLE(pci, fam15h_power_id_table); From 4e66cd13ff9cd7eaae69e2fae0335d8d99d8afdf Mon Sep 17 00:00:00 2001 From: sundarjdev Date: Mon, 22 Sep 2014 10:31:39 -0700 Subject: [PATCH 3/3] hwmon: (tmp103) Fix resource leak bug in tmp103 temperature sensor driver tmp103 temperature sensor driver registers with the hwmon framework by calling hwmon_device_register_with_groups but does not have a .remove method to call hwmon_device_unregister to unregister from the framework when the device is no longer needed. Fix this by calling devm_hwmon_device_register_with_groups. Signed-off-by: Sundar J Dev Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp103.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/tmp103.c b/drivers/hwmon/tmp103.c index e42964f07f67..ad571ec795a3 100644 --- a/drivers/hwmon/tmp103.c +++ b/drivers/hwmon/tmp103.c @@ -145,7 +145,7 @@ static int tmp103_probe(struct i2c_client *client, } i2c_set_clientdata(client, regmap); - hwmon_dev = hwmon_device_register_with_groups(dev, client->name, + hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, regmap, tmp103_groups); return PTR_ERR_OR_ZERO(hwmon_dev); }