Skip to contentSkip to conversation

hwmon: Add support for MAX6642

PATCH In review Per Dalén 2 participants 6 messages Apr 6, 2011

Subsystems (2)
lore
Share & tools
lore

Per Dalén

author
#0 lore raw

PATCH v4 1/1 hwmon: Add support for MAX6642

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim.

---

Documentation/hwmon/max6642 new file +21 -0
new file mode 100644
index 0000000..afbd3e4
@@ -0,0 +1,21 @@
+Kernel driver max6642
+=====================
+
+Supported chips:
+  * Maxim MAX6642
+    Prefix: 'max6642'
+    Addresses scanned: I2C 0x48-0x4f
+    Datasheet: Publicly available at the Maxim website
+               http://datasheets.maxim-ic.com/en/ds/MAX6642.pdf
+
+Authors:
+        Per Dalen <[email protected]>
+
+Description
+-----------
+
+The MAX6642 is a digital temperature sensor. It senses its own temperature as
+well as the temperature on one external diode.
+
+All temperature values are given in degrees Celsius. Resolution
+is 0.25 degree for the local temperature and for the remote temperature.
drivers/hwmon/Kconfig +11 -0
index 060ef63..e9a3d7a 100644
@@ -728,6 +728,17 @@ config SENSORS_MAX6639
 	  This driver can also be built as a module.  If so, the module
 	  will be called max6639.
 
+config SENSORS_MAX6642
+	tristate "Maxim MAX6642 sensor chip"
+	depends on I2C && EXPERIMENTAL
+	help
+	  If you say yes here you get support for MAX6642 sensor chip.
+	  MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor
+	  with Overtemperature Alarm from Maxim.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called max6642.
+
 config SENSORS_MAX6650
 	tristate "Maxim MAX6650 sensor chip"
 	depends on I2C && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
index 967d0ea..2211752 100644
@@ -85,6 +85,7 @@ obj-$(CONFIG_SENSORS_LTC4261)	+= ltc4261.o
 obj-$(CONFIG_SENSORS_MAX1111)	+= max1111.o
 obj-$(CONFIG_SENSORS_MAX1619)	+= max1619.o
 obj-$(CONFIG_SENSORS_MAX6639)	+= max6639.o
+obj-$(CONFIG_SENSORS_MAX6642)	+= max6642.o
 obj-$(CONFIG_SENSORS_MAX6650)	+= max6650.o
 obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
drivers/hwmon/max6642.c new file +359 -0

359 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Hi Per,

Quoted 9 lines · Per Dalén

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

Quoted 4 lines

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim.

Sorry, one more detail I just noticed. More of a question.

[ ... ]

drivers/hwmon/max6642.c line 163

Quoted 10 lines
drivers/hwmon/max6642.c new file +10 -0
+
+static struct max6642_data *max6642_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct max6642_data *data = i2c_get_clientdata(client);
+	u16 val, tmp;
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ * 8) || !data->valid) {

Are you sure you only want to update readings every 8 seconds ?

Also, after spending all this time on this driver (and after falling into the same trap last night with another driver ;), it looks like this is really just another variant of the lm90, and adding support for max6642 to the lm90 driver might be quite trivial. Have you considered this ?

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#2 lore raw
In reply to Per Dalén
Quoted 19 lines · Guenter Roeck

Hi Per,

Quoted 9 lines · Per Dalén

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

Quoted 4 lines

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim.

Sorry, one more detail I just noticed. More of a question.

[ ... ]

Quoted 12 lines

drivers/hwmon/max6642.c line 163

Quoted 10 lines
drivers/hwmon/max6642.c new file +10 -0
+
+static struct max6642_data *max6642_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct max6642_data *data = i2c_get_clientdata(client);
+	u16 val, tmp;
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ * 8) || !data->valid) {

Are you sure you only want to update readings every 8 seconds ?

No, this is wrong from me. Every second, or what do you think?

Quoted 5 lines

Also, after spending all this time on this driver (and after falling into the same trap last night with another driver ;), it looks like this is really just another variant of the lm90, and adding support for max6642 to the lm90 driver might be quite trivial. Have you considered this ?

Hmmm, ;)

"Re: [lm-sensors] [PATCH] hwmon: (lm90) Add support for max6642

On 03/03/2011 08:55 PM, Guenter Roeck wrote:
With all the differences and lacking registers, I wonder if it would be better to write a new driver, either based on this driver of based on the max1619 driver.

Guenter"

Quoted 4 lines

Thanks,
Guenter

br
Per

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Per Dalén
Quoted 33 lines · Per Dalén
Quoted 19 lines · Guenter Roeck

Hi Per,

