aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorLaurent Navet <laurent.navet@gmail.com>2013-01-10 09:07:42 -0500
committerWolfram Sang <w.sang@pengutronix.de>2013-01-27 23:26:42 -0500
commit5c38dc8911b86b7c49305e2f2b631cd1241f2d87 (patch)
treedc6964e42fb260b105007019d6e6542ce0a96f70 /drivers/i2c
parent81e34f913402284deed1a74ad7dcfa79396cbcc4 (diff)
i2c: nforce2: fix coding style issues
avoid these checkpatch.pl issues : - ERROR: "foo * bar" should be "foo *bar" - ERROR: switch and case should be at the same indent - ERROR: "(foo*)" should be "(foo *)" - ERROR: do not use assignment in if condition - ERROR: space required before the open parenthesis '(' - WARNING: suspect code indent for conditional statements - WARNING: quoted string split across lines - WARNING: space prohibited between function name and open parenthesis '(' - WARNING: line over 80 characters also add spaces around some "+", "=", "*" Signed-off-by: Laurent Navet <laurent.navet@gmail.com> Reviewed-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index adac8542771d..ac88f4000cc2 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -60,7 +60,7 @@
60#include <linux/io.h> 60#include <linux/io.h>
61 61
62MODULE_LICENSE("GPL"); 62MODULE_LICENSE("GPL");
63MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>"); 63MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
64MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver"); 64MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
65 65
66 66
@@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
188} 188}
189 189
190/* Return negative errno on error */ 190/* Return negative errno on error */
191static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, 191static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
192 unsigned short flags, char read_write, 192 unsigned short flags, char read_write,
193 u8 command, int size, union i2c_smbus_data * data) 193 u8 command, int size, union i2c_smbus_data *data)
194{ 194{
195 struct nforce2_smbus *smbus = adap->algo_data; 195 struct nforce2_smbus *smbus = adap->algo_data;
196 unsigned char protocol, pec; 196 unsigned char protocol, pec;
@@ -202,56 +202,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
202 pec = (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0; 202 pec = (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0;
203 203
204 switch (size) { 204 switch (size) {
205 case I2C_SMBUS_QUICK:
206 protocol |= NVIDIA_SMB_PRTCL_QUICK;
207 read_write = I2C_SMBUS_WRITE;
208 break;
205 209
206 case I2C_SMBUS_QUICK: 210 case I2C_SMBUS_BYTE:
207 protocol |= NVIDIA_SMB_PRTCL_QUICK; 211 if (read_write == I2C_SMBUS_WRITE)
208 read_write = I2C_SMBUS_WRITE;
209 break;
210
211 case I2C_SMBUS_BYTE:
212 if (read_write == I2C_SMBUS_WRITE)
213 outb_p(command, NVIDIA_SMB_CMD);
214 protocol |= NVIDIA_SMB_PRTCL_BYTE;
215 break;
216
217 case I2C_SMBUS_BYTE_DATA:
218 outb_p(command, NVIDIA_SMB_CMD);
219 if (read_write == I2C_SMBUS_WRITE)
220 outb_p(data->byte, NVIDIA_SMB_DATA);
221 protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
222 break;
223
224 case I2C_SMBUS_WORD_DATA:
225 outb_p(command, NVIDIA_SMB_CMD); 212 outb_p(command, NVIDIA_SMB_CMD);
226 if (read_write == I2C_SMBUS_WRITE) { 213 protocol |= NVIDIA_SMB_PRTCL_BYTE;
227 outb_p(data->word, NVIDIA_SMB_DATA); 214 break;
228 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1); 215
229 } 216 case I2C_SMBUS_BYTE_DATA:
230 protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec; 217 outb_p(command, NVIDIA_SMB_CMD);
231 break; 218 if (read_write == I2C_SMBUS_WRITE)
232 219 outb_p(data->byte, NVIDIA_SMB_DATA);
233 case I2C_SMBUS_BLOCK_DATA: 220 protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
234 outb_p(command, NVIDIA_SMB_CMD); 221 break;
235 if (read_write == I2C_SMBUS_WRITE) { 222
236 len = data->block[0]; 223 case I2C_SMBUS_WORD_DATA:
237 if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) { 224 outb_p(command, NVIDIA_SMB_CMD);
238 dev_err(&adap->dev, 225 if (read_write == I2C_SMBUS_WRITE) {
239 "Transaction failed " 226 outb_p(data->word, NVIDIA_SMB_DATA);
240 "(requested block size: %d)\n", 227 outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
241 len); 228 }
242 return -EINVAL; 229 protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
243 } 230 break;
244 outb_p(len, NVIDIA_SMB_BCNT); 231
245 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) 232 case I2C_SMBUS_BLOCK_DATA:
246 outb_p(data->block[i + 1], 233 outb_p(command, NVIDIA_SMB_CMD);
247 NVIDIA_SMB_DATA+i); 234 if (read_write == I2C_SMBUS_WRITE) {
235 len = data->block[0];
236 if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
237 dev_err(&adap->dev,
238 "Transaction failed (requested block size: %d)\n",
239 len);
240 return -EINVAL;
248 } 241 }
249 protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec; 242 outb_p(len, NVIDIA_SMB_BCNT);
250 break; 243 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
244 outb_p(data->block[i + 1],
245 NVIDIA_SMB_DATA + i);
246 }
247 protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
248 break;
251 249
252 default: 250 default:
253 dev_err(&adap->dev, "Unsupported transaction %d\n", size); 251 dev_err(&adap->dev, "Unsupported transaction %d\n", size);
254 return -EOPNOTSUPP; 252 return -EOPNOTSUPP;
255 } 253 }
256 254
257 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); 255 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
@@ -265,28 +263,28 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
265 return 0; 263 return 0;
266 264
267 switch (size) { 265 switch (size) {
268 266 case I2C_SMBUS_BYTE:
269 case I2C_SMBUS_BYTE: 267 case I2C_SMBUS_BYTE_DATA:
270 case I2C_SMBUS_BYTE_DATA: 268 data->byte = inb_p(NVIDIA_SMB_DATA);
271 data->byte = inb_p(NVIDIA_SMB_DATA); 269 break;
272 break; 270
273 271 case I2C_SMBUS_WORD_DATA:
274 case I2C_SMBUS_WORD_DATA: 272 data->word = inb_p(NVIDIA_SMB_DATA) |
275 data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8); 273 (inb_p(NVIDIA_SMB_DATA + 1) << 8);
276 break; 274 break;
277 275
278 case I2C_SMBUS_BLOCK_DATA: 276 case I2C_SMBUS_BLOCK_DATA:
279 len = inb_p(NVIDIA_SMB_BCNT); 277 len = inb_p(NVIDIA_SMB_BCNT);
280 if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) { 278 if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
281 dev_err(&adap->dev, "Transaction failed " 279 dev_err(&adap->dev,
282 "(received block size: 0x%02x)\n", 280 "Transaction failed (received block size: 0x%02x)\n",
283 len); 281 len);
284 return -EPROTO; 282 return -EPROTO;
285 } 283 }
286 for (i = 0; i < len; i++) 284 for (i = 0; i < len; i++)
287 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); 285 data->block[i + 1] = inb_p(NVIDIA_SMB_DATA + i);
288 data->block[0] = len; 286 data->block[0] = len;
289 break; 287 break;
290 } 288 }
291 289
292 return 0; 290 return 0;
@@ -299,7 +297,7 @@ static u32 nforce2_func(struct i2c_adapter *adapter)
299 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 297 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
300 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 298 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
301 I2C_FUNC_SMBUS_PEC | 299 I2C_FUNC_SMBUS_PEC |
302 (((struct nforce2_smbus*)adapter->algo_data)->blockops ? 300 (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
303 I2C_FUNC_SMBUS_BLOCK_DATA : 0); 301 I2C_FUNC_SMBUS_BLOCK_DATA : 0);
304} 302}
305 303
@@ -327,7 +325,7 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
327 { 0 } 325 { 0 }
328}; 326};
329 327
330MODULE_DEVICE_TABLE (pci, nforce2_ids); 328MODULE_DEVICE_TABLE(pci, nforce2_ids);
331 329
332 330
333static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg, 331static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
@@ -377,7 +375,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
377 release_region(smbus->base, smbus->size); 375 release_region(smbus->base, smbus->size);
378 return error; 376 return error;
379 } 377 }
380 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base); 378 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n",
379 smbus->base);
381 return 0; 380 return 0;
382} 381}
383 382
@@ -388,11 +387,12 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id)
388 int res1, res2; 387 int res1, res2;
389 388
390 /* we support 2 SMBus adapters */ 389 /* we support 2 SMBus adapters */
391 if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL))) 390 smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
391 if (!smbuses)
392 return -ENOMEM; 392 return -ENOMEM;
393 pci_set_drvdata(dev, smbuses); 393 pci_set_drvdata(dev, smbuses);
394 394
395 switch(dev->device) { 395 switch (dev->device) {
396 case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS: 396 case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
397 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS: 397 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
398 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS: 398 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS: