aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fschmd.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-12-09 14:35:57 -0500
committerJean Delvare <khali@linux-fr.org>2009-12-09 14:35:57 -0500
commit52df6440a29123eed912183fe785bbe174ef14b9 (patch)
tree3a3b9f4110d21c2ec4f5711444dd9cec6fb3d32c /drivers/hwmon/fschmd.c
parenta1fa4cdcc4abd4c02a81ab7052c16a342d29f060 (diff)
hwmon: Clean up detect functions
As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Corentin Labbe <corentin.labbe@geomatys.fr> Cc: "Mark M. Hoffman" <mhoffman@lightlink.com> Cc: Juerg Haefliger <juergh@gmail.com> Cc: Riku Voipio <riku.voipio@iki.fi> Acked-by: "Hans J. Koch" <hjk@linutronix.de> Cc: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'drivers/hwmon/fschmd.c')
-rw-r--r--drivers/hwmon/fschmd.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index da1b1f9488af..281829cd1533 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -1000,43 +1000,38 @@ static void fschmd_dmi_decode(const struct dmi_header *header, void *dummy)
1000 } 1000 }
1001} 1001}
1002 1002
1003static int fschmd_detect(struct i2c_client *client, int kind, 1003static int fschmd_detect(struct i2c_client *client, int _kind,
1004 struct i2c_board_info *info) 1004 struct i2c_board_info *info)
1005{ 1005{
1006 enum chips kind;
1006 struct i2c_adapter *adapter = client->adapter; 1007 struct i2c_adapter *adapter = client->adapter;
1008 char id[4];
1007 1009
1008 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1010 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1009 return -ENODEV; 1011 return -ENODEV;
1010 1012
1011 /* Detect & Identify the chip */ 1013 /* Detect & Identify the chip */
1012 if (kind <= 0) { 1014 id[0] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_0);
1013 char id[4]; 1015 id[1] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_1);
1014 1016 id[2] = i2c_smbus_read_byte_data(client, FSCHMD_REG_IDENT_2);
1015 id[0] = i2c_smbus_read_byte_data(client, 1017 id[3] = '\0';
1016 FSCHMD_REG_IDENT_0); 1018
1017 id[1] = i2c_smbus_read_byte_data(client, 1019 if (!strcmp(id, "PEG"))
1018 FSCHMD_REG_IDENT_1); 1020 kind = fscpos;
1019 id[2] = i2c_smbus_read_byte_data(client, 1021 else if (!strcmp(id, "HER"))
1020 FSCHMD_REG_IDENT_2); 1022 kind = fscher;
1021 id[3] = '\0'; 1023 else if (!strcmp(id, "SCY"))
1022 1024 kind = fscscy;
1023 if (!strcmp(id, "PEG")) 1025 else if (!strcmp(id, "HRC"))
1024 kind = fscpos; 1026 kind = fschrc;
1025 else if (!strcmp(id, "HER")) 1027 else if (!strcmp(id, "HMD"))
1026 kind = fscher; 1028 kind = fschmd;
1027 else if (!strcmp(id, "SCY")) 1029 else if (!strcmp(id, "HDS"))
1028 kind = fscscy; 1030 kind = fschds;
1029 else if (!strcmp(id, "HRC")) 1031 else if (!strcmp(id, "SYL"))
1030 kind = fschrc; 1032 kind = fscsyl;
1031 else if (!strcmp(id, "HMD")) 1033 else
1032 kind = fschmd; 1034 return -ENODEV;
1033 else if (!strcmp(id, "HDS"))
1034 kind = fschds;
1035 else if (!strcmp(id, "SYL"))
1036 kind = fscsyl;
1037 else
1038 return -ENODEV;
1039 }
1040 1035
1041 strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE); 1036 strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE);
1042 1037