Quoted 9 lines · Per Dalén

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

Quoted 4 lines

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim.

Sorry, one more detail I just noticed. More of a question.

[ ... ]

Quoted 12 lines

drivers/hwmon/max6642.c line 163

Quoted 10 lines
drivers/hwmon/max6642.c new file +10 -0
+
+static struct max6642_data *max6642_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct max6642_data *data = i2c_get_clientdata(client);
+	u16 val, tmp;
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ * 8) || !data->valid) {

Are you sure you only want to update readings every 8 seconds ?

Quoted 2 lines

No, this is wrong from me. Every second, or what do you think?

Something like that, or HZ + HZ/<fraction> if you want to be fancy.

Quoted 8 lines
Quoted 5 lines

Also, after spending all this time on this driver (and after falling into the same trap last night with another driver ;), it looks like this is really just another variant of the lm90, and adding support for max6642 to the lm90 driver might be quite trivial. Have you considered this ?

Hmmm, ;)

Quoted 9 lines

"Re: [lm-sensors] [PATCH] hwmon: (lm90) Add support for max6642

On 03/03/2011 08:55 PM, Guenter Roeck wrote:
With all the differences and lacking registers, I wonder if it would be better to write a new driver, either based on this driver of based on the max1619 driver.

Guenter"

Guess you got me there. But then this was more than a month ago, and it was my birthday, so who knows how much blood was left in my alcohol ;).

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

author
#4 lore raw
In reply to Per Dalén
Quoted 59 lines · Per Dalén
Quoted 34 lines · Guenter Roeck
Quoted 13 lines

Hi Per,

Quoted 10 lines · Per Dalén

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with

Overtemperature Alarm from Maxim.

Quoted 8 lines
Quoted 3 lines

Sorry, one more detail I just noticed. More of a question.

[ ... ]

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+static struct max6642_data *max6642_update_device(struct device

*dev)

Quoted 8 lines

drivers/hwmon/max6642.c

Quoted 8 lines
drivers/hwmon/max6642.c new file +8 -0
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct max6642_data *data = i2c_get_clientdata(client);
+	u16 val, tmp;
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ * 8) ||

!data->valid) {

Quoted 1 line
Quoted 4 lines
Quoted 1 line

Are you sure you only want to update readings every 8 seconds ?

No, this is wrong from me. Every second, or what do you think?

Something like that, or HZ + HZ/<fraction> if you want to be fancy.

Quoted 18 lines
Quoted 2 lines

Also, after spending all this time on this driver (and after falling

into

Quoted 1 line

the same trap last night with another driver ;), it looks like this is

really

Quoted 1 line

just another variant of the lm90, and adding support for max6642 to

the lm90

Quoted 1 line

driver might be quite trivial. Have you considered this ?

Hmmm, ;)

"Re: [lm-sensors] [PATCH] hwmon: (lm90) Add support for max6642

On 03/03/2011 08:55 PM, Guenter Roeck wrote:
With all the differences and lacking registers, I wonder if it would be better to write a new driver, either based on this driver of based on the max1619 driver.

Quoted 5 lines
Quoted 2 lines

Guenter"

Guess you got me there. But then this was more than a month ago, and it was
my birthday, so who knows how much blood was left in my alcohol ;).

Ok, that is something I can relate to ;)

Do you think I should do the last fix on the max6642 driver or should I add it to lm90?

Quoted 4 lines

Thanks,
Guenter

/Per

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw
In reply to Per Dalén
Quoted 33 lines · Per Dalén
Quoted 19 lines · Guenter Roeck

Hi Per,

Quoted 9 lines · Per Dalén

First a big thanks to Guenter Roeck for helping me (allot) to cleanup this driver

v3 -> v4:
* Removed "data->valid = 0;" (missed that in v3 ;)
* only read the limits once
* changed the temp_input and temp_high as suggested by Guenter, also
changed the functions/macros related to that change

Quoted 4 lines

MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim.

Sorry, one more detail I just noticed. More of a question.

[ ... ]

Quoted 12 lines

drivers/hwmon/max6642.c line 163

Quoted 10 lines
drivers/hwmon/max6642.c new file +10 -0
+
+static struct max6642_data *max6642_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct max6642_data *data = i2c_get_clientdata(client);
+	u16 val, tmp;
+
+	mutex_lock(&data->update_lock);
+
+	if (time_after(jiffies, data->last_updated + HZ * 8) || !data->valid) {

Are you sure you only want to update readings every 8 seconds ?

Quoted 2 lines

No, this is wrong from me. Every second, or what do you think?

No need to re-submit. I applied v4 of your patch, changing the above to HZ.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors