Commit f24d548bf2c4da3fd2cc4d0ffec108216b705850

Authored by Guenter Roeck
Committed by Guenter Roeck
1 parent 724cc3316e

hwmon: (atxp1) Fix checkpatch issues

Fixed:
ERROR: code indent should use tabs where possible
ERROR: do not use assignment in if condition
ERROR: else should follow close brace '}'
ERROR: "foo * bar" should be "foo *bar"
WARNING: braces {} are not necessary for single statement blocks
WARNING: line over 80 characters
WARNING: please, no space before tabs
WARNING: please, no spaces at the start of a line
WARNING: simple_strtoul is obsolete, use kstrtoul instead

Modify multi-line comments to follow Documentation/CodingStyle.

Cc: Sebastian Witt <se.witt@gmx.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Showing 1 changed file with 93 additions and 65 deletions Side-by-side Diff

drivers/hwmon/atxp1.c
1 1 /*
2   - atxp1.c - kernel module for setting CPU VID and general purpose
3   - I/Os using the Attansic ATXP1 chip.
  2 + * atxp1.c - kernel module for setting CPU VID and general purpose
  3 + * I/Os using the Attansic ATXP1 chip.
  4 + *
  5 + * This program is free software; you can redistribute it and/or modify
  6 + * it under the terms of the GNU General Public License as published by
  7 + * the Free Software Foundation; either version 2 of the License, or
  8 + * (at your option) any later version.
  9 + *
  10 + * This program is distributed in the hope that it will be useful,
  11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 + * GNU General Public License for more details.
  14 + *
  15 + * You should have received a copy of the GNU General Public License
  16 + * along with this program; if not, write to the Free Software
  17 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18 + *
  19 + */
4 20  
5   - This program is free software; you can redistribute it and/or modify
6   - it under the terms of the GNU General Public License as published by
7   - the Free Software Foundation; either version 2 of the License, or
8   - (at your option) any later version.
9   -
10   - This program is distributed in the hope that it will be useful,
11   - but WITHOUT ANY WARRANTY; without even the implied warranty of
12   - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   - GNU General Public License for more details.
14   -
15   - You should have received a copy of the GNU General Public License
16   - along with this program; if not, write to the Free Software
17   - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18   -
19   -*/
20   -
21 21 #include <linux/kernel.h>
22 22 #include <linux/init.h>
23 23 #include <linux/module.h>
... ... @@ -48,7 +48,7 @@
48 48 static int atxp1_probe(struct i2c_client *client,
49 49 const struct i2c_device_id *id);
50 50 static int atxp1_remove(struct i2c_client *client);
51   -static struct atxp1_data * atxp1_update_device(struct device *dev);
  51 +static struct atxp1_data *atxp1_update_device(struct device *dev);
52 52 static int atxp1_detect(struct i2c_client *client, struct i2c_board_info *info);
53 53  
54 54 static const struct i2c_device_id atxp1_id[] = {
... ... @@ -83,7 +83,7 @@
83 83 u8 vrm; /* Detected CPU VRM */
84 84 };
85 85  
86   -static struct atxp1_data * atxp1_update_device(struct device *dev)
  86 +static struct atxp1_data *atxp1_update_device(struct device *dev)
87 87 {
88 88 struct i2c_client *client;
89 89 struct atxp1_data *data;
... ... @@ -97,7 +97,8 @@
97 97  
98 98 /* Update local register data */
99 99 data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID);
100   - data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID);
  100 + data->reg.cpu_vid = i2c_smbus_read_byte_data(client,
  101 + ATXP1_CVID);
101 102 data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1);
102 103 data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2);
103 104  
104 105  
105 106  
106 107  
107 108  
... ... @@ -110,29 +111,37 @@
110 111 }
111 112  
112 113 /* sys file functions for cpu0_vid */
113   -static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf)
  114 +static ssize_t atxp1_showvcore(struct device *dev,
  115 + struct device_attribute *attr, char *buf)
