aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-s3c2410.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-10-31 12:10:24 -0400
committerBen Dooks <ben-linux@fluff.org>2008-12-16 15:24:16 -0500
commit3d0911bfe03b5f077cef32ca644b5756d48affc3 (patch)
tree53f7ebb75b3132e4c5616087c2553bd16c9733d3 /drivers/i2c/busses/i2c-s3c2410.c
parent1bda71282ded6a2e09a2db7c8884542fb46bfd4f (diff)
i2c-s3c2410: Fixup style problems from checkpatch.pl
Fixup the 36 warnings and errors generated from running checkpatch.pl on the driver. The warnings are too numerous to be listed here. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-s3c2410.c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1fac4e233133..f5efece9b166 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -109,7 +109,8 @@ static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
109 * the default if there is none 109 * the default if there is none
110*/ 110*/
111 111
112static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev) 112static inline struct s3c2410_platform_i2c *
113s3c24xx_i2c_get_platformdata(struct device *dev)
113{ 114{
114 if (dev->platform_data != NULL) 115 if (dev->platform_data != NULL)
115 return (struct s3c2410_platform_i2c *)dev->platform_data; 116 return (struct s3c2410_platform_i2c *)dev->platform_data;
@@ -129,7 +130,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
129 130
130 i2c->msg_ptr = 0; 131 i2c->msg_ptr = 0;
131 i2c->msg = NULL; 132 i2c->msg = NULL;
132 i2c->msg_idx ++; 133 i2c->msg_idx++;
133 i2c->msg_num = 0; 134 i2c->msg_num = 0;
134 if (ret) 135 if (ret)
135 i2c->msg_idx = ret; 136 i2c->msg_idx = ret;
@@ -140,19 +141,17 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
140static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) 141static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
141{ 142{
142 unsigned long tmp; 143 unsigned long tmp;
143 144
144 tmp = readl(i2c->regs + S3C2410_IICCON); 145 tmp = readl(i2c->regs + S3C2410_IICCON);
145 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 146 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
146
147} 147}
148 148
149static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c) 149static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
150{ 150{
151 unsigned long tmp; 151 unsigned long tmp;
152 152
153 tmp = readl(i2c->regs + S3C2410_IICCON); 153 tmp = readl(i2c->regs + S3C2410_IICCON);
154 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 154 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
155
156} 155}
157 156
158/* irq enable/disable functions */ 157/* irq enable/disable functions */
@@ -160,7 +159,7 @@ static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
160static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c) 159static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
161{ 160{
162 unsigned long tmp; 161 unsigned long tmp;
163 162
164 tmp = readl(i2c->regs + S3C2410_IICCON); 163 tmp = readl(i2c->regs + S3C2410_IICCON);
165 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 164 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
166} 165}
@@ -168,7 +167,7 @@ static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
168static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) 167static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
169{ 168{
170 unsigned long tmp; 169 unsigned long tmp;
171 170
172 tmp = readl(i2c->regs + S3C2410_IICCON); 171 tmp = readl(i2c->regs + S3C2410_IICCON);
173 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 172 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
174} 173}
@@ -176,10 +175,10 @@ static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
176 175
177/* s3c24xx_i2c_message_start 176/* s3c24xx_i2c_message_start
178 * 177 *
179 * put the start of a message onto the bus 178 * put the start of a message onto the bus
180*/ 179*/
181 180
182static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, 181static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
183 struct i2c_msg *msg) 182 struct i2c_msg *msg)
184{ 183{
185 unsigned int addr = (msg->addr & 0x7f) << 1; 184 unsigned int addr = (msg->addr & 0x7f) << 1;
@@ -198,15 +197,15 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
198 if (msg->flags & I2C_M_REV_DIR_ADDR) 197 if (msg->flags & I2C_M_REV_DIR_ADDR)
199 addr ^= 1; 198 addr ^= 1;
200 199
201 // todo - check for wether ack wanted or not 200 /* todo - check for wether ack wanted or not */
202 s3c24xx_i2c_enable_ack(i2c); 201 s3c24xx_i2c_enable_ack(i2c);
203 202
204 iiccon = readl(i2c->regs + S3C2410_IICCON); 203 iiccon = readl(i2c->regs + S3C2410_IICCON);
205 writel(stat, i2c->regs + S3C2410_IICSTAT); 204 writel(stat, i2c->regs + S3C2410_IICSTAT);
206 205
207 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); 206 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
208 writeb(addr, i2c->regs + S3C2410_IICDS); 207 writeb(addr, i2c->regs + S3C2410_IICDS);
209 208
210 /* delay here to ensure the data byte has gotten onto the bus 209 /* delay here to ensure the data byte has gotten onto the bus
211 * before the transaction is started */ 210 * before the transaction is started */
212 211
@@ -214,8 +213,8 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
214 213
215 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); 214 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
216 writel(iiccon, i2c->regs + S3C2410_IICCON); 215 writel(iiccon, i2c->regs + S3C2410_IICCON);
217 216
218 stat |= S3C2410_IICSTAT_START; 217 stat |= S3C2410_IICSTAT_START;
219 writel(stat, i2c->regs + S3C2410_IICSTAT); 218 writel(stat, i2c->regs + S3C2410_IICSTAT);
220} 219}
221 220
@@ -226,11 +225,11 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
226 dev_dbg(i2c->dev, "STOP\n"); 225 dev_dbg(i2c->dev, "STOP\n");
227 226
228 /* stop the transfer */ 227 /* stop the transfer */
229 iicstat &= ~ S3C2410_IICSTAT_START; 228 iicstat &= ~S3C2410_IICSTAT_START;
230 writel(iicstat, i2c->regs + S3C2410_IICSTAT); 229 writel(iicstat, i2c->regs + S3C2410_IICSTAT);
231 230
232 i2c->state = STATE_STOP; 231 i2c->state = STATE_STOP;
233 232
234 s3c24xx_i2c_master_complete(i2c, ret); 233 s3c24xx_i2c_master_complete(i2c, ret);
235 s3c24xx_i2c_disable_irq(i2c); 234 s3c24xx_i2c_disable_irq(i2c);
236} 235}
@@ -240,7 +239,7 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
240 239
241/* is_lastmsg() 240/* is_lastmsg()
242 * 241 *
243 * returns TRUE if the current message is the last in the set 242 * returns TRUE if the current message is the last in the set
244*/ 243*/
245 244
246static inline int is_lastmsg(struct s3c24xx_i2c *i2c) 245static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
@@ -288,14 +287,14 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
288 287
289 case STATE_STOP: 288 case STATE_STOP:
290 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); 289 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
291 s3c24xx_i2c_disable_irq(i2c); 290 s3c24xx_i2c_disable_irq(i2c);
292 goto out_ack; 291 goto out_ack;
293 292
294 case STATE_START: 293 case STATE_START:
295 /* last thing we did was send a start condition on the 294 /* last thing we did was send a start condition on the
296 * bus, or started a new i2c message 295 * bus, or started a new i2c message
297 */ 296 */
298 297
299 if (iicstat & S3C2410_IICSTAT_LASTBIT && 298 if (iicstat & S3C2410_IICSTAT_LASTBIT &&
300 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { 299 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
301 /* ack was not received... */ 300 /* ack was not received... */
@@ -321,7 +320,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
321 if (i2c->state == STATE_READ) 320 if (i2c->state == STATE_READ)
322 goto prepare_read; 321 goto prepare_read;
323 322
324 /* fall through to the write state, as we will need to 323 /* fall through to the write state, as we will need to
325 * send a byte as well */ 324 * send a byte as well */
326 325
327 case STATE_WRITE: 326 case STATE_WRITE:
@@ -338,7 +337,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
338 } 337 }
339 } 338 }
340 339
341 retry_write: 340 retry_write:
342 341
343 if (!is_msgend(i2c)) { 342 if (!is_msgend(i2c)) {
344 byte = i2c->msg->buf[i2c->msg_ptr++]; 343 byte = i2c->msg->buf[i2c->msg_ptr++];
@@ -358,9 +357,9 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
358 dev_dbg(i2c->dev, "WRITE: Next Message\n"); 357 dev_dbg(i2c->dev, "WRITE: Next Message\n");
359 358
360 i2c->msg_ptr = 0; 359 i2c->msg_ptr = 0;
361 i2c->msg_idx ++; 360 i2c->msg_idx++;
362 i2c->msg++; 361 i2c->msg++;
363 362
364 /* check to see if we need to do another message */ 363 /* check to see if we need to do another message */
365 if (i2c->msg->flags & I2C_M_NOSTART) { 364 if (i2c->msg->flags & I2C_M_NOSTART) {
366 365
@@ -374,7 +373,6 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
374 373
375 goto retry_write; 374 goto retry_write;
376 } else { 375 } else {
377
378 /* send the new start */ 376 /* send the new start */
379 s3c24xx_i2c_message_start(i2c, i2c->msg); 377 s3c24xx_i2c_message_start(i2c, i2c->msg);
380 i2c->state = STATE_START; 378 i2c->state = STATE_START;
@@ -388,7 +386,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
388 break; 386 break;
389 387
390 case STATE_READ: 388 case STATE_READ:
391 /* we have a byte of data in the data register, do 389 /* we have a byte of data in the data register, do
392 * something with it, and then work out wether we are 390 * something with it, and then work out wether we are
393 * going to do any more read/write 391 * going to do any more read/write
394 */ 392 */
@@ -396,13 +394,13 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
396 byte = readb(i2c->regs + S3C2410_IICDS); 394 byte = readb(i2c->regs + S3C2410_IICDS);
397 i2c->msg->buf[i2c->msg_ptr++] = byte; 395 i2c->msg->buf[i2c->msg_ptr++] = byte;
398 396
399 prepare_read: 397 prepare_read:
400 if (is_msglast(i2c)) { 398 if (is_msglast(i2c)) {
401 /* last byte of buffer */ 399 /* last byte of buffer */
402 400
403 if (is_lastmsg(i2c)) 401 if (is_lastmsg(i2c))
404 s3c24xx_i2c_disable_ack(i2c); 402 s3c24xx_i2c_disable_ack(i2c);
405 403
406 } else if (is_msgend(i2c)) { 404 } else if (is_msgend(i2c)) {
407 /* ok, we've read the entire buffer, see if there 405 /* ok, we've read the entire buffer, see if there
408 * is anything else we need to do */ 406 * is anything else we need to do */
@@ -428,7 +426,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
428 /* acknowlegde the IRQ and get back on with the work */ 426 /* acknowlegde the IRQ and get back on with the work */
429 427
430 out_ack: 428 out_ack:
431 tmp = readl(i2c->regs + S3C2410_IICCON); 429 tmp = readl(i2c->regs + S3C2410_IICCON);
432 tmp &= ~S3C2410_IICCON_IRQPEND; 430 tmp &= ~S3C2410_IICCON_IRQPEND;
433 writel(tmp, i2c->regs + S3C2410_IICCON); 431 writel(tmp, i2c->regs + S3C2410_IICCON);
434 out: 432 out:
@@ -449,19 +447,19 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id)
449 status = readl(i2c->regs + S3C2410_IICSTAT); 447 status = readl(i2c->regs + S3C2410_IICSTAT);
450 448
451 if (status & S3C2410_IICSTAT_ARBITR) { 449 if (status & S3C2410_IICSTAT_ARBITR) {
452 // deal with arbitration loss 450 /* deal with arbitration loss */
453 dev_err(i2c->dev, "deal with arbitration loss\n"); 451 dev_err(i2c->dev, "deal with arbitration loss\n");
454 } 452 }
455 453
456 if (i2c->state == STATE_IDLE) { 454 if (i2c->state == STATE_IDLE) {
457 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n"); 455 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
458 456
459 tmp = readl(i2c->regs + S3C2410_IICCON); 457 tmp = readl(i2c->regs + S3C2410_IICCON);
460 tmp &= ~S3C2410_IICCON_IRQPEND; 458 tmp &= ~S3C2410_IICCON_IRQPEND;
461 writel(tmp, i2c->regs + S3C2410_IICCON); 459 writel(tmp, i2c->regs + S3C2410_IICCON);
462 goto out; 460 goto out;
463 } 461 }
464 462
465 /* pretty much this leaves us with the fact that we've 463 /* pretty much this leaves us with the fact that we've
466 * transmitted or received whatever byte we last sent */ 464 * transmitted or received whatever byte we last sent */
467 465
@@ -484,7 +482,7 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
484 482
485 while (timeout-- > 0) { 483 while (timeout-- > 0) {
486 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 484 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
487 485
488 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY)) 486 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
489 return 0; 487 return 0;
490 488
@@ -502,7 +500,8 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
502 * this starts an i2c transfer 500 * this starts an i2c transfer
503*/ 501*/
504 502
505static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num) 503static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
504 struct i2c_msg *msgs, int num)
506{ 505{
507 unsigned long timeout; 506 unsigned long timeout;
508 int ret; 507 int ret;
@@ -528,12 +527,12 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
528 s3c24xx_i2c_enable_irq(i2c); 527 s3c24xx_i2c_enable_irq(i2c);
529 s3c24xx_i2c_message_start(i2c, msgs); 528 s3c24xx_i2c_message_start(i2c, msgs);
530 spin_unlock_irq(&i2c->lock); 529 spin_unlock_irq(&i2c->lock);
531 530
532 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); 531 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
533 532
534 ret = i2c->msg_idx; 533 ret = i2c->msg_idx;
535 534
536 /* having these next two as dev_err() makes life very 535 /* having these next two as dev_err() makes life very
537 * noisy when doing an i2cdetect */ 536 * noisy when doing an i2cdetect */
538 537
539 if (timeout == 0) 538 if (timeout == 0)
@@ -642,7 +641,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
642{ 641{
643 int diff = freq - wanted; 642 int diff = freq - wanted;
644 643
645 return (diff >= -2 && diff <= 2); 644 return diff >= -2 && diff <= 2;
646} 645}
647 646
648/* s3c24xx_i2c_clockrate 647/* s3c24xx_i2c_clockrate
@@ -665,7 +664,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
665 664
666 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent); 665 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
667 clkin /= 1000; /* clkin now in KHz */ 666 clkin /= 1000; /* clkin now in KHz */
668 667
669 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", 668 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
670 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); 669 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
671 670
@@ -773,7 +772,7 @@ static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
773 772
774/* s3c24xx_i2c_init 773/* s3c24xx_i2c_init
775 * 774 *
776 * initialise the controller, set the IO lines and frequency 775 * initialise the controller, set the IO lines and frequency
777*/ 776*/
778 777
779static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) 778static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
@@ -792,7 +791,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
792 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL); 791 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);
793 792
794 /* write slave address */ 793 /* write slave address */
795 794
796 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD); 795 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);
797 796
798 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); 797 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
@@ -877,7 +876,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
877 goto err_ioarea; 876 goto err_ioarea;
878 } 877 }
879 878
880 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 879 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
880 i2c->regs, i2c->ioarea, res);
881 881
882 /* setup info block for the i2c core */ 882 /* setup info block for the i2c core */
883 883
@@ -891,7 +891,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
891 goto err_iomap; 891 goto err_iomap;
892 892
893 /* find the IRQ for this unit (note, this relies on the init call to 893 /* find the IRQ for this unit (note, this relies on the init call to
894 * ensure no current IRQs pending 894 * ensure no current IRQs pending
895 */ 895 */
896 896
897 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 897 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -910,7 +910,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
910 } 910 }
911 911
912 i2c->irq = res; 912 i2c->irq = res;
913 913
914 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res, 914 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
915 (unsigned long)res->start); 915 (unsigned long)res->start);
916 916