lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 23 Nov 2013 15:32:59 +0100
From:	Jean Delvare <khali@...ux-fr.org>
To:	Guenter Roeck <linux@...ck-us.net>
Cc:	netdev@...r.kernel.org, Nithin Nayak Sujir <nsujir@...adcom.com>,
	e1000-devel@...ts.sourceforge.net,
	Don Skidmore <donald.c.skidmore@...el.com>,
	Bruce Allan <bruce.w.allan@...el.com>,
	Jesse Brandeburg <jesse.brandeburg@...el.com>,
	lm-sensors@...sensors.org, Greg Rose <gregory.v.rose@...el.com>,
	Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
	Michael Chan <mchan@...adcom.com>,
	Carolyn Wyborny <carolyn.wyborny@...el.com>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [lm-sensors] [PATCH 1/5] tg3: Convert to use 
 hwmon_device_register_with_groups

Hi Guenter,

On Fri, 22 Nov 2013 22:07:57 -0800, Guenter Roeck wrote:
> 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@...ck-us.net>
> ---
>  drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
>  1 file changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index a9e0684..369b736 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -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);
> @@ -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];
> @@ -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);
>  	}
>  }
>  

I can't test this, but the changes look good to me.

Reviewed-by: Jean Delvare <khali@...ux-fr.org>

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