114 116 {
115 117 int size;
116 118 struct atxp1_data *data;
117 119  
118 120 data = atxp1_update_device(dev);
119 121  
120   - size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm));
  122 + size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK,
  123 + data->vrm));
121 124  
122 125 return size;
123 126 }
124 127  
125   -static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
  128 +static ssize_t atxp1_storevcore(struct device *dev,
  129 + struct device_attribute *attr,
  130 + const char *buf, size_t count)
126 131 {
127 132 struct atxp1_data *data;
128 133 struct i2c_client *client;
129 134 int vid, cvid;
130   - unsigned int vcore;
  135 + unsigned long vcore;
  136 + int err;
131 137  
132 138 client = to_i2c_client(dev);
133 139 data = atxp1_update_device(dev);
134 140  
135   - vcore = simple_strtoul(buf, NULL, 10);
  141 + err = kstrtoul(buf, 10, &vcore);
  142 + if (err)
  143 + return err;
  144 +
136 145 vcore /= 25;
137 146 vcore *= 25;
138 147  
... ... @@ -144,7 +153,10 @@
144 153 return -1;
145 154 }
146 155  
147   - /* If output enabled, use control register value. Otherwise original CPU VID */
  156 + /*
  157 + * If output enabled, use control register value.
  158 + * Otherwise original CPU VID
  159 + */
148 160 if (data->reg.vid & ATXP1_VIDENA)
149 161 cvid = data->reg.vid & ATXP1_VIDMASK;
150 162 else
151 163  
152 164  
153 165  
154 166  
... ... @@ -154,32 +166,34 @@
154 166 if (vid == cvid)
155 167 return count;
156 168  
157   - dev_dbg(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid);
  169 + dev_dbg(dev, "Setting VCore to %d mV (0x%02x)\n", (int)vcore, vid);
158 170  
159 171 /* Write every 25 mV step to increase stability */
160 172 if (cvid > vid) {
161   - for (; cvid >= vid; cvid--) {
162   - i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
163   - }
  173 + for (; cvid >= vid; cvid--)
  174 + i2c_smbus_write_byte_data(client,
  175 + ATXP1_VID, cvid | ATXP1_VIDENA);
  176 + } else {
  177 + for (; cvid <= vid; cvid++)
  178 + i2c_smbus_write_byte_data(client,
  179 + ATXP1_VID, cvid | ATXP1_VIDENA);
164 180 }
165   - else {
166   - for (; cvid <= vid; cvid++) {
167   - i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
168   - }
169   - }
170 181  
171 182 data->valid = 0;
172 183  
173 184 return count;
174 185 }
175 186  
176   -/* CPU core reference voltage
177   - unit: millivolt
178   -*/
179   -static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);
  187 +/*
  188 + * CPU core reference voltage
  189 + * unit: millivolt
  190 + */
  191 +static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore,
  192 + atxp1_storevcore);
180 193  
181 194 /* sys file functions for GPIO1 */
182   -static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf)
  195 +static ssize_t atxp1_showgpio1(struct device *dev,
  196 + struct device_attribute *attr, char *buf)
183 197 {
184 198 int size;
185 199 struct atxp1_data *data;
186 200  
187 201  
188 202  
... ... @@ -191,21 +205,26 @@
191 205 return size;
192 206 }
193 207  
194   -static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count)
  208 +static ssize_t atxp1_storegpio1(struct device *dev,
  209 + struct device_attribute *attr, const char *buf,
  210 + size_t count)
