linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] expose lm90 to thermal fw
@ 2014-02-25  6:21 Wei Ni
  2014-02-25  6:21 ` [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes Wei Ni
  2014-02-25  6:21 ` [PATCH 2/2] hwmon: lm90: expose to thermal fw via DT nodes Wei Ni
  0 siblings, 2 replies; 9+ messages in thread
From: Wei Ni @ 2014-02-25  6:21 UTC (permalink / raw)
  To: khali, linux; +Cc: lm-sensors, linux-kernel, Wei Ni

Expose lm90 to thermal framework via DT nodes.

The [PATCH 1/2] had reviewed in:
http://www.spinics.net/lists/linux-tegra/msg14108.html

Wei Ni (2):
  hwmon: (lm90) split set&show temp as common codes
  hwmon: lm90: expose to thermal fw via DT nodes

 drivers/hwmon/lm90.c |  228 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 173 insertions(+), 55 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  6:21 [PATCH 0/2] expose lm90 to thermal fw Wei Ni
@ 2014-02-25  6:21 ` Wei Ni
  2014-02-25  6:32   ` Guenter Roeck
  2014-02-25  6:21 ` [PATCH 2/2] hwmon: lm90: expose to thermal fw via DT nodes Wei Ni
  1 sibling, 1 reply; 9+ messages in thread
From: Wei Ni @ 2014-02-25  6:21 UTC (permalink / raw)
  To: khali, linux; +Cc: lm-sensors, linux-kernel, Wei Ni

Split set&show temp codes as common functions, so we can use it
directly when implement linux thermal framework.
And handle error return value for the lm90_select_remote_channel
and write_tempx, then set_temp8 and set_temp11 could return it
to user-space.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
---
 drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 115 insertions(+), 55 deletions(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index c9ff08d..fb9e224 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
  * various registers have different meanings as a result of selecting a
  * non-default remote channel.
  */
-static inline void lm90_select_remote_channel(struct i2c_client *client,
-					      struct lm90_data *data,
-					      int channel)
+static inline int lm90_select_remote_channel(struct i2c_client *client,
+					     struct lm90_data *data,
+					     int channel)
 {
 	u8 config;
+	int err;
 
 	if (data->kind == max6696) {
 		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
 		config &= ~0x08;
 		if (channel)
 			config |= 0x08;
-		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
-					  config);
+		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
+						config);
+		if (err < 0) {
+			dev_err(&client->dev,
+				"Failed to select remote channel %d, err %d\n",
+				channel, err);
+			return err;
+		}
 	}
+
+	return 0;
 }
 
 /*
@@ -759,29 +768,34 @@ static u16 temp_to_u16_adt7461(struct lm90_data *data, long val)
  * Sysfs stuff
  */
 
-static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
-			  char *buf)
+static int read_temp8(struct device *dev, int index)
 {
-	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 	struct lm90_data *data = lm90_update_device(dev);
 	int temp;
 
 	if (data->kind == adt7461 || data->kind == tmp451)
-		temp = temp_from_u8_adt7461(data, data->temp8[attr->index]);
+		temp = temp_from_u8_adt7461(data, data->temp8[index]);
 	else if (data->kind == max6646)
-		temp = temp_from_u8(data->temp8[attr->index]);
+		temp = temp_from_u8(data->temp8[index]);
 	else
-		temp = temp_from_s8(data->temp8[attr->index]);
+		temp = temp_from_s8(data->temp8[index]);
 
 	/* +16 degrees offset for temp2 for the LM99 */
-	if (data->kind == lm99 && attr->index == 3)
+	if (data->kind == lm99 && index == 3)
 		temp += 16000;
 
-	return sprintf(buf, "%d\n", temp);
+	return temp;
 }
 
-static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
-			 const char *buf, size_t count)
+static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
+			  char *buf)
+{
+	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+
+	return sprintf(buf, "%d\n", read_temp8(dev, attr->index));
+}
+
+static int write_temp8(struct device *dev, int index, long val)
 {
 	static const u8 reg[TEMP8_REG_NUM] = {
 		LM90_REG_W_LOCAL_LOW,
@@ -794,60 +808,79 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
 		MAX6659_REG_W_REMOTE_EMERG,
 	};
 
-	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 	struct lm90_data *data = dev_get_drvdata(dev);
 	struct i2c_client *client = data->client;
-	int nr = attr->index;
-	long val;
 	int err;
 
-	err = kstrtol(buf, 10, &val);
-	if (err < 0)
-		return err;
-
 	/* +16 degrees offset for temp2 for the LM99 */
-	if (data->kind == lm99 && attr->index == 3)
+	if (data->kind == lm99 && index == 3)
 		val -= 16000;
 
 	mutex_lock(&data->update_lock);
 	if (data->kind == adt7461 || data->kind == tmp451)
-		data->temp8[nr] = temp_to_u8_adt7461(data, val);
+		data->temp8[index] = temp_to_u8_adt7461(data, val);
 	else if (data->kind == max6646)
-		data->temp8[nr] = temp_to_u8(val);
+		data->temp8[index] = temp_to_u8(val);
 	else
-		data->temp8[nr] = temp_to_s8(val);
-
-	lm90_select_remote_channel(client, data, nr >= 6);
-	i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]);
-	lm90_select_remote_channel(client, data, 0);
+		data->temp8[index] = temp_to_s8(val);
 
+	if ((err = lm90_select_remote_channel(client, data, index >= 6)) ||
+	    (err = i2c_smbus_write_byte_data(client, reg[index],
+					     data->temp8[index])) ||
+	    (err = lm90_select_remote_channel(client, data, 0)))
+		dev_err(dev, "write_temp8 failed, err %d\n", err);
 	mutex_unlock(&data->update_lock);
+
+	return err;
+}
+
+static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
+			 const char *buf, size_t count)
+{
+	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	int index = attr->index;
+	long val;
+	int err;
+
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
+		return err;
+
+	err = write_temp8(dev, index, val);
+	if (err < 0)
+		return err;
+
 	return count;
 }
 
-static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
-			   char *buf)
+static int read_temp11(struct device *dev, int index)
 {
-	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
 	struct lm90_data *data = lm90_update_device(dev);
 	int temp;
 
 	if (data->kind == adt7461 || data->kind == tmp451)
-		temp = temp_from_u16_adt7461(data, data->temp11[attr->index]);
+		temp = temp_from_u16_adt7461(data, data->temp11[index]);
 	else if (data->kind == max6646)
-		temp = temp_from_u16(data->temp11[attr->index]);
+		temp = temp_from_u16(data->temp11[index]);
 	else
-		temp = temp_from_s16(data->temp11[attr->index]);
+		temp = temp_from_s16(data->temp11[index]);
 
 	/* +16 degrees offset for temp2 for the LM99 */
-	if (data->kind == lm99 &&  attr->index <= 2)
+	if (data->kind == lm99 && index <= 2)
 		temp += 16000;
 
-	return sprintf(buf, "%d\n", temp);
+	return temp;
 }
 
-static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
-			  const char *buf, size_t count)
+static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
+			   char *buf)
+{
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
+
+	return sprintf(buf, "%d\n", read_temp11(dev, attr->index));
+}
+
+static int write_temp11(struct device *dev, int nr, int index, long val)
 {
 	struct {
 		u8 high;
@@ -861,18 +894,10 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
 		{ LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 1 }
 	};
 
-	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
 	struct lm90_data *data = dev_get_drvdata(dev);
 	struct i2c_client *client = data->client;
-	int nr = attr->nr;
-	int index = attr->index;
-	long val;
 	int err;
 
-	err = kstrtol(buf, 10, &val);
-	if (err < 0)
-		return err;
-
 	/* +16 degrees offset for temp2 for the LM99 */
 	if (data->kind == lm99 && index <= 2)
 		val -= 16000;
@@ -887,15 +912,50 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
 	else
 		data->temp11[index] = temp_to_s8(val) << 8;
 
-	lm90_select_remote_channel(client, data, reg[nr].channel);
-	i2c_smbus_write_byte_data(client, reg[nr].high,
-				  data->temp11[index] >> 8);
-	if (data->flags & LM90_HAVE_REM_LIMIT_EXT)
-		i2c_smbus_write_byte_data(client, reg[nr].low,
-					  data->temp11[index] & 0xff);
-	lm90_select_remote_channel(client, data, 0);
+	err = lm90_select_remote_channel(client, data, reg[nr].channel);
+	if (err)
+		goto error;
+
+	err = i2c_smbus_write_byte_data(client, reg[nr].high,
+					data->temp11[index] >> 8);
+	if (err)
+		goto error;
+
+	if (data->flags & LM90_HAVE_REM_LIMIT_EXT) {
+		err = i2c_smbus_write_byte_data(client, reg[nr].low,
+						data->temp11[index] & 0xff);
+		if (err)
+			goto error;
+	}
+
+	err = lm90_select_remote_channel(client, data, 0);
+
+error:
+	if (err)
+		dev_err(dev, "write_temp11 failed, err %d\n", err);
 
 	mutex_unlock(&data->update_lock);
+
+	return err;
+}
+
+static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
+			  const char *buf, size_t count)
+{
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
+	int nr = attr->nr;
+	int index = attr->index;
+	long val;
+	int err;
+
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
+		return err;
+
+	err = write_temp11(dev, nr, index, val);
+	if (err < 0)
+		return err;
+
 	return count;
 }
 
-- 
1.7.9.5


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

* [PATCH 2/2] hwmon: lm90: expose to thermal fw via DT nodes
  2014-02-25  6:21 [PATCH 0/2] expose lm90 to thermal fw Wei Ni
  2014-02-25  6:21 ` [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes Wei Ni
@ 2014-02-25  6:21 ` Wei Ni
  1 sibling, 0 replies; 9+ messages in thread
From: Wei Ni @ 2014-02-25  6:21 UTC (permalink / raw)
  To: khali, linux; +Cc: lm-sensors, linux-kernel, Wei Ni

This patch adds to lm90 temperature sensor the possibility
to expose itself as thermal zone device, registered on the
thermal framework.

The thermal zone is built only if a device tree node
describing a thermal zone for this sensor is present
inside the lm90 DT node. Otherwise, the driver behavior
will be the same.

Signed-off-by: Wei Ni <wni@nvidia.com>
---
 drivers/hwmon/lm90.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index fb9e224..8f52269 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -96,6 +96,8 @@
 #include <linux/sysfs.h>
 #include <linux/interrupt.h>
 #include <linux/regulator/consumer.h>
+#include <linux/of.h>
+#include <linux/thermal.h>
 
 /*
  * Addresses to scan
@@ -119,6 +121,13 @@ static const unsigned short normal_i2c[] = {
 enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
 	max6646, w83l771, max6696, sa56004, g781, tmp451 };
 
+enum sensor_id {
+	LOCAL = 0,
+	REMOTE,
+	REMOTE2,
+	SENSOR_ID_END,
+};
+
 /*
  * The LM90 registers
  */
@@ -368,6 +377,7 @@ struct lm90_data {
 	struct i2c_client *client;
 	struct device *hwmon_dev;
 	const struct attribute_group *groups[6];
+	struct thermal_zone_device *tz[SENSOR_ID_END];
 	struct mutex update_lock;
 	struct regulator *regulator;
 	char valid; /* zero until following fields are valid */
@@ -880,6 +890,24 @@ static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
 	return sprintf(buf, "%d\n", read_temp11(dev, attr->index));
 }
 
+static int lm90_read_local_temp(void *dev, long *temp)
+{
+	*temp = read_temp11(dev, LOCAL_TEMP);
+	return 0;
+}
+
+static int lm90_read_remote_temp(void *dev, long *temp)
+{
+	*temp = read_temp11(dev, REMOTE_TEMP);
+	return 0;
+}
+
+static int lm90_read_remote2_temp(void *dev, long *temp)
+{
+	*temp = read_temp11(dev, REMOTE2_TEMP);
+	return 0;
+}
+
 static int write_temp11(struct device *dev, int nr, int index, long val)
 {
 	struct {
@@ -1659,6 +1687,33 @@ static int lm90_probe(struct i2c_client *client,
 		}
 	}
 
+	data->tz[LOCAL] = thermal_zone_of_sensor_register(&client->dev,
+							LOCAL,
+							&client->dev,
+							lm90_read_local_temp,
+							NULL);
+	if (IS_ERR(data->tz[LOCAL]))
+		data->tz[LOCAL] = NULL;
+
+	data->tz[REMOTE] = thermal_zone_of_sensor_register(&client->dev,
+							REMOTE,
+							&client->dev,
+							lm90_read_remote_temp,
+							NULL);
+	if (IS_ERR(data->tz[REMOTE]))
+		data->tz[REMOTE] = NULL;
+
+	if (data->flags & LM90_HAVE_TEMP3) {
+		data->tz[REMOTE2] = thermal_zone_of_sensor_register(
+							&client->dev,
+							REMOTE2,
+							&client->dev,
+							lm90_read_remote2_temp,
+							NULL);
+		if (IS_ERR(data->tz[REMOTE2]))
+			data->tz[REMOTE2] = NULL;
+	}
+
 	return 0;
 
 exit_unregister:
@@ -1674,8 +1729,11 @@ exit_restore:
 
 static int lm90_remove(struct i2c_client *client)
 {
+	int i;
 	struct lm90_data *data = i2c_get_clientdata(client);
 
+	for (i = 0; i < SENSOR_ID_END; i++)
+		thermal_zone_of_sensor_unregister(&client->dev, data->tz[i]);
 	hwmon_device_unregister(data->hwmon_dev);
 	device_remove_file(&client->dev, &dev_attr_pec);
 	lm90_restore_conf(client, data);
-- 
1.7.9.5


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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  6:21 ` [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes Wei Ni
@ 2014-02-25  6:32   ` Guenter Roeck
  2014-02-25  8:21     ` Wei Ni
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-02-25  6:32 UTC (permalink / raw)
  To: Wei Ni, khali; +Cc: lm-sensors, linux-kernel

On 02/24/2014 10:21 PM, Wei Ni wrote:
> Split set&show temp codes as common functions, so we can use it
> directly when implement linux thermal framework.
> And handle error return value for the lm90_select_remote_channel
> and write_tempx, then set_temp8 and set_temp11 could return it
> to user-space.
>
> Signed-off-by: Wei Ni <wni@nvidia.com>
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> ---
>   drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
>   1 file changed, 115 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index c9ff08d..fb9e224 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
>    * various registers have different meanings as a result of selecting a
>    * non-default remote channel.
>    */
> -static inline void lm90_select_remote_channel(struct i2c_client *client,
> -					      struct lm90_data *data,
> -					      int channel)
> +static inline int lm90_select_remote_channel(struct i2c_client *client,
> +					     struct lm90_data *data,
> +					     int channel)
>   {
>   	u8 config;
> +	int err;
>
>   	if (data->kind == max6696) {
>   		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
>   		config &= ~0x08;
>   		if (channel)
>   			config |= 0x08;
> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> -					  config);
> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> +						config);
> +		if (err < 0) {
> +			dev_err(&client->dev,
> +				"Failed to select remote channel %d, err %d\n",
> +				channel, err);
> +			return err;

Not my call to make, but I really dislike all that new noisiness.
Sure, it is ok to pass the error back, but in my opinion that is
good enough. If every driver in the kernel would be that noisy,
the log would be all but useless.

Guenter


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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  6:32   ` Guenter Roeck
@ 2014-02-25  8:21     ` Wei Ni
  2014-02-25  8:57       ` Guenter Roeck
  0 siblings, 1 reply; 9+ messages in thread
From: Wei Ni @ 2014-02-25  8:21 UTC (permalink / raw)
  To: Guenter Roeck, khali@linux-fr.org
  Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org

On 02/25/2014 02:32 PM, Guenter Roeck wrote:
> On 02/24/2014 10:21 PM, Wei Ni wrote:
>> Split set&show temp codes as common functions, so we can use it
>> directly when implement linux thermal framework.
>> And handle error return value for the lm90_select_remote_channel
>> and write_tempx, then set_temp8 and set_temp11 could return it
>> to user-space.
>>
>> Signed-off-by: Wei Ni <wni@nvidia.com>
>> Signed-off-by: Jean Delvare <khali@linux-fr.org>
>> ---
>>   drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
>>   1 file changed, 115 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>> index c9ff08d..fb9e224 100644
>> --- a/drivers/hwmon/lm90.c
>> +++ b/drivers/hwmon/lm90.c
>> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
>>    * various registers have different meanings as a result of selecting a
>>    * non-default remote channel.
>>    */
>> -static inline void lm90_select_remote_channel(struct i2c_client *client,
>> -					      struct lm90_data *data,
>> -					      int channel)
>> +static inline int lm90_select_remote_channel(struct i2c_client *client,
>> +					     struct lm90_data *data,
>> +					     int channel)
>>   {
>>   	u8 config;
>> +	int err;
>>
>>   	if (data->kind == max6696) {
>>   		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
>>   		config &= ~0x08;
>>   		if (channel)
>>   			config |= 0x08;
>> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>> -					  config);
>> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>> +						config);
>> +		if (err < 0) {
>> +			dev_err(&client->dev,
>> +				"Failed to select remote channel %d, err %d\n",
>> +				channel, err);
>> +			return err;
> 
> Not my call to make, but I really dislike all that new noisiness.
> Sure, it is ok to pass the error back, but in my opinion that is
> good enough. If every driver in the kernel would be that noisy,
> the log would be all but useless.

This was discussed in https://lkml.org/lkml/2013/12/227
Jean wish to catch and return write errors,then the set_temp8() could
return error to user-space.

Thanks.
Wei.

> 
> Guenter
> 


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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  8:21     ` Wei Ni
@ 2014-02-25  8:57       ` Guenter Roeck
  2014-02-25  9:21         ` Wei Ni
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-02-25  8:57 UTC (permalink / raw)
  To: Wei Ni, khali@linux-fr.org
  Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org

On 02/25/2014 12:21 AM, Wei Ni wrote:
> On 02/25/2014 02:32 PM, Guenter Roeck wrote:
>> On 02/24/2014 10:21 PM, Wei Ni wrote:
>>> Split set&show temp codes as common functions, so we can use it
>>> directly when implement linux thermal framework.
>>> And handle error return value for the lm90_select_remote_channel
>>> and write_tempx, then set_temp8 and set_temp11 could return it
>>> to user-space.
>>>
>>> Signed-off-by: Wei Ni <wni@nvidia.com>
>>> Signed-off-by: Jean Delvare <khali@linux-fr.org>
>>> ---
>>>    drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
>>>    1 file changed, 115 insertions(+), 55 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>>> index c9ff08d..fb9e224 100644
>>> --- a/drivers/hwmon/lm90.c
>>> +++ b/drivers/hwmon/lm90.c
>>> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
>>>     * various registers have different meanings as a result of selecting a
>>>     * non-default remote channel.
>>>     */
>>> -static inline void lm90_select_remote_channel(struct i2c_client *client,
>>> -					      struct lm90_data *data,
>>> -					      int channel)
>>> +static inline int lm90_select_remote_channel(struct i2c_client *client,
>>> +					     struct lm90_data *data,
>>> +					     int channel)
>>>    {
>>>    	u8 config;
>>> +	int err;
>>>
>>>    	if (data->kind == max6696) {
>>>    		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
>>>    		config &= ~0x08;
>>>    		if (channel)
>>>    			config |= 0x08;
>>> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>> -					  config);
>>> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>> +						config);
>>> +		if (err < 0) {
>>> +			dev_err(&client->dev,
>>> +				"Failed to select remote channel %d, err %d\n",
>>> +				channel, err);
>>> +			return err;
>>
>> Not my call to make, but I really dislike all that new noisiness.
>> Sure, it is ok to pass the error back, but in my opinion that is
>> good enough. If every driver in the kernel would be that noisy,
>> the log would be all but useless.
>
> This was discussed in https://lkml.org/lkml/2013/12/227
> Jean wish to catch and return write errors,then the set_temp8() could
> return error to user-space.
>

The link doesn't work for me. Anyway, catching write errors and being
noisy about it are different issues, and I am a bit surprised that
Jean wants the driver to be noisy about it, but if so I won't object.

Guenter


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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  8:57       ` Guenter Roeck
@ 2014-02-25  9:21         ` Wei Ni
  2014-02-25 16:06           ` Guenter Roeck
  0 siblings, 1 reply; 9+ messages in thread
From: Wei Ni @ 2014-02-25  9:21 UTC (permalink / raw)
  To: Guenter Roeck, khali@linux-fr.org
  Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org

On 02/25/2014 04:57 PM, Guenter Roeck wrote:
> On 02/25/2014 12:21 AM, Wei Ni wrote:
>> On 02/25/2014 02:32 PM, Guenter Roeck wrote:
>>> On 02/24/2014 10:21 PM, Wei Ni wrote:
>>>> Split set&show temp codes as common functions, so we can use it
>>>> directly when implement linux thermal framework.
>>>> And handle error return value for the lm90_select_remote_channel
>>>> and write_tempx, then set_temp8 and set_temp11 could return it
>>>> to user-space.
>>>>
>>>> Signed-off-by: Wei Ni <wni@nvidia.com>
>>>> Signed-off-by: Jean Delvare <khali@linux-fr.org>
>>>> ---
>>>>    drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
>>>>    1 file changed, 115 insertions(+), 55 deletions(-)
>>>>
>>>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>>>> index c9ff08d..fb9e224 100644
>>>> --- a/drivers/hwmon/lm90.c
>>>> +++ b/drivers/hwmon/lm90.c
>>>> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
>>>>     * various registers have different meanings as a result of selecting a
>>>>     * non-default remote channel.
>>>>     */
>>>> -static inline void lm90_select_remote_channel(struct i2c_client *client,
>>>> -					      struct lm90_data *data,
>>>> -					      int channel)
>>>> +static inline int lm90_select_remote_channel(struct i2c_client *client,
>>>> +					     struct lm90_data *data,
>>>> +					     int channel)
>>>>    {
>>>>    	u8 config;
>>>> +	int err;
>>>>
>>>>    	if (data->kind == max6696) {
>>>>    		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
>>>>    		config &= ~0x08;
>>>>    		if (channel)
>>>>    			config |= 0x08;
>>>> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>>> -					  config);
>>>> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>>> +						config);
>>>> +		if (err < 0) {
>>>> +			dev_err(&client->dev,
>>>> +				"Failed to select remote channel %d, err %d\n",
>>>> +				channel, err);
>>>> +			return err;
>>>
>>> Not my call to make, but I really dislike all that new noisiness.
>>> Sure, it is ok to pass the error back, but in my opinion that is
>>> good enough. If every driver in the kernel would be that noisy,
>>> the log would be all but useless.
>>
>> This was discussed in https://lkml.org/lkml/2013/12/227
>> Jean wish to catch and return write errors,then the set_temp8() could
>> return error to user-space.
>>
> 
> The link doesn't work for me. Anyway, catching write errors and being
> noisy about it are different issues, and I am a bit surprised that
> Jean wants the driver to be noisy about it, but if so I won't object.

Sorry, the link should be https://lkml.org/lkml/2013/7/12/227

> 
> Guenter
> 


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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25  9:21         ` Wei Ni
@ 2014-02-25 16:06           ` Guenter Roeck
  2014-02-28  3:21             ` Wei Ni
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-02-25 16:06 UTC (permalink / raw)
  To: Wei Ni
  Cc: khali@linux-fr.org, lm-sensors@lm-sensors.org,
	linux-kernel@vger.kernel.org

On Tue, Feb 25, 2014 at 05:21:40PM +0800, Wei Ni wrote:
> On 02/25/2014 04:57 PM, Guenter Roeck wrote:
> > On 02/25/2014 12:21 AM, Wei Ni wrote:
> >> On 02/25/2014 02:32 PM, Guenter Roeck wrote:
> >>> On 02/24/2014 10:21 PM, Wei Ni wrote:
> >>>> Split set&show temp codes as common functions, so we can use it
> >>>> directly when implement linux thermal framework.
> >>>> And handle error return value for the lm90_select_remote_channel
> >>>> and write_tempx, then set_temp8 and set_temp11 could return it
> >>>> to user-space.
> >>>>
> >>>> Signed-off-by: Wei Ni <wni@nvidia.com>
> >>>> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> >>>> ---
> >>>>    drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
> >>>>    1 file changed, 115 insertions(+), 55 deletions(-)
> >>>>
> >>>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> >>>> index c9ff08d..fb9e224 100644
> >>>> --- a/drivers/hwmon/lm90.c
> >>>> +++ b/drivers/hwmon/lm90.c
> >>>> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
> >>>>     * various registers have different meanings as a result of selecting a
> >>>>     * non-default remote channel.
> >>>>     */
> >>>> -static inline void lm90_select_remote_channel(struct i2c_client *client,
> >>>> -					      struct lm90_data *data,
> >>>> -					      int channel)
> >>>> +static inline int lm90_select_remote_channel(struct i2c_client *client,
> >>>> +					     struct lm90_data *data,
> >>>> +					     int channel)
> >>>>    {
> >>>>    	u8 config;
> >>>> +	int err;
> >>>>
> >>>>    	if (data->kind == max6696) {
> >>>>    		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
> >>>>    		config &= ~0x08;
> >>>>    		if (channel)
> >>>>    			config |= 0x08;
> >>>> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> >>>> -					  config);
> >>>> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
> >>>> +						config);
> >>>> +		if (err < 0) {
> >>>> +			dev_err(&client->dev,
> >>>> +				"Failed to select remote channel %d, err %d\n",
> >>>> +				channel, err);
> >>>> +			return err;
> >>>
> >>> Not my call to make, but I really dislike all that new noisiness.
> >>> Sure, it is ok to pass the error back, but in my opinion that is
> >>> good enough. If every driver in the kernel would be that noisy,
> >>> the log would be all but useless.
> >>
> >> This was discussed in https://lkml.org/lkml/2013/12/227
> >> Jean wish to catch and return write errors,then the set_temp8() could
> >> return error to user-space.
> >>
> > 
> > The link doesn't work for me. Anyway, catching write errors and being
> > noisy about it are different issues, and I am a bit surprised that
> > Jean wants the driver to be noisy about it, but if so I won't object.
> 
> Sorry, the link should be https://lkml.org/lkml/2013/7/12/227
> 
FWIW, Jean was asking for errors to be detected and be reported to the user,
not to create log messages to the console for each error.

Guenter

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

* Re: [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes
  2014-02-25 16:06           ` Guenter Roeck
@ 2014-02-28  3:21             ` Wei Ni
  0 siblings, 0 replies; 9+ messages in thread
From: Wei Ni @ 2014-02-28  3:21 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: khali@linux-fr.org, lm-sensors@lm-sensors.org,
	linux-kernel@vger.kernel.org

On 02/26/2014 12:06 AM, Guenter Roeck wrote:
> On Tue, Feb 25, 2014 at 05:21:40PM +0800, Wei Ni wrote:
>> On 02/25/2014 04:57 PM, Guenter Roeck wrote:
>>> On 02/25/2014 12:21 AM, Wei Ni wrote:
>>>> On 02/25/2014 02:32 PM, Guenter Roeck wrote:
>>>>> On 02/24/2014 10:21 PM, Wei Ni wrote:
>>>>>> Split set&show temp codes as common functions, so we can use it
>>>>>> directly when implement linux thermal framework.
>>>>>> And handle error return value for the lm90_select_remote_channel
>>>>>> and write_tempx, then set_temp8 and set_temp11 could return it
>>>>>> to user-space.
>>>>>>
>>>>>> Signed-off-by: Wei Ni <wni@nvidia.com>
>>>>>> Signed-off-by: Jean Delvare <khali@linux-fr.org>
>>>>>> ---
>>>>>>    drivers/hwmon/lm90.c |  170 ++++++++++++++++++++++++++++++++++----------------
>>>>>>    1 file changed, 115 insertions(+), 55 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>>>>>> index c9ff08d..fb9e224 100644
>>>>>> --- a/drivers/hwmon/lm90.c
>>>>>> +++ b/drivers/hwmon/lm90.c
>>>>>> @@ -473,20 +473,29 @@ static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
>>>>>>     * various registers have different meanings as a result of selecting a
>>>>>>     * non-default remote channel.
>>>>>>     */
>>>>>> -static inline void lm90_select_remote_channel(struct i2c_client *client,
>>>>>> -					      struct lm90_data *data,
>>>>>> -					      int channel)
>>>>>> +static inline int lm90_select_remote_channel(struct i2c_client *client,
>>>>>> +					     struct lm90_data *data,
>>>>>> +					     int channel)
>>>>>>    {
>>>>>>    	u8 config;
>>>>>> +	int err;
>>>>>>
>>>>>>    	if (data->kind == max6696) {
>>>>>>    		lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
>>>>>>    		config &= ~0x08;
>>>>>>    		if (channel)
>>>>>>    			config |= 0x08;
>>>>>> -		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>>>>> -					  config);
>>>>>> +		err = i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>>>>> +						config);
>>>>>> +		if (err < 0) {
>>>>>> +			dev_err(&client->dev,
>>>>>> +				"Failed to select remote channel %d, err %d\n",
>>>>>> +				channel, err);
>>>>>> +			return err;
>>>>>
>>>>> Not my call to make, but I really dislike all that new noisiness.
>>>>> Sure, it is ok to pass the error back, but in my opinion that is
>>>>> good enough. If every driver in the kernel would be that noisy,
>>>>> the log would be all but useless.
>>>>
>>>> This was discussed in https://lkml.org/lkml/2013/12/227
>>>> Jean wish to catch and return write errors,then the set_temp8() could
>>>> return error to user-space.
>>>>
>>>
>>> The link doesn't work for me. Anyway, catching write errors and being
>>> noisy about it are different issues, and I am a bit surprised that
>>> Jean wants the driver to be noisy about it, but if so I won't object.
>>
>> Sorry, the link should be https://lkml.org/lkml/2013/7/12/227
>>
> FWIW, Jean was asking for errors to be detected and be reported to the user,
> not to create log messages to the console for each error.

Sorry for late reply, I'm busy on other issues these days.
I will remove that log messages, and will try to add this node in dts
file for our tegra board.
I will send out patch next week.

Wei.

> 
> Guenter
> 


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

end of thread, other threads:[~2014-02-28  3:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-25  6:21 [PATCH 0/2] expose lm90 to thermal fw Wei Ni
2014-02-25  6:21 ` [PATCH 1/2] hwmon: (lm90) split set&show temp as common codes Wei Ni
2014-02-25  6:32   ` Guenter Roeck
2014-02-25  8:21     ` Wei Ni
2014-02-25  8:57       ` Guenter Roeck
2014-02-25  9:21         ` Wei Ni
2014-02-25 16:06           ` Guenter Roeck
2014-02-28  3:21             ` Wei Ni
2014-02-25  6:21 ` [PATCH 2/2] hwmon: lm90: expose to thermal fw via DT nodes Wei Ni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).