All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute
@ 2007-08-17 15:31 Jean Delvare
  2007-08-17 16:17 ` Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jean Delvare @ 2007-08-17 15:31 UTC (permalink / raw)
  To: lm-sensors

Add a name attribute to the lm70 devices. This is required for
libsensors to recognize them.

Also drop the "+" before the temperature value, even though it did
not cause problems to libsensors, other hardware monitoring drivers
don't print it, so it's more consistent that way.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 drivers/hwmon/lm70.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

--- linux-2.6.23-rc3.orig/drivers/hwmon/lm70.c	2007-07-23 16:44:35.000000000 +0200
+++ linux-2.6.23-rc3/drivers/hwmon/lm70.c	2007-08-17 16:16:40.000000000 +0200
@@ -81,7 +81,7 @@ static ssize_t lm70_sense_temp(struct de
 	 * So it's equivalent to multiplying by 0.25 * 1000 = 250.
 	 */
 	val = ((int)raw/32) * 250;
-	status = sprintf(buf, "%+d\n", val); /* millidegrees Celsius */
+	status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
 out:
 	up(&p_lm70->sem);
 	return status;
@@ -89,6 +89,14 @@ out:
 
 static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL);
 
+static ssize_t lm70_show_name(struct device *dev, struct device_attribute
+			      *devattr, char *buf)
+{
+	return sprintf(buf, "lm70\n");
+}
+
+static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);
+
 /*----------------------------------------------------------------------*/
 
 static int __devinit lm70_probe(struct spi_device *spi)
@@ -115,7 +123,8 @@ static int __devinit lm70_probe(struct s
 	}
 	dev_set_drvdata(&spi->dev, p_lm70);
 
-	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))) {
+	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
+	 || (status = device_create_file(&spi->dev, &dev_attr_name))) {
 		dev_dbg(&spi->dev, "device_create_file failure.\n");
 		goto out_dev_create_file_failed;
 	}
@@ -123,6 +132,7 @@ static int __devinit lm70_probe(struct s
 	return 0;
 
 out_dev_create_file_failed:
+	device_remove_file(&spi->dev, &dev_attr_temp1_input);
 	hwmon_device_unregister(p_lm70->cdev);
 out_dev_reg_failed:
 	dev_set_drvdata(&spi->dev, NULL);
@@ -135,6 +145,7 @@ static int __devexit lm70_remove(struct 
 	struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
 
 	device_remove_file(&spi->dev, &dev_attr_temp1_input);
+	device_remove_file(&spi->dev, &dev_attr_name);
 	hwmon_device_unregister(p_lm70->cdev);
 	dev_set_drvdata(&spi->dev, NULL);
 	kfree(p_lm70);


-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute
  2007-08-17 15:31 [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute Jean Delvare
@ 2007-08-17 16:17 ` Hans de Goede
  2007-08-18  6:26 ` Kaiwan N Billimoria
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2007-08-17 16:17 UTC (permalink / raw)
  To: lm-sensors

Jean Delvare wrote:
> Add a name attribute to the lm70 devices. This is required for
> libsensors to recognize them.
> 
> Also drop the "+" before the temperature value, even though it did
> not cause problems to libsensors, other hardware monitoring drivers
> don't print it, so it's more consistent that way.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>

Looks good to me.

Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl>

> ---
>  drivers/hwmon/lm70.c |   15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> --- linux-2.6.23-rc3.orig/drivers/hwmon/lm70.c	2007-07-23 16:44:35.000000000 +0200
> +++ linux-2.6.23-rc3/drivers/hwmon/lm70.c	2007-08-17 16:16:40.000000000 +0200
> @@ -81,7 +81,7 @@ static ssize_t lm70_sense_temp(struct de
>  	 * So it's equivalent to multiplying by 0.25 * 1000 = 250.
>  	 */
>  	val = ((int)raw/32) * 250;
> -	status = sprintf(buf, "%+d\n", val); /* millidegrees Celsius */
> +	status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
>  out:
>  	up(&p_lm70->sem);
>  	return status;
> @@ -89,6 +89,14 @@ out:
>  
>  static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL);
>  
> +static ssize_t lm70_show_name(struct device *dev, struct device_attribute
> +			      *devattr, char *buf)
> +{
> +	return sprintf(buf, "lm70\n");
> +}
> +
> +static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);
> +
>  /*----------------------------------------------------------------------*/
>  
>  static int __devinit lm70_probe(struct spi_device *spi)
> @@ -115,7 +123,8 @@ static int __devinit lm70_probe(struct s
>  	}
>  	dev_set_drvdata(&spi->dev, p_lm70);
>  
> -	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))) {
> +	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
> +	 || (status = device_create_file(&spi->dev, &dev_attr_name))) {
>  		dev_dbg(&spi->dev, "device_create_file failure.\n");
>  		goto out_dev_create_file_failed;
>  	}
> @@ -123,6 +132,7 @@ static int __devinit lm70_probe(struct s
>  	return 0;
>  
>  out_dev_create_file_failed:
> +	device_remove_file(&spi->dev, &dev_attr_temp1_input);
>  	hwmon_device_unregister(p_lm70->cdev);
>  out_dev_reg_failed:
>  	dev_set_drvdata(&spi->dev, NULL);
> @@ -135,6 +145,7 @@ static int __devexit lm70_remove(struct 
>  	struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
>  
>  	device_remove_file(&spi->dev, &dev_attr_temp1_input);
> +	device_remove_file(&spi->dev, &dev_attr_name);
>  	hwmon_device_unregister(p_lm70->cdev);
>  	dev_set_drvdata(&spi->dev, NULL);
>  	kfree(p_lm70);
> 
> 


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute
  2007-08-17 15:31 [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute Jean Delvare
  2007-08-17 16:17 ` Hans de Goede
