Skip to contentSkip to conversation

I2C: Cleanup lm78 init

PATCH New Jean Delvare 2 participants 2 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 I2C: Cleanup lm78 init

Hi Greg,

This patch cleans the init part of the lm78 driver.

* Do not reset the chip.

* Get rid of useless code, which was accidentally left in when we removed the limit initialization from the driver.

* Do not enable monitoring if it is already enabled (it wouldn't hurt, but since we can avoid it at no cost...)

Similar changes were applied to the Linux 2.4 driver, which I successfully tested on my own LM78 chip.

Please apply,
thanks.

drivers/i2c/chips/lm78.c renamed from drivers/i2c/chips/lm78.c.orig +4 -17
@@ -692,26 +692,12 @@
 /* Called when we have found a new LM78. It should set limits, etc. */
 static void lm78_init_client(struct i2c_client *client)
 {
-	struct lm78_data *data = i2c_get_clientdata(client);
-	int vid;
-
-	/* Reset all except Watchdog values and last conversion values
-	   This sets fan-divs to 2, among others */
-	lm78_write_value(client, LM78_REG_CONFIG, 0x80);
-
-	vid = lm78_read_value(client, LM78_REG_VID_FANDIV) & 0x0f;
-	if (data->type = lm79)
-		vid |-		    (lm78_read_value(client, LM78_REG_CHIPID) & 0x01) << 4;
-	else
-		vid |= 0x10;
-	vid = VID_FROM_REG(vid);
+	u8 config = lm78_read_value(client, LM78_REG_CONFIG);
 
 	/* Start monitoring */
-	lm78_write_value(client, LM78_REG_CONFIG,
-			 (lm78_read_value(client, LM78_REG_CONFIG) & 0xf7)
-			 | 0x01);
-
+	if (!(config & 0x01))
+		lm78_write_value(client, LM78_REG_CONFIG,
+				 (config & 0xf7) | 0x01);
 }
 
 static struct lm78_data *lm78_update_device(struct device *dev)
Signature · 2 lines
Jean "Khali" Delvare
http://khali.linux-fr.org/
Applied
#1 lore raw

PATCH 1/1 I2C: Cleanup lm78 init

Quoted 6 lines · Jean Delvare

Hi Greg,

This patch cleans the init part of the lm78 driver.

* Do not reset the chip.

Quoted 8 lines

* Get rid of useless code, which was accidentally left in when we removed the limit initialization from the driver.

* Do not enable monitoring if it is already enabled (it wouldn't hurt, but since we can avoid it at no cost...)

Similar changes were applied to the Linux 2.4 driver, which I successfully tested on my own LM78 chip.

Applied, thanks.

greg k-h