aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-11-21 07:46:31 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-02-12 12:32:42 -0500
commit4be53dbe74818a12cc737a89b5d0aec6095956e0 (patch)
tree35b7f80ce81c7f8c42f324c982d880a2c717457e /drivers
parent81d6724a564fa5bd20b006eae0da4462d599bb92 (diff)
ARM: PNX4008: i2c-pnx: don't split messages across several lines
It makes them harder to grep for. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-pnx.c81
1 files changed, 44 insertions, 37 deletions
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 181e69211e4f..afc9c968deec 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -86,25 +86,26 @@ static int i2c_pnx_start(unsigned char slave_addr,
86 86
87 /* Check for 7 bit slave addresses only */ 87 /* Check for 7 bit slave addresses only */
88 if (slave_addr & ~0x7f) { 88 if (slave_addr & ~0x7f) {
89 dev_err(&alg_data->adapter.dev, "%s: Invalid slave address %x. " 89 dev_err(&alg_data->adapter.dev,
90 "Only 7-bit addresses are supported\n", 90 "%s: Invalid slave address %x. Only 7-bit addresses are supported\n",
91 alg_data->adapter.name, slave_addr); 91 alg_data->adapter.name, slave_addr);
92 return -EINVAL; 92 return -EINVAL;
93 } 93 }
94 94
95 /* First, make sure bus is idle */ 95 /* First, make sure bus is idle */
96 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) { 96 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) {
97 /* Somebody else is monopolizing the bus */ 97 /* Somebody else is monopolizing the bus */
98 dev_err(&alg_data->adapter.dev, "%s: Bus busy. Slave addr = %02x, " 98 dev_err(&alg_data->adapter.dev,
99 "cntrl = %x, stat = %x\n", 99 "%s: Bus busy. Slave addr = %02x, cntrl = %x, stat = %x\n",
100 alg_data->adapter.name, slave_addr, 100 alg_data->adapter.name, slave_addr,
101 ioread32(I2C_REG_CTL(alg_data)), 101 ioread32(I2C_REG_CTL(alg_data)),
102 ioread32(I2C_REG_STS(alg_data))); 102 ioread32(I2C_REG_STS(alg_data)));
103 return -EBUSY; 103 return -EBUSY;
104 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) { 104 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) {
105 /* Sorry, we lost the bus */ 105 /* Sorry, we lost the bus */
106 dev_err(&alg_data->adapter.dev, "%s: Arbitration failure. " 106 dev_err(&alg_data->adapter.dev,
107 "Slave addr = %02x\n", alg_data->adapter.name, slave_addr); 107 "%s: Arbitration failure. Slave addr = %02x\n",
108 alg_data->adapter.name, slave_addr);
108 return -EIO; 109 return -EIO;
109 } 110 }
110 111
@@ -182,15 +183,15 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
182 alg_data->mif.len--; 183 alg_data->mif.len--;
183 iowrite32(val, I2C_REG_TX(alg_data)); 184 iowrite32(val, I2C_REG_TX(alg_data));
184 185
185 dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n", __func__, 186 dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n",
186 val, alg_data->mif.len + 1); 187 __func__, val, alg_data->mif.len + 1);
187 188
188 if (alg_data->mif.len == 0) { 189 if (alg_data->mif.len == 0) {
189 if (alg_data->last) { 190 if (alg_data->last) {
190 /* Wait until the STOP is seen. */ 191 /* Wait until the STOP is seen. */
191 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) 192 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
192 dev_err(&alg_data->adapter.dev, "The bus is still " 193 dev_err(&alg_data->adapter.dev,
193 "active after timeout\n"); 194 "The bus is still active after timeout\n");
194 } 195 }
195 /* Disable master interrupts */ 196 /* Disable master interrupts */
196 iowrite32(ioread32(I2C_REG_CTL(alg_data)) & 197 iowrite32(ioread32(I2C_REG_CTL(alg_data)) &
@@ -199,7 +200,8 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
199 200
200 del_timer_sync(&alg_data->mif.timer); 201 del_timer_sync(&alg_data->mif.timer);
201 202
202 dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine.\n", 203 dev_dbg(&alg_data->adapter.dev,
204 "%s(): Waking up xfer routine.\n",
203 __func__); 205 __func__);
204 206
205 complete(&alg_data->mif.complete); 207 complete(&alg_data->mif.complete);
@@ -215,8 +217,9 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
215 217
216 /* Stop timer. */ 218 /* Stop timer. */
217 del_timer_sync(&alg_data->mif.timer); 219 del_timer_sync(&alg_data->mif.timer);
218 dev_dbg(&alg_data->adapter.dev, "%s(): Waking up xfer routine after " 220 dev_dbg(&alg_data->adapter.dev,
219 "zero-xfer.\n", __func__); 221 "%s(): Waking up xfer routine after zero-xfer.\n",
222 __func__);
220 223
221 complete(&alg_data->mif.complete); 224 complete(&alg_data->mif.complete);
222 } 225 }
@@ -245,8 +248,9 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
245 * or we didn't 'ask' for it yet. 248 * or we didn't 'ask' for it yet.
246 */ 249 */
247 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) { 250 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) {
248 dev_dbg(&alg_data->adapter.dev, "%s(): Write dummy data to fill " 251 dev_dbg(&alg_data->adapter.dev,
249 "Rx-fifo...\n", __func__); 252 "%s(): Write dummy data to fill Rx-fifo...\n",
253 __func__);
250 254
251 if (alg_data->mif.len == 1) { 255 if (alg_data->mif.len == 1) {
252 /* Last byte, do not acknowledge next rcv. */ 256 /* Last byte, do not acknowledge next rcv. */
@@ -278,16 +282,16 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
278 if (alg_data->mif.len > 0) { 282 if (alg_data->mif.len > 0) {
279 val = ioread32(I2C_REG_RX(alg_data)); 283 val = ioread32(I2C_REG_RX(alg_data));
280 *alg_data->mif.buf++ = (u8) (val & 0xff); 284 *alg_data->mif.buf++ = (u8) (val & 0xff);
281 dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n", __func__, val, 285 dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n",
282 alg_data->mif.len); 286 __func__, val, alg_data->mif.len);
283 287
284 alg_data->mif.len--; 288 alg_data->mif.len--;
285 if (alg_data->mif.len == 0) { 289 if (alg_data->mif.len == 0) {
286 if (alg_data->last) 290 if (alg_data->last)
287 /* Wait until the STOP is seen. */ 291 /* Wait until the STOP is seen. */
288 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) 292 if (wait_timeout(I2C_PNX_TIMEOUT, alg_data))
289 dev_err(&alg_data->adapter.dev, "The bus is still " 293 dev_err(&alg_data->adapter.dev,
290 "active after timeout\n"); 294 "The bus is still active after timeout\n");
291 295
292 /* Disable master interrupts */ 296 /* Disable master interrupts */
293 ctl = ioread32(I2C_REG_CTL(alg_data)); 297 ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -312,7 +316,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
312 struct i2c_pnx_algo_data *alg_data = dev_id; 316 struct i2c_pnx_algo_data *alg_data = dev_id;
313 u32 stat, ctl; 317 u32 stat, ctl;
314 318
315 dev_dbg(&alg_data->adapter.dev, "%s(): mstat = %x mctrl = %x, mode = %d\n", 319 dev_dbg(&alg_data->adapter.dev,
320 "%s(): mstat = %x mctrl = %x, mode = %d\n",
316 __func__, 321 __func__,
317 ioread32(I2C_REG_STS(alg_data)), 322 ioread32(I2C_REG_STS(alg_data)),
318 ioread32(I2C_REG_CTL(alg_data)), 323 ioread32(I2C_REG_CTL(alg_data)),
@@ -335,8 +340,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
335 complete(&alg_data->mif.complete); 340 complete(&alg_data->mif.complete);
336 } else if (stat & mstatus_nai) { 341 } else if (stat & mstatus_nai) {
337 /* Slave did not acknowledge, generate a STOP */ 342 /* Slave did not acknowledge, generate a STOP */
338 dev_dbg(&alg_data->adapter.dev, "%s(): " 343 dev_dbg(&alg_data->adapter.dev,
339 "Slave did not acknowledge, generating a STOP.\n", 344 "%s(): Slave did not acknowledge, generating a STOP.\n",
340 __func__); 345 __func__);
341 i2c_pnx_stop(alg_data); 346 i2c_pnx_stop(alg_data);
342 347
@@ -375,7 +380,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
375 stat = ioread32(I2C_REG_STS(alg_data)); 380 stat = ioread32(I2C_REG_STS(alg_data));
376 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data)); 381 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data));
377 382
378 dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x ctrl = %x.\n", 383 dev_dbg(&alg_data->adapter.dev,
384 "%s(): exiting, stat = %x ctrl = %x.\n",
379 __func__, ioread32(I2C_REG_STS(alg_data)), 385 __func__, ioread32(I2C_REG_STS(alg_data)),
380 ioread32(I2C_REG_CTL(alg_data))); 386 ioread32(I2C_REG_CTL(alg_data)));
381 387
@@ -387,10 +393,10 @@ static void i2c_pnx_timeout(unsigned long data)
387 struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data; 393 struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data;
388 u32 ctl; 394 u32 ctl;
389 395
390 dev_err(&alg_data->adapter.dev, "Master timed out. stat = %04x, cntrl = %04x. " 396 dev_err(&alg_data->adapter.dev,
391 "Resetting master...\n", 397 "Master timed out. stat = %04x, cntrl = %04x. Resetting master...\n",
392 ioread32(I2C_REG_STS(alg_data)), 398 ioread32(I2C_REG_STS(alg_data)),
393 ioread32(I2C_REG_CTL(alg_data))); 399 ioread32(I2C_REG_CTL(alg_data)));
394 400
395 /* Reset master and disable interrupts */ 401 /* Reset master and disable interrupts */
396 ctl = ioread32(I2C_REG_CTL(alg_data)); 402 ctl = ioread32(I2C_REG_CTL(alg_data));
@@ -411,7 +417,7 @@ static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data)
411 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) { 417 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) {
412 dev_err(&alg_data->adapter.dev, 418 dev_err(&alg_data->adapter.dev,
413 "%s: Bus is still active after xfer. Reset it...\n", 419 "%s: Bus is still active after xfer. Reset it...\n",
414 alg_data->adapter.name); 420 alg_data->adapter.name);
415 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, 421 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset,
416 I2C_REG_CTL(alg_data)); 422 I2C_REG_CTL(alg_data));
417 wait_reset(I2C_PNX_TIMEOUT, alg_data); 423 wait_reset(I2C_PNX_TIMEOUT, alg_data);
@@ -445,7 +451,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
445 struct i2c_pnx_algo_data *alg_data = adap->algo_data; 451 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
446 u32 stat = ioread32(I2C_REG_STS(alg_data)); 452 u32 stat = ioread32(I2C_REG_STS(alg_data));
447 453
448 dev_dbg(&alg_data->adapter.dev, "%s(): entering: %d messages, stat = %04x.\n", 454 dev_dbg(&alg_data->adapter.dev,
455 "%s(): entering: %d messages, stat = %04x.\n",
449 __func__, num, ioread32(I2C_REG_STS(alg_data))); 456 __func__, num, ioread32(I2C_REG_STS(alg_data)));
450 457
451 bus_reset_if_active(alg_data); 458 bus_reset_if_active(alg_data);
@@ -472,9 +479,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
472 alg_data->mif.ret = 0; 479 alg_data->mif.ret = 0;
473 alg_data->last = (i == num - 1); 480 alg_data->last = (i == num - 1);
474 481
475 dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n", __func__, 482 dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n",
476 alg_data->mif.mode, 483 __func__, alg_data->mif.mode, alg_data->mif.len);
477 alg_data->mif.len);
478 484
479 i2c_pnx_arm_timer(alg_data); 485 i2c_pnx_arm_timer(alg_data);
480 486
@@ -496,7 +502,8 @@ i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
496 502
497 if (!(rc = alg_data->mif.ret)) 503 if (!(rc = alg_data->mif.ret))
498 completed++; 504 completed++;
499 dev_dbg(&alg_data->adapter.dev, "%s(): Complete, return code = %d.\n", 505 dev_dbg(&alg_data->adapter.dev,
506 "%s(): Complete, return code = %d.\n",
500 __func__, rc); 507 __func__, rc);
501 508
502 /* Clear TDI and AFI bits in case they are set. */ 509 /* Clear TDI and AFI bits in case they are set. */