Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh-2.6
[pandora-kernel.git] / drivers / hwmon / w83781d.c
index 7821178..95221b1 100644 (file)
@@ -57,6 +57,10 @@ I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
                    "{bus, clientaddr, subclientaddr1, subclientaddr2}");
 
+static int reset;
+module_param(reset, bool, 0);
+MODULE_PARM_DESC(reset, "Set to one to reset chip on load");
+
 static int init = 1;
 module_param(init, bool, 0);
 MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization");
@@ -268,9 +272,8 @@ static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter);
 static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind);
 static int w83781d_detach_client(struct i2c_client *client);
 
-static int w83781d_read_value(struct i2c_client *client, u16 register);
-static int w83781d_write_value(struct i2c_client *client, u16 register,
-                              u16 value);
+static int w83781d_read_value(struct i2c_client *client, u16 reg);
+static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value);
 static struct w83781d_data *w83781d_update_device(struct device *dev);
 static void w83781d_init_client(struct i2c_client *client);
 
@@ -285,6 +288,7 @@ static struct i2c_driver w83781d_driver = {
 
 static struct i2c_driver w83781d_isa_driver = {
        .driver = {
+               .owner = THIS_MODULE,
                .name = "w83781d-isa",
        },
        .attach_adapter = w83781d_isa_attach_adapter,
@@ -627,7 +631,7 @@ show_fan_div_reg(struct device *dev, char *buf, int nr)
 
 /* Note: we save and restore the fan minimum here, because its value is
    determined in part by the fan divisor.  This follows the principle of
-   least suprise; the user doesn't expect the fan minimum to change just
+   least surprise; the user doesn't expect the fan minimum to change just
    because the divisor changed. */
 static ssize_t
 store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
@@ -1460,8 +1464,17 @@ w83781d_init_client(struct i2c_client *client)
        int type = data->type;
        u8 tmp;
 
-       if (init && type != as99127f) { /* this resets registers we don't have
+       if (reset && type != as99127f) { /* this resets registers we don't have
                                           documentation for on the as99127f */
+               /* Resetting the chip has been the default for a long time,
+                  but it causes the BIOS initializations (fan clock dividers,
+                  thermal sensor types...) to be lost, so it is now optional.
+                  It might even go away if nobody reports it as being useful,
+                  as I see very little reason why this would be needed at
+                  all. */
+               dev_info(&client->dev, "If reset=1 solved a problem you were "
+                        "having, please report!\n");
+
                /* save these registers */
                i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG);
                p = w83781d_read_value(client, W83781D_REG_PWMCLK12);
@@ -1478,6 +1491,13 @@ w83781d_init_client(struct i2c_client *client)
                w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0);
        }
 
+       /* Disable power-on abnormal beep, as advised by the datasheet.
+          Already done if reset=1. */
+       if (init && !reset && type != as99127f) {
+               i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG);
+               w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80);
+       }
+
        data->vrm = vid_which_vrm();
 
        if ((type != w83781d) && (type != as99127f)) {