USB: s3c_hsotg: define USB_GADGET_DUALSPEED in Kconfig
[safe/jmp/linux-2.6] / drivers / hwmon / lm87.c
index fa0e379..f1e6e75 100644 (file)
  *   http://www.national.com/pf/LM/LM87.html
  *
  * Some functions share pins, so not all functions are available at the same
- * time. Which are depends on the hardware setup. This driver assumes that
- * the BIOS configured the chip correctly. In that respect, it  differs from
- * the original driver (from lm_sensors for Linux 2.4), which would force the
- * LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
- * chipset wiring.
+ * time. Which are depends on the hardware setup. This driver normally
+ * assumes that firmware configured the chip correctly. Where this is not
+ * the case, platform code must set the I2C client's platform_data to point
+ * to a u8 value to be written to the channel register.
  * For reference, here is the list of exclusive functions:
  *  - in0+in5 (default) or temp3
  *  - fan1 (default) or in6
 
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_2(lm87, adm1024);
+enum chips { lm87, adm1024 };
 
 /*
  * The LM87 registers
@@ -159,7 +154,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };
 
 static int lm87_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
-static int lm87_detect(struct i2c_client *new_client, int kind,
+static int lm87_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info);
 static void lm87_init_client(struct i2c_client *client);
 static int lm87_remove(struct i2c_client *client);
@@ -185,7 +180,7 @@ static struct i2c_driver lm87_driver = {
        .remove         = lm87_remove,
        .id_table       = lm87_id,
        .detect         = lm87_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -663,41 +658,36 @@ static const struct attribute_group lm87_group_opt = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm87_detect(struct i2c_client *new_client, int kind,
+static int lm87_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
-       static const char *names[] = { "lm87", "adm1024" };
+       const char *name;
+       u8 cid, rev;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -ENODEV;
 
-       /* Default to an LM87 if forced */
-       if (kind == 0)
-               kind = lm87;
+       if (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)
+               return -ENODEV;
 
        /* Now, we do the remaining detection. */
-       if (kind < 0) {
-               u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID);
-               u8 rev = lm87_read_value(new_client, LM87_REG_REVISION);
-
-               if (cid == 0x02                 /* National Semiconductor */
-                && (rev >= 0x01 && rev <= 0x08))
-                       kind = lm87;
-               else if (cid == 0x41            /* Analog Devices */
-                     && (rev & 0xf0) == 0x10)
-                       kind = adm1024;
-
-               if (kind < 0
-                || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) {
-                       dev_dbg(&adapter->dev,
-                               "LM87 detection failed at 0x%02x.\n",
-                               new_client->addr);
-                       return -ENODEV;
-               }
+       cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID);
+       rev = lm87_read_value(new_client, LM87_REG_REVISION);
+
+       if (cid == 0x02                 /* National Semiconductor */
+        && (rev >= 0x01 && rev <= 0x08))
+               name = "lm87";
+       else if (cid == 0x41            /* Analog Devices */
+             && (rev & 0xf0) == 0x10)
+               name = "adm1024";
+       else {
+               dev_dbg(&adapter->dev, "LM87 detection failed at 0x%02x\n",
+                       new_client->addr);
+               return -ENODEV;
        }
 
-       strlcpy(info->type, names[kind - 1], I2C_NAME_SIZE);
+       strlcpy(info->type, name, I2C_NAME_SIZE);
 
        return 0;
 }
@@ -843,7 +833,13 @@ static void lm87_init_client(struct i2c_client *client)
 {
        struct lm87_data *data = i2c_get_clientdata(client);
 
-       data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
+       if (client->dev.platform_data) {
+               data->channel = *(u8 *)client->dev.platform_data;
+               lm87_write_value(client,
+                                LM87_REG_CHANNEL_MODE, data->channel);
+       } else {
+               data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
+       }
        data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F;
 
        if (!(data->config & 0x01)) {