195 211 {
196 212 struct atxp1_data *data;
197 213 struct i2c_client *client;
198   - unsigned int value;
  214 + unsigned long value;
  215 + int err;
199 216  
200 217 client = to_i2c_client(dev);
201 218 data = atxp1_update_device(dev);
202 219  
203   - value = simple_strtoul(buf, NULL, 16);
  220 + err = kstrtoul(buf, 16, &value);
  221 + if (err)
  222 + return err;
204 223  
205 224 value &= ATXP1_GPIO1MASK;
206 225  
207 226 if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) {
208   - dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
  227 + dev_info(dev, "Writing 0x%x to GPIO1.\n", (unsigned int)value);
209 228  
210 229 i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value);
211 230  
212 231  
... ... @@ -215,13 +234,15 @@
215 234 return count;
216 235 }
217 236  
218   -/* GPIO1 data register
219   - unit: Four bit as hex (e.g. 0x0f)
220   -*/
  237 +/*
  238 + * GPIO1 data register
  239 + * unit: Four bit as hex (e.g. 0x0f)
  240 + */
221 241 static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);
222 242  
223 243 /* sys file functions for GPIO2 */
224   -static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf)
  244 +static ssize_t atxp1_showgpio2(struct device *dev,
  245 + struct device_attribute *attr, char *buf)
225 246 {
226 247 int size;
227 248 struct atxp1_data *data;
228 249  
229 250  
230 251  
231 252  
... ... @@ -233,19 +254,22 @@
233 254 return size;
234 255 }
235 256  
236   -static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
  257 +static ssize_t atxp1_storegpio2(struct device *dev,
  258 + struct device_attribute *attr,
  259 + const char *buf, size_t count)
237 260 {
238   - struct atxp1_data *data;
239   - struct i2c_client *client;
240   - unsigned int value;
  261 + struct atxp1_data *data = atxp1_update_device(dev);
  262 + struct i2c_client *client = to_i2c_client(dev);
  263 + unsigned long value;
  264 + int err;
241 265  
242   - client = to_i2c_client(dev);
243   - data = atxp1_update_device(dev);
  266 + err = kstrtoul(buf, 16, &value);
  267 + if (err)
  268 + return err;
  269 + value &= 0xff;
244 270  
245   - value = simple_strtoul(buf, NULL, 16) & 0xff;
246   -
247 271 if (value != data->reg.gpio2) {
248   - dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
  272 + dev_info(dev, "Writing 0x%x to GPIO1.\n", (unsigned int)value);
249 273  
250 274 i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value);
251 275  
... ... @@ -255,9 +279,10 @@
255 279 return count;
256 280 }
257 281  
258   -/* GPIO2 data register
259   - unit: Eight bit as hex (e.g. 0xff)
260   -*/
  282 +/*
  283 + * GPIO2 data register
  284 + * unit: Eight bit as hex (e.g. 0xff)
  285 + */
261 286 static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
262 287  
263 288 static struct attribute *atxp1_attributes[] = {
... ... @@ -290,8 +315,10 @@
290 315 (i2c_smbus_read_byte_data(new_client, 0xff) == 0)))
291 316 return -ENODEV;
292 317  
293   - /* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
294   - * showing the same as register 0x00 */
  318 + /*
  319 + * No vendor ID, now checking if registers 0x10,0x11 (non-existent)
  320 + * showing the same as register 0x00
  321 + */
295 322 temp = i2c_smbus_read_byte_data(new_client, 0x00);
296 323  
297 324 if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&
... ... @@ -333,7 +360,8 @@
333 360 mutex_init(&data->update_lock);
334 361  
335 362 /* Register sysfs hooks */
336   - if ((err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group)))
  363 + err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group);
  364 + if (err)
337 365 goto exit_free;
338 366  
339 367 data->hwmon_dev = hwmon_device_register(&new_client->dev);
... ... @@ -357,7 +385,7 @@
357 385  
358 386 static int atxp1_remove(struct i2c_client *client)
359 387 {
360   - struct atxp1_data * data = i2c_get_clientdata(client);
  388 + struct atxp1_data *data = i2c_get_clientdata(client);
361 389  
362 390 hwmon_device_unregister(data->hwmon_dev);
363 391 sysfs_remove_group(&client->dev.kobj, &atxp1_group);