@ 2007-08-18  6:26 ` Kaiwan N Billimoria
  2007-08-18 14:07 ` Jean Delvare
  2007-08-26 18:50 ` Mark M. Hoffman
  3 siblings, 0 replies; 5+ messages in thread
From: Kaiwan N Billimoria @ 2007-08-18  6:26 UTC (permalink / raw)
  To: lm-sensors

> Add a name attribute to the lm70 devices. This is required for
> libsensors to recognize them.
> 
> Also drop the "+" before the temperature value, even though it did
> not cause problems to libsensors, other hardware monitoring drivers
> don't print it, so it's more consistent that way.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>

Yup, fine with me.

Acked-by: Kaiwan <kaiwan@designergraphix.com>

> ---
>  drivers/hwmon/lm70.c |   15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> --- linux-2.6.23-rc3.orig/drivers/hwmon/lm70.c	2007-07-23 16:44:35.000000000 +0200
> +++ linux-2.6.23-rc3/drivers/hwmon/lm70.c	2007-08-17 16:16:40.000000000 +0200
> @@ -81,7 +81,7 @@ static ssize_t lm70_sense_temp(struct de
>  	 * So it's equivalent to multiplying by 0.25 * 1000 = 250.
>  	 */
>  	val = ((int)raw/32) * 250;
> -	status = sprintf(buf, "%+d\n", val); /* millidegrees Celsius */
> +	status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
>  out:
>  	up(&p_lm70->sem);
>  	return status;
> @@ -89,6 +89,14 @@ out:
>  
>  static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL);
>  
> +static ssize_t lm70_show_name(struct device *dev, struct device_attribute
> +			      *devattr, char *buf)
> +{
> +	return sprintf(buf, "lm70\n");
> +}
> +
> +static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);
> +
>  /*----------------------------------------------------------------------*/
>  
>  static int __devinit lm70_probe(struct spi_device *spi)
> @@ -115,7 +123,8 @@ static int __devinit lm70_probe(struct s
>  	}
>  	dev_set_drvdata(&spi->dev, p_lm70);
>  
> -	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))) {
> +	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
> +	 || (status = device_create_file(&spi->dev, &dev_attr_name))) {
>  		dev_dbg(&spi->dev, "device_create_file failure.\n");
>  		goto out_dev_create_file_failed;
>  	}
> @@ -123,6 +132,7 @@ static int __devinit lm70_probe(struct s
>  	return 0;
>  
>  out_dev_create_file_failed:
> +	device_remove_file(&spi->dev, &dev_attr_temp1_input);
Ah. Thanks!

>  	hwmon_device_unregister(p_lm70->cdev);
>  out_dev_reg_failed:
>  	dev_set_drvdata(&spi->dev, NULL);
> @@ -135,6 +145,7 @@ static int __devexit lm70_remove(struct 
>  	struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
>  
>  	device_remove_file(&spi->dev, &dev_attr_temp1_input);
> +	device_remove_file(&spi->dev, &dev_attr_name);
>  	hwmon_device_unregister(p_lm70->cdev);
>  	dev_set_drvdata(&spi->dev, NULL);
>  	kfree(p_lm70);
> 
> 


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute
  2007-08-17 15:31 [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute Jean Delvare
  2007-08-17 16:17 ` Hans de Goede
  2007-08-18  6:26 ` Kaiwan N Billimoria
@ 2007-08-18 14:07 ` Jean Delvare
  2007-08-26 18:50 ` Mark M. Hoffman
  3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2007-08-18 14:07 UTC (permalink / raw)
  To: lm-sensors

Hi Kaiwan,

On Sat, 18 Aug 2007 11:44:22 +0530, Kaiwan N Billimoria wrote:
> > @@ -115,7 +123,8 @@ static int __devinit lm70_probe(struct s
> >  	}
> >  	dev_set_drvdata(&spi->dev, p_lm70);
> >  
> > -	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))) {
> > +	if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))
> > +	 || (status = device_create_file(&spi->dev, &dev_attr_name))) {
> >  		dev_dbg(&spi->dev, "device_create_file failure.\n");
> >  		goto out_dev_create_file_failed;
> >  	}
> > @@ -123,6 +132,7 @@ static int __devinit lm70_probe(struct s
> >  	return 0;
> >  
> >  out_dev_create_file_failed:
> > +	device_remove_file(&spi->dev, &dev_attr_temp1_input);
>
> Ah. Thanks!
> 
> >  	hwmon_device_unregister(p_lm70->cdev);
> >  out_dev_reg_failed:
> >  	dev_set_drvdata(&spi->dev, NULL);

Just to make it clear: there was no bug there. This call to
device_remove_file() is now needed in the case where the temp1_input
file would be successfully created but the name file creation would
fail.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute
  2007-08-17 15:31 [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute Jean Delvare
                   ` (2 preceding siblings ...)
  2007-08-18 14:07 ` Jean Delvare
@ 2007-08-26 18:50 ` Mark M. Hoffman
  3 siblings, 0 replies; 5+ messages in thread
From: Mark M. Hoffman @ 2007-08-26 18:50 UTC (permalink / raw)
  To: lm-sensors

* Hans de Goede <j.w.r.degoede@hhs.nl> [2007-08-17 18:17:52 +0200]:
> Jean Delvare wrote:
> > Add a name attribute to the lm70 devices. This is required for
> > libsensors to recognize them.
> > 
> > Also drop the "+" before the temperature value, even though it did
> > not cause problems to libsensors, other hardware monitoring drivers
> > don't print it, so it's more consistent that way.
> > 
> > Signed-off-by: Jean Delvare <khali@linux-fr.org>
> 
> Looks good to me.
> 
> Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl>

Applied to hwmon-2.6.git/testing, thanks.

-- 
Mark M. Hoffman
mhoffman@lightlink.com


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-26 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-17 15:31 [lm-sensors] [PATCH] hwmon/lm70: Add a name attribute Jean Delvare
2007-08-17 16:17 ` Hans de Goede
2007-08-18  6:26 ` Kaiwan N Billimoria
2007-08-18 14:07 ` Jean Delvare
2007-08-26 18:50 ` Mark M. Hoffman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.