Commit 47064d645bc55863c7887a7c96cde39c9a37ee5f

Authored by Ben Hutchings
Committed by Jean Delvare
1 parent d2cac802fe

hwmon: (lm87) Add support for configuration through platform_data

The lm87 driver normally assumes that firmware configured the chip
correctly.  Since this is not always the case, alllow platform code to
set the channel register value via platform_data.  All other
configuration registers can be changed after driver initialisation.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>

Showing 2 changed files with 15 additions and 11 deletions Side-by-side Diff

Documentation/hwmon/lm87
... ... @@ -65,11 +65,10 @@
65 65 depending on the hardware configuration.
66 66  
67 67 Some functions share pins, so not all functions are available at the same
68   -time. Which are depends on the hardware setup. This driver assumes that
69   -the BIOS configured the chip correctly. In that respect, it differs from
70   -the original driver (from lm_sensors for Linux 2.4), which would force the
71   -LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
72   -chipset wiring.
  68 +time. Which are depends on the hardware setup. This driver normally
  69 +assumes that firmware configured the chip correctly. Where this is not
  70 +the case, platform code must set the I2C client's platform_data to point
  71 +to a u8 value to be written to the channel register.
73 72  
74 73 For reference, here is the list of exclusive functions:
75 74 - in0+in5 (default) or temp3
drivers/hwmon/lm87.c
... ... @@ -21,11 +21,10 @@
21 21 * http://www.national.com/pf/LM/LM87.html
22 22 *
23 23 * Some functions share pins, so not all functions are available at the same
24   - * time. Which are depends on the hardware setup. This driver assumes that
25   - * the BIOS configured the chip correctly. In that respect, it differs from
26   - * the original driver (from lm_sensors for Linux 2.4), which would force the
27   - * LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
28   - * chipset wiring.
  24 + * time. Which are depends on the hardware setup. This driver normally
  25 + * assumes that firmware configured the chip correctly. Where this is not
  26 + * the case, platform code must set the I2C client's platform_data to point
  27 + * to a u8 value to be written to the channel register.
29 28 * For reference, here is the list of exclusive functions:
30 29 * - in0+in5 (default) or temp3
31 30 * - fan1 (default) or in6
... ... @@ -843,7 +842,13 @@
843 842 {
844 843 struct lm87_data *data = i2c_get_clientdata(client);
845 844  
846   - data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
  845 + if (client->dev.platform_data) {
  846 + data->channel = *(u8 *)client->dev.platform_data;
  847 + lm87_write_value(client,
  848 + LM87_REG_CHANNEL_MODE, data->channel);
  849 + } else {
  850 + data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
  851 + }
847 852 data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F;
848 853  
849 854 if (!(data->config & 0x01)) {