提交 be8992c2 编写于 作者: J Jean Delvare 提交者: Greg Kroah-Hartman

[PATCH] I2C: Coding style cleanups to via686a

The via686a hardware monitoring driver has infamous coding style at the
moment. I'd like to clean up the mess before I start working on other
changes to this driver. Is the following patch acceptable? No code
change, only coding style (indentation, alignments, trailing white
space, a few parentheses and a typo).
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 68188ba7
...@@ -87,8 +87,10 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; ...@@ -87,8 +87,10 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
#define VIA686A_REG_TEMP(nr) (regtemp[nr]) #define VIA686A_REG_TEMP(nr) (regtemp[nr])
#define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) #define VIA686A_REG_TEMP_OVER(nr) (regover[nr])
#define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) #define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr])
#define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 /* bits 7-6 */
#define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 #define VIA686A_REG_TEMP_LOW1 0x4b
/* 2 = bits 5-4, 3 = bits 7-6 */
#define VIA686A_REG_TEMP_LOW23 0x49
#define VIA686A_REG_ALARM1 0x41 #define VIA686A_REG_ALARM1 0x41
#define VIA686A_REG_ALARM2 0x42 #define VIA686A_REG_ALARM2 0x42
...@@ -103,7 +105,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; ...@@ -103,7 +105,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
#define VIA686A_REG_TEMP_MODE 0x4b #define VIA686A_REG_TEMP_MODE 0x4b
/* We'll just assume that you want to set all 3 simultaneously: */ /* We'll just assume that you want to set all 3 simultaneously: */
#define VIA686A_TEMP_MODE_MASK 0x3F #define VIA686A_TEMP_MODE_MASK 0x3F
#define VIA686A_TEMP_MODE_CONTINUOUS (0x00) #define VIA686A_TEMP_MODE_CONTINUOUS 0x00
/* Conversions. Limit checking is only done on the TO_REG /* Conversions. Limit checking is only done on the TO_REG
variants. variants.
...@@ -192,7 +194,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) ...@@ -192,7 +194,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
Alas, none of the elegant function-fit solutions will work because we Alas, none of the elegant function-fit solutions will work because we
aren't allowed to use floating point in the kernel and doing it with aren't allowed to use floating point in the kernel and doing it with
integers doesn't rpovide enough precision. So we'll do boring old integers doesn't provide enough precision. So we'll do boring old
look-up table stuff. The unofficial data (see below) have effectively look-up table stuff. The unofficial data (see below) have effectively
7-bit resolution (they are rounded to the nearest degree). I'm assuming 7-bit resolution (they are rounded to the nearest degree). I'm assuming
that the transfer function of the device is monotonic and smooth, so a that the transfer function of the device is monotonic and smooth, so a
...@@ -204,7 +206,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) ...@@ -204,7 +206,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
we'll just use linear interpolation for 10-bit readings.) So, tempLUT we'll just use linear interpolation for 10-bit readings.) So, tempLUT
is the temp at via register values 0-255: */ is the temp at via register values 0-255: */
static const long tempLUT[] = static const long tempLUT[] =
{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
-503, -487, -471, -456, -442, -428, -414, -400, -387, -375, -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
-362, -350, -339, -327, -316, -305, -295, -285, -275, -265, -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
-255, -246, -237, -229, -220, -212, -204, -196, -188, -180, -255, -246, -237, -229, -220, -212, -204, -196, -188, -180,
...@@ -250,7 +252,7 @@ static const long tempLUT[] = ...@@ -250,7 +252,7 @@ static const long tempLUT[] =
- 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01)
Note that n=161: */ Note that n=161: */
static const u8 viaLUT[] = static const u8 viaLUT[] =
{ 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40,
41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66,
69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100,
...@@ -361,7 +363,7 @@ static ssize_t set_in_min(struct device *dev, const char *buf, ...@@ -361,7 +363,7 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10); unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock); down(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val,nr); data->in_min[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MIN(nr), via686a_write_value(client, VIA686A_REG_IN_MIN(nr),
data->in_min[nr]); data->in_min[nr]);
up(&data->update_lock); up(&data->update_lock);
...@@ -374,7 +376,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf, ...@@ -374,7 +376,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10); unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock); down(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val,nr); data->in_max[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MAX(nr), via686a_write_value(client, VIA686A_REG_IN_MAX(nr),
data->in_max[nr]); data->in_max[nr]);
up(&data->update_lock); up(&data->update_lock);
...@@ -493,17 +495,17 @@ show_temp_offset(3); ...@@ -493,17 +495,17 @@ show_temp_offset(3);
/* 2 Fans */ /* 2 Fans */
static ssize_t show_fan(struct device *dev, char *buf, int nr) { static ssize_t show_fan(struct device *dev, char *buf, int nr) {
struct via686a_data *data = via686a_update_device(dev); struct via686a_data *data = via686a_update_device(dev);
return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
DIV_FROM_REG(data->fan_div[nr])) ); DIV_FROM_REG(data->fan_div[nr])) );
} }
static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { static ssize_t show_fan_min(struct device *dev, char *buf, int nr) {
struct via686a_data *data = via686a_update_device(dev); struct via686a_data *data = via686a_update_device(dev);
return sprintf(buf,"%d\n", return sprintf(buf, "%d\n",
FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) );
} }
static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { static ssize_t show_fan_div(struct device *dev, char *buf, int nr) {
struct via686a_data *data = via686a_update_device(dev); struct via686a_data *data = via686a_update_device(dev);
return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) );
} }
static ssize_t set_fan_min(struct device *dev, const char *buf, static ssize_t set_fan_min(struct device *dev, const char *buf,
size_t count, int nr) { size_t count, int nr) {
...@@ -608,11 +610,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -608,11 +610,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
} }
/* 8231 requires multiple of 256, we enforce that on 686 as well */ /* 8231 requires multiple of 256, we enforce that on 686 as well */
if(force_addr) if (force_addr)
address = force_addr & 0xFF00; address = force_addr & 0xFF00;
if(force_addr) { if (force_addr) {
dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
address);
if (PCIBIOS_SUCCESSFUL != if (PCIBIOS_SUCCESSFUL !=
pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) pci_write_config_word(s_bridge, VIA686A_BASE_REG, address))
return -ENODEV; return -ENODEV;
...@@ -621,7 +624,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -621,7 +624,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))
return -ENODEV; return -ENODEV;
if (!(val & 0x0001)) { if (!(val & 0x0001)) {
dev_warn(&adapter->dev,"enabling sensors\n"); dev_warn(&adapter->dev, "enabling sensors\n");
if (PCIBIOS_SUCCESSFUL != if (PCIBIOS_SUCCESSFUL !=
pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
val | 0x0001)) val | 0x0001))
...@@ -630,7 +633,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -630,7 +633,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
/* Reserve the ISA region */ /* Reserve the ISA region */
if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) {
dev_err(&adapter->dev,"region 0x%x already in use!\n", dev_err(&adapter->dev, "region 0x%x already in use!\n",
address); address);
return -ENODEV; return -ENODEV;
} }
...@@ -695,9 +698,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -695,9 +698,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
return 0; return 0;
ERROR3: ERROR3:
kfree(data); kfree(data);
ERROR0: ERROR0:
release_region(address, VIA686A_EXTENT); release_region(address, VIA686A_EXTENT);
return err; return err;
} }
...@@ -818,14 +821,15 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, ...@@ -818,14 +821,15 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
addr = val & ~(VIA686A_EXTENT - 1); addr = val & ~(VIA686A_EXTENT - 1);
if (addr == 0 && force_addr == 0) { if (addr == 0 && force_addr == 0) {
dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); dev_err(&dev->dev, "base address not set - upgrade BIOS "
"or use force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
if (force_addr) if (force_addr)
addr = force_addr; /* so detect will get called */ addr = force_addr; /* so detect will get called */
if (!addr) { if (!addr) {
dev_err(&dev->dev,"No Via 686A sensors found.\n"); dev_err(&dev->dev, "No Via 686A sensors found.\n");
return -ENODEV; return -ENODEV;
} }
normal_isa[0] = addr; normal_isa[0] = addr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册