* [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2013-10-08 7:04 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2013-10-08 7:04 UTC (permalink / raw)
To: khali-PUYAD+kWke1g9hUCZPvPmw
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 113 insertions(+), 53 deletions(-)
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 3f51680..82a1ca15 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -424,20 +424,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,
+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;
}
/*
@@ -704,29 +713,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)
- 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[8] = {
LM90_REG_W_LOCAL_LOW,
@@ -739,60 +753,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 i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(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->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 %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)
- 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;
@@ -806,18 +839,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 i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(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;
@@ -832,15 +857,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 %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] 16+ messages in thread* [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2013-10-08 7:04 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2013-10-08 7:04 UTC (permalink / raw)
To: khali-PUYAD+kWke1g9hUCZPvPmw
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, 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>
---
drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 113 insertions(+), 53 deletions(-)
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 3f51680..82a1ca15 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -424,20 +424,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,
+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;
}
/*
@@ -704,29 +713,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)
- 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[8] = {
LM90_REG_W_LOCAL_LOW,
@@ -739,60 +753,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 i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(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->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 %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)
- 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;
@@ -806,18 +839,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 i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(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;
@@ -832,15 +857,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 %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
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 16+ messages in thread[parent not found: <1381215866-20608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <1381215866-20608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-10-08 7:10 ` Wei Ni
2013-10-11 7:17 ` [lm-sensors] " Jean Delvare
1 sibling, 0 replies; 16+ messages in thread
From: Wei Ni @ 2013-10-08 7:10 UTC (permalink / raw)
To: Wei Ni
Cc: khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
The previous version is in https://lkml.org/lkml/2013/8/6/170 .
Changes from v4:
Couple of changes to get right error codes, as per Jean's review.
On 10/08/2013 03:04 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 113 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 3f51680..82a1ca15 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -424,20 +424,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,
> +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;
> }
>
> /*
> @@ -704,29 +713,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)
> - 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[8] = {
> LM90_REG_W_LOCAL_LOW,
> @@ -739,60 +753,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 i2c_client *client = to_i2c_client(dev);
> struct lm90_data *data = i2c_get_clientdata(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->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 %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)
> - 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;
> @@ -806,18 +839,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 i2c_client *client = to_i2c_client(dev);
> struct lm90_data *data = i2c_get_clientdata(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;
> @@ -832,15 +857,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 %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;
> }
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2013-10-08 7:10 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2013-10-08 7:10 UTC (permalink / raw)
To: Wei Ni
Cc: khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
The previous version is in https://lkml.org/lkml/2013/8/6/170 .
Changes from v4:
Couple of changes to get right error codes, as per Jean's review.
On 10/08/2013 03:04 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>
> ---
> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 113 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 3f51680..82a1ca15 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -424,20 +424,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,
> +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;
> }
>
> /*
> @@ -704,29 +713,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)
> - 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[8] = {
> LM90_REG_W_LOCAL_LOW,
> @@ -739,60 +753,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 i2c_client *client = to_i2c_client(dev);
> struct lm90_data *data = i2c_get_clientdata(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->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 %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)
> - 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;
> @@ -806,18 +839,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 i2c_client *client = to_i2c_client(dev);
> struct lm90_data *data = i2c_get_clientdata(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;
> @@ -832,15 +857,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 %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;
> }
>
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <1381215866-20608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2013-10-11 7:17 ` Jean Delvare
2013-10-11 7:17 ` [lm-sensors] " Jean Delvare
1 sibling, 0 replies; 16+ messages in thread
From: Jean Delvare @ 2013-10-11 7:17 UTC (permalink / raw)
To: Wei Ni
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 113 insertions(+), 53 deletions(-)
> (...)
Applied with minor edits, thanks.
--
Jean Delvare
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2013-10-11 7:17 ` Jean Delvare
0 siblings, 0 replies; 16+ messages in thread
From: Jean Delvare @ 2013-10-11 7:17 UTC (permalink / raw)
To: Wei Ni
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
On Tue, 8 Oct 2013 15:04:26 +0800, 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>
> ---
> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 113 insertions(+), 53 deletions(-)
> (...)
Applied with minor edits, thanks.
--
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] 16+ messages in thread
[parent not found: <20131011091741.59cdaf31-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <20131011091741.59cdaf31-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2014-02-22 10:47 ` Jean Delvare
2015-04-21 10:19 ` [lm-sensors] " Wei Ni
2015-04-22 1:57 ` [lm-sensors] " Wei Ni
2 siblings, 0 replies; 16+ messages in thread
From: Jean Delvare @ 2014-02-22 10:47 UTC (permalink / raw)
To: Wei Ni, Guenter Roeck
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA
On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
> On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > ---
> > drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> > 1 file changed, 113 insertions(+), 53 deletions(-)
> > (...)
>
> Applied with minor edits, thanks.
Wei, what's the status? With Guenter's recent cleanup of the lm90
driver, this patch no longer applies. I never sent it upstream as it
makes no sense without users of the new functions defined by the patch.
Will this ever happen?
For now I am discarding this patch. If it still needed, please rebase
on top of the current lm90 patch set:
http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
and resend.
Thanks,
--
Jean Delvare
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2014-02-22 10:47 ` Jean Delvare
0 siblings, 0 replies; 16+ messages in thread
From: Jean Delvare @ 2014-02-22 10:47 UTC (permalink / raw)
To: Wei Ni, Guenter Roeck
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA
On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
> On Tue, 8 Oct 2013 15:04:26 +0800, 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>
> > ---
> > drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
> > 1 file changed, 113 insertions(+), 53 deletions(-)
> > (...)
>
> Applied with minor edits, thanks.
Wei, what's the status? With Guenter's recent cleanup of the lm90
driver, this patch no longer applies. I never sent it upstream as it
makes no sense without users of the new functions defined by the patch.
Will this ever happen?
For now I am discarding this patch. If it still needed, please rebase
on top of the current lm90 patch set:
http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
and resend.
Thanks,
--
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] 16+ messages in thread
[parent not found: <20140222114735.38d36f4a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>]
* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <20140222114735.38d36f4a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2014-02-22 17:37 ` Guenter Roeck
2014-02-24 8:07 ` Wei Ni
1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-02-22 17:37 UTC (permalink / raw)
To: Jean Delvare, Wei Ni
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA
On 02/22/2014 02:47 AM, Jean Delvare wrote:
> On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
>> On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>>> ---
>>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>>> 1 file changed, 113 insertions(+), 53 deletions(-)
>>> (...)
>>
>> Applied with minor edits, thanks.
>
> Wei, what's the status? With Guenter's recent cleanup of the lm90
> driver, this patch no longer applies. I never sent it upstream as it
> makes no sense without users of the new functions defined by the patch.
> Will this ever happen?
>
> For now I am discarding this patch. If it still needed, please rebase
> on top of the current lm90 patch set:
> http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
> and resend.
>
I am still dreaming of somehow coming up with a new hwmon api that would move
the sysfs ABI into the hwmon core and only provide raw read/write functions
in the drivers. iio manages to do that, after all, so we should be able to
do it as well. Unfortunately everything I tried or have seen so far ended up
making the code more complex, defeating the idea.
On the other side, if we have more and more of those dual-mode drivers,
it might make sense to put more thought into it. After all, if the drivers
have to provide the raw access functions anyway, it would be neat if we
can just pass those to the hwmon core (and possibly instantiate the thermal
device from there and not from each driver).
Guenter
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2014-02-22 17:37 ` Guenter Roeck
0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-02-22 17:37 UTC (permalink / raw)
To: Jean Delvare, Wei Ni
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA
On 02/22/2014 02:47 AM, Jean Delvare wrote:
> On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
>> On Tue, 8 Oct 2013 15:04:26 +0800, 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>
>>> ---
>>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>>> 1 file changed, 113 insertions(+), 53 deletions(-)
>>> (...)
>>
>> Applied with minor edits, thanks.
>
> Wei, what's the status? With Guenter's recent cleanup of the lm90
> driver, this patch no longer applies. I never sent it upstream as it
> makes no sense without users of the new functions defined by the patch.
> Will this ever happen?
>
> For now I am discarding this patch. If it still needed, please rebase
> on top of the current lm90 patch set:
> http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
> and resend.
>
I am still dreaming of somehow coming up with a new hwmon api that would move
the sysfs ABI into the hwmon core and only provide raw read/write functions
in the drivers. iio manages to do that, after all, so we should be able to
do it as well. Unfortunately everything I tried or have seen so far ended up
making the code more complex, defeating the idea.
On the other side, if we have more and more of those dual-mode drivers,
it might make sense to put more thought into it. After all, if the drivers
have to provide the raw access functions anyway, it would be neat if we
can just pass those to the hwmon core (and possibly instantiate the thermal
device from there and not from each driver).
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <20140222114735.38d36f4a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2014-02-24 8:07 ` Wei Ni
2014-02-24 8:07 ` Wei Ni
1 sibling, 0 replies; 16+ messages in thread
From: Wei Ni @ 2014-02-24 8:07 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
On 02/22/2014 06:47 PM, Jean Delvare wrote:
> On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
>> On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>>> ---
>>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>>> 1 file changed, 113 insertions(+), 53 deletions(-)
>>> (...)
>>
>> Applied with minor edits, thanks.
>
> Wei, what's the status? With Guenter's recent cleanup of the lm90
> driver, this patch no longer applies. I never sent it upstream as it
> makes no sense without users of the new functions defined by the patch.
> Will this ever happen?
>
> For now I am discarding this patch. If it still needed, please rebase
> on top of the current lm90 patch set:
> http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
> and resend.
Hi, Jean
Sorry for no updates on this patch.
I noticed that in lm75.c, it expose itself as thermal zone device and
register on the thermal framework, so I will also implement it for
lm90.c, base on this patch.
Thanks.
>
> Thanks,
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2014-02-24 8:07 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2014-02-24 8:07 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
On 02/22/2014 06:47 PM, Jean Delvare wrote:
> On Fri, 11 Oct 2013 09:17:41 +0200, Jean Delvare wrote:
>> On Tue, 8 Oct 2013 15:04:26 +0800, 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>
>>> ---
>>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>>> 1 file changed, 113 insertions(+), 53 deletions(-)
>>> (...)
>>
>> Applied with minor edits, thanks.
>
> Wei, what's the status? With Guenter's recent cleanup of the lm90
> driver, this patch no longer applies. I never sent it upstream as it
> makes no sense without users of the new functions defined by the patch.
> Will this ever happen?
>
> For now I am discarding this patch. If it still needed, please rebase
> on top of the current lm90 patch set:
> http://jdelvare.nerim.net/devel/linux-3/jdelvare-hwmon/
> and resend.
Hi, Jean
Sorry for no updates on this patch.
I noticed that in lm75.c, it expose itself as thermal zone device and
register on the thermal framework, so I will also implement it for
lm90.c, base on this patch.
Thanks.
>
> Thanks,
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <20131011091741.59cdaf31-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-04-21 10:19 ` Wei Ni
2015-04-21 10:19 ` [lm-sensors] " Wei Ni
2015-04-22 1:57 ` [lm-sensors] " Wei Ni
2 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2015-04-21 10:19 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi, Jean
Sorry to trouble you, I recalled that you had applied this change, but I still
can't find it in the mainline.
Could you please check it or does I need to do anything else?
Thanks.
Wei.
On 2013年10月11日 15:17, Jean Delvare wrote:
> On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>> 1 file changed, 113 insertions(+), 53 deletions(-)
>> (...)
>
> Applied with minor edits, thanks.
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2015-04-21 10:19 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2015-04-21 10:19 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
SGksIEplYW4KU29ycnkgdG8gdHJvdWJsZSB5b3UsIEkgcmVjYWxsZWQgdGhhdCB5b3UgaGFkIGFw
cGxpZWQgdGhpcyBjaGFuZ2UsIGJ1dCBJIHN0aWxsCmNhbid0IGZpbmQgaXQgaW4gdGhlIG1haW5s
aW5lLgpDb3VsZCB5b3UgcGxlYXNlIGNoZWNrIGl0IG9yIGRvZXMgSSBuZWVkIHRvIGRvIGFueXRo
aW5nIGVsc2U/CgpUaGFua3MuCldlaS4KCk9uIDIwMTPlubQxMOaciDEx5pelIDE1OjE3LCBKZWFu
IERlbHZhcmUgd3JvdGU6Cj4gT24gVHVlLCA4IE9jdCAyMDEzIDE1OjA0OjI2ICswODAwLCBXZWkg
Tmkgd3JvdGU6Cj4+IFNwbGl0IHNldCZzaG93IHRlbXAgY29kZXMgYXMgY29tbW9uIGZ1bmN0aW9u
cywgc28gd2UgY2FuIHVzZSBpdAo+PiBkaXJlY3RseSB3aGVuIGltcGxlbWVudCBsaW51eCB0aGVy
bWFsIGZyYW1ld29yay4KPj4gQW5kIGhhbmRsZSBlcnJvciByZXR1cm4gdmFsdWUgZm9yIHRoZSBs
bTkwX3NlbGVjdF9yZW1vdGVfY2hhbm5lbAo+PiBhbmQgd3JpdGVfdGVtcHgsIHRoZW4gc2V0X3Rl
bXA4IGFuZCBzZXRfdGVtcDExIGNvdWxkIHJldHVybiBpdAo+PiB0byB1c2VyLXNwYWNlLgo+Pgo+
PiBTaWduZWQtb2ZmLWJ5OiBXZWkgTmkgPHduaUBudmlkaWEuY29tPgo+PiAtLS0KPj4gIGRyaXZl
cnMvaHdtb24vbG05MC5jIHwgIDE2NiArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr
LS0tLS0tLS0tLS0tLS0tLQo+PiAgMSBmaWxlIGNoYW5nZWQsIDExMyBpbnNlcnRpb25zKCspLCA1
MyBkZWxldGlvbnMoLSkKPj4gKC4uLikKPiAKPiBBcHBsaWVkIHdpdGggbWlub3IgZWRpdHMsIHRo
YW5rcy4KPiAKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
CmxtLXNlbnNvcnMgbWFpbGluZyBsaXN0CmxtLXNlbnNvcnNAbG0tc2Vuc29ycy5vcmcKaHR0cDov
L2xpc3RzLmxtLXNlbnNvcnMub3JnL21haWxtYW4vbGlzdGluZm8vbG0tc2Vuc29ycw=
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5] hwmon: (lm90) split set&show temp as common codes
[not found] ` <20131011091741.59cdaf31-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-04-22 1:57 ` Wei Ni
2015-04-21 10:19 ` [lm-sensors] " Wei Ni
2015-04-22 1:57 ` [lm-sensors] " Wei Ni
2 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2015-04-22 1:57 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi, Jean
Sorry to trouble you, I recalled that you had applied this change, but I still
can't find it in the mainline.
Could you please check it or does I need to do anything else?
Thanks.
Wei.
On 2013年10月11日 15:17, Jean Delvare wrote:
> On Tue, 8 Oct 2013 15:04:26 +0800, 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/hwmon/lm90.c | 166 ++++++++++++++++++++++++++++++++++----------------
>> 1 file changed, 113 insertions(+), 53 deletions(-)
>> (...)
>
> Applied with minor edits, thanks.
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [lm-sensors] [PATCH v5] hwmon: (lm90) split set&show temp as common codes
@ 2015-04-22 1:57 ` Wei Ni
0 siblings, 0 replies; 16+ messages in thread
From: Wei Ni @ 2015-04-22 1:57 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
SGksIEplYW4KU29ycnkgdG8gdHJvdWJsZSB5b3UsIEkgcmVjYWxsZWQgdGhhdCB5b3UgaGFkIGFw
cGxpZWQgdGhpcyBjaGFuZ2UsIGJ1dCBJIHN0aWxsCmNhbid0IGZpbmQgaXQgaW4gdGhlIG1haW5s
aW5lLgpDb3VsZCB5b3UgcGxlYXNlIGNoZWNrIGl0IG9yIGRvZXMgSSBuZWVkIHRvIGRvIGFueXRo
aW5nIGVsc2U/CgpUaGFua3MuCldlaS4KCk9uIDIwMTPlubQxMOaciDEx5pelIDE1OjE3LCBKZWFu
IERlbHZhcmUgd3JvdGU6Cj4gT24gVHVlLCA4IE9jdCAyMDEzIDE1OjA0OjI2ICswODAwLCBXZWkg
Tmkgd3JvdGU6Cj4+IFNwbGl0IHNldCZzaG93IHRlbXAgY29kZXMgYXMgY29tbW9uIGZ1bmN0aW9u
cywgc28gd2UgY2FuIHVzZSBpdAo+PiBkaXJlY3RseSB3aGVuIGltcGxlbWVudCBsaW51eCB0aGVy
bWFsIGZyYW1ld29yay4KPj4gQW5kIGhhbmRsZSBlcnJvciByZXR1cm4gdmFsdWUgZm9yIHRoZSBs
bTkwX3NlbGVjdF9yZW1vdGVfY2hhbm5lbAo+PiBhbmQgd3JpdGVfdGVtcHgsIHRoZW4gc2V0X3Rl
bXA4IGFuZCBzZXRfdGVtcDExIGNvdWxkIHJldHVybiBpdAo+PiB0byB1c2VyLXNwYWNlLgo+Pgo+
PiBTaWduZWQtb2ZmLWJ5OiBXZWkgTmkgPHduaUBudmlkaWEuY29tPgo+PiAtLS0KPj4gIGRyaXZl
cnMvaHdtb24vbG05MC5jIHwgIDE2NiArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr
LS0tLS0tLS0tLS0tLS0tLQo+PiAgMSBmaWxlIGNoYW5nZWQsIDExMyBpbnNlcnRpb25zKCspLCA1
MyBkZWxldGlvbnMoLSkKPj4gKC4uLikKPiAKPiBBcHBsaWVkIHdpdGggbWlub3IgZWRpdHMsIHRo
YW5rcy4KPiAKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
CmxtLXNlbnNvcnMgbWFpbGluZyBsaXN0CmxtLXNlbnNvcnNAbG0tc2Vuc29ycy5vcmcKaHR0cDov
L2xpc3RzLmxtLXNlbnNvcnMub3JnL21haWxtYW4vbGlzdGluZm8vbG0tc2Vuc29ycw=
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-04-22 1:57 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-08 7:04 [PATCH v5] hwmon: (lm90) split set&show temp as common codes Wei Ni
2013-10-08 7:04 ` [lm-sensors] " Wei Ni
[not found] ` <1381215866-20608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-08 7:10 ` Wei Ni
2013-10-08 7:10 ` [lm-sensors] " Wei Ni
2013-10-11 7:17 ` Jean Delvare
2013-10-11 7:17 ` [lm-sensors] " Jean Delvare
[not found] ` <20131011091741.59cdaf31-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-02-22 10:47 ` Jean Delvare
2014-02-22 10:47 ` Jean Delvare
[not found] ` <20140222114735.38d36f4a-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-02-22 17:37 ` Guenter Roeck
2014-02-22 17:37 ` Guenter Roeck
2014-02-24 8:07 ` Wei Ni
2014-02-24 8:07 ` Wei Ni
2015-04-21 10:19 ` Wei Ni
2015-04-21 10:19 ` [lm-sensors] " Wei Ni
2015-04-22 1:57 ` Wei Ni
2015-04-22 1:57 ` [lm-sensors] " Wei Ni
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.