Skip to content

Commit

Permalink
tg3: Convert to use hwmon_device_register_with_groups
Browse files Browse the repository at this point in the history
Use new hwmon API to simplify code, provide missing mandatory 'name'
sysfs attribute, and attach hwmon attributes to hwmon device instead
of pci device.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Nithin Nayak Sujir <nsujir@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Guenter Roeck authored and David S. Miller committed Nov 28, 2013
1 parent fe9d04a commit a2f4dfb
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions drivers/net/ethernet/broadcom/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir)
static ssize_t tg3_show_temp(struct device *dev,
struct device_attribute *devattr, char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct net_device *netdev = pci_get_drvdata(pdev);
struct tg3 *tp = netdev_priv(netdev);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct tg3 *tp = dev_get_drvdata(dev);
u32 temperature;

spin_lock_bh(&tp->lock);
Expand All @@ -10650,29 +10648,25 @@ static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, tg3_show_temp, NULL,
static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL,
TG3_TEMP_MAX_OFFSET);

static struct attribute *tg3_attributes[] = {
static struct attribute *tg3_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp1_crit.dev_attr.attr,
&sensor_dev_attr_temp1_max.dev_attr.attr,
NULL
};

static const struct attribute_group tg3_group = {
.attrs = tg3_attributes,
};
ATTRIBUTE_GROUPS(tg3);

static void tg3_hwmon_close(struct tg3 *tp)
{
if (tp->hwmon_dev) {
hwmon_device_unregister(tp->hwmon_dev);
tp->hwmon_dev = NULL;
sysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group);
}
}

static void tg3_hwmon_open(struct tg3 *tp)
{
int i, err;
int i;
u32 size = 0;
struct pci_dev *pdev = tp->pdev;
struct tg3_ocir ocirs[TG3_SD_NUM_RECS];
Expand All @@ -10690,18 +10684,11 @@ static void tg3_hwmon_open(struct tg3 *tp)
if (!size)
return;

/* Register hwmon sysfs hooks */
err = sysfs_create_group(&pdev->dev.kobj, &tg3_group);
if (err) {
dev_err(&pdev->dev, "Cannot create sysfs group, aborting\n");
return;
}

tp->hwmon_dev = hwmon_device_register(&pdev->dev);
tp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, "tg3",
tp, tg3_groups);
if (IS_ERR(tp->hwmon_dev)) {
tp->hwmon_dev = NULL;
dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n");
sysfs_remove_group(&pdev->dev.kobj, &tg3_group);
}
}

Expand Down

0 comments on commit a2f4dfb

Please sign in to comment.