diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2016-04-21 03:04:51 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-04-25 18:27:18 -0400 |
commit | 0915833bd5f9987fdcdb491da1e75026bae05683 (patch) | |
tree | a9cf643870d2b5307895ba0d27b88f8604141cdc | |
parent | ec7c34a4c6c71487a5de4c1b2d47beb2c334aa0d (diff) |
i2c: s3c2410: Cleanup indentation and comment style
Improve the readability by:
- fixing indentation,
- switching to proper block comments,
- removing spurious blank lines,
- checkpatch: void function return statements are not generally useful,
- checkpatch: braces {} are not necessary for any arm of this
statement,
- checkpatch: missing a blank line after declarations.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 7245c81366be..dde1abce07ee 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -170,6 +170,7 @@ static inline kernel_ulong_t s3c24xx_get_device_quirks(struct platform_device *p | |||
170 | { | 170 | { |
171 | if (pdev->dev.of_node) { | 171 | if (pdev->dev.of_node) { |
172 | const struct of_device_id *match; | 172 | const struct of_device_id *match; |
173 | |||
173 | match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); | 174 | match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); |
174 | return (kernel_ulong_t)match->data; | 175 | return (kernel_ulong_t)match->data; |
175 | } | 176 | } |
@@ -277,9 +278,10 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, | |||
277 | dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); | 278 | dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); |
278 | writeb(addr, i2c->regs + S3C2410_IICDS); | 279 | writeb(addr, i2c->regs + S3C2410_IICDS); |
279 | 280 | ||
280 | /* delay here to ensure the data byte has gotten onto the bus | 281 | /* |
281 | * before the transaction is started */ | 282 | * delay here to ensure the data byte has gotten onto the bus |
282 | 283 | * before the transaction is started | |
284 | */ | ||
283 | ndelay(i2c->tx_setup); | 285 | ndelay(i2c->tx_setup); |
284 | 286 | ||
285 | dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); | 287 | dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); |
@@ -354,8 +356,10 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) | |||
354 | s3c24xx_i2c_disable_irq(i2c); | 356 | s3c24xx_i2c_disable_irq(i2c); |
355 | } | 357 | } |
356 | 358 | ||
357 | /* helper functions to determine the current state in the set of | 359 | /* |
358 | * messages we are sending */ | 360 | * helper functions to determine the current state in the set of |
361 | * messages we are sending | ||
362 | */ | ||
359 | 363 | ||
360 | /* | 364 | /* |
361 | * returns TRUE if the current message is the last in the set | 365 | * returns TRUE if the current message is the last in the set |
@@ -370,9 +374,11 @@ static inline int is_lastmsg(struct s3c24xx_i2c *i2c) | |||
370 | */ | 374 | */ |
371 | static inline int is_msglast(struct s3c24xx_i2c *i2c) | 375 | static inline int is_msglast(struct s3c24xx_i2c *i2c) |
372 | { | 376 | { |
373 | /* msg->len is always 1 for the first byte of smbus block read. | 377 | /* |
378 | * msg->len is always 1 for the first byte of smbus block read. | ||
374 | * Actual length will be read from slave. More bytes will be | 379 | * Actual length will be read from slave. More bytes will be |
375 | * read according to the length then. */ | 380 | * read according to the length then. |
381 | */ | ||
376 | if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) | 382 | if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) |
377 | return 0; | 383 | return 0; |
378 | 384 | ||
@@ -408,14 +414,13 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
408 | goto out_ack; | 414 | goto out_ack; |
409 | 415 | ||
410 | case STATE_START: | 416 | case STATE_START: |
411 | /* last thing we did was send a start condition on the | 417 | /* |
418 | * last thing we did was send a start condition on the | ||
412 | * bus, or started a new i2c message | 419 | * bus, or started a new i2c message |
413 | */ | 420 | */ |
414 | |||
415 | if (iicstat & S3C2410_IICSTAT_LASTBIT && | 421 | if (iicstat & S3C2410_IICSTAT_LASTBIT && |
416 | !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { | 422 | !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { |
417 | /* ack was not received... */ | 423 | /* ack was not received... */ |
418 | |||
419 | dev_dbg(i2c->dev, "ack was not received\n"); | 424 | dev_dbg(i2c->dev, "ack was not received\n"); |
420 | s3c24xx_i2c_stop(i2c, -ENXIO); | 425 | s3c24xx_i2c_stop(i2c, -ENXIO); |
421 | goto out_ack; | 426 | goto out_ack; |
@@ -426,9 +431,10 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
426 | else | 431 | else |
427 | i2c->state = STATE_WRITE; | 432 | i2c->state = STATE_WRITE; |
428 | 433 | ||
429 | /* terminate the transfer if there is nothing to do | 434 | /* |
430 | * as this is used by the i2c probe to find devices. */ | 435 | * Terminate the transfer if there is nothing to do |
431 | 436 | * as this is used by the i2c probe to find devices. | |
437 | */ | ||
432 | if (is_lastmsg(i2c) && i2c->msg->len == 0) { | 438 | if (is_lastmsg(i2c) && i2c->msg->len == 0) { |
433 | s3c24xx_i2c_stop(i2c, 0); | 439 | s3c24xx_i2c_stop(i2c, 0); |
434 | goto out_ack; | 440 | goto out_ack; |
@@ -437,14 +443,16 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
437 | if (i2c->state == STATE_READ) | 443 | if (i2c->state == STATE_READ) |
438 | goto prepare_read; | 444 | goto prepare_read; |
439 | 445 | ||
440 | /* fall through to the write state, as we will need to | 446 | /* |
441 | * send a byte as well */ | 447 | * fall through to the write state, as we will need to |
448 | * send a byte as well | ||
449 | */ | ||
442 | 450 | ||
443 | case STATE_WRITE: | 451 | case STATE_WRITE: |
444 | /* we are writing data to the device... check for the | 452 | /* |
453 | * we are writing data to the device... check for the | ||
445 | * end of the message, and if so, work out what to do | 454 | * end of the message, and if so, work out what to do |
446 | */ | 455 | */ |
447 | |||
448 | if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) { | 456 | if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) { |
449 | if (iicstat & S3C2410_IICSTAT_LASTBIT) { | 457 | if (iicstat & S3C2410_IICSTAT_LASTBIT) { |
450 | dev_dbg(i2c->dev, "WRITE: No Ack\n"); | 458 | dev_dbg(i2c->dev, "WRITE: No Ack\n"); |
@@ -460,12 +468,13 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
460 | byte = i2c->msg->buf[i2c->msg_ptr++]; | 468 | byte = i2c->msg->buf[i2c->msg_ptr++]; |
461 | writeb(byte, i2c->regs + S3C2410_IICDS); | 469 | writeb(byte, i2c->regs + S3C2410_IICDS); |
462 | 470 | ||
463 | /* delay after writing the byte to allow the | 471 | /* |
472 | * delay after writing the byte to allow the | ||
464 | * data setup time on the bus, as writing the | 473 | * data setup time on the bus, as writing the |
465 | * data to the register causes the first bit | 474 | * data to the register causes the first bit |
466 | * to appear on SDA, and SCL will change as | 475 | * to appear on SDA, and SCL will change as |
467 | * soon as the interrupt is acknowledged */ | 476 | * soon as the interrupt is acknowledged |
468 | 477 | */ | |
469 | ndelay(i2c->tx_setup); | 478 | ndelay(i2c->tx_setup); |
470 | 479 | ||
471 | } else if (!is_lastmsg(i2c)) { | 480 | } else if (!is_lastmsg(i2c)) { |
@@ -481,10 +490,11 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
481 | if (i2c->msg->flags & I2C_M_NOSTART) { | 490 | if (i2c->msg->flags & I2C_M_NOSTART) { |
482 | 491 | ||
483 | if (i2c->msg->flags & I2C_M_RD) { | 492 | if (i2c->msg->flags & I2C_M_RD) { |
484 | /* cannot do this, the controller | 493 | /* |
494 | * cannot do this, the controller | ||
485 | * forces us to send a new START | 495 | * forces us to send a new START |
486 | * when we change direction */ | 496 | * when we change direction |
487 | 497 | */ | |
488 | s3c24xx_i2c_stop(i2c, -EINVAL); | 498 | s3c24xx_i2c_stop(i2c, -EINVAL); |
489 | } | 499 | } |
490 | 500 | ||
@@ -497,17 +507,16 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
497 | 507 | ||
498 | } else { | 508 | } else { |
499 | /* send stop */ | 509 | /* send stop */ |
500 | |||
501 | s3c24xx_i2c_stop(i2c, 0); | 510 | s3c24xx_i2c_stop(i2c, 0); |
502 | } | 511 | } |
503 | break; | 512 | break; |
504 | 513 | ||
505 | case STATE_READ: | 514 | case STATE_READ: |
506 | /* we have a byte of data in the data register, do | 515 | /* |
516 | * we have a byte of data in the data register, do | ||
507 | * something with it, and then work out whether we are | 517 | * something with it, and then work out whether we are |
508 | * going to do any more read/write | 518 | * going to do any more read/write |
509 | */ | 519 | */ |
510 | |||
511 | byte = readb(i2c->regs + S3C2410_IICDS); | 520 | byte = readb(i2c->regs + S3C2410_IICDS); |
512 | i2c->msg->buf[i2c->msg_ptr++] = byte; | 521 | i2c->msg->buf[i2c->msg_ptr++] = byte; |
513 | 522 | ||
@@ -522,9 +531,10 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
522 | s3c24xx_i2c_disable_ack(i2c); | 531 | s3c24xx_i2c_disable_ack(i2c); |
523 | 532 | ||
524 | } else if (is_msgend(i2c)) { | 533 | } else if (is_msgend(i2c)) { |
525 | /* ok, we've read the entire buffer, see if there | 534 | /* |
526 | * is anything else we need to do */ | 535 | * ok, we've read the entire buffer, see if there |
527 | 536 | * is anything else we need to do | |
537 | */ | ||
528 | if (is_lastmsg(i2c)) { | 538 | if (is_lastmsg(i2c)) { |
529 | /* last message, send stop and complete */ | 539 | /* last message, send stop and complete */ |
530 | dev_dbg(i2c->dev, "READ: Send Stop\n"); | 540 | dev_dbg(i2c->dev, "READ: Send Stop\n"); |
@@ -578,9 +588,10 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id) | |||
578 | goto out; | 588 | goto out; |
579 | } | 589 | } |
580 | 590 | ||
581 | /* pretty much this leaves us with the fact that we've | 591 | /* |
582 | * transmitted or received whatever byte we last sent */ | 592 | * pretty much this leaves us with the fact that we've |
583 | 593 | * transmitted or received whatever byte we last sent | |
594 | */ | ||
584 | i2c_s3c_irq_nextbyte(i2c, status); | 595 | i2c_s3c_irq_nextbyte(i2c, status); |
585 | 596 | ||
586 | out: | 597 | out: |
@@ -726,9 +737,10 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, | |||
726 | 737 | ||
727 | ret = i2c->msg_idx; | 738 | ret = i2c->msg_idx; |
728 | 739 | ||
729 | /* having these next two as dev_err() makes life very | 740 | /* |
730 | * noisy when doing an i2cdetect */ | 741 | * Having these next two as dev_err() makes life very |
731 | 742 | * noisy when doing an i2cdetect | |
743 | */ | ||
732 | if (timeout == 0) | 744 | if (timeout == 0) |
733 | dev_dbg(i2c->dev, "timeout\n"); | 745 | dev_dbg(i2c->dev, "timeout\n"); |
734 | else if (ret != num) | 746 | else if (ret != num) |
@@ -1071,10 +1083,7 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) | |||
1071 | } | 1083 | } |
1072 | #else | 1084 | #else |
1073 | static void | 1085 | static void |
1074 | s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) | 1086 | s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { } |
1075 | { | ||
1076 | return; | ||
1077 | } | ||
1078 | #endif | 1087 | #endif |
1079 | 1088 | ||
1080 | static int s3c24xx_i2c_probe(struct platform_device *pdev) | 1089 | static int s3c24xx_i2c_probe(struct platform_device *pdev) |
@@ -1117,7 +1126,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1117 | init_waitqueue_head(&i2c->wait); | 1126 | init_waitqueue_head(&i2c->wait); |
1118 | 1127 | ||
1119 | /* find the clock and enable it */ | 1128 | /* find the clock and enable it */ |
1120 | |||
1121 | i2c->dev = &pdev->dev; | 1129 | i2c->dev = &pdev->dev; |
1122 | i2c->clk = devm_clk_get(&pdev->dev, "i2c"); | 1130 | i2c->clk = devm_clk_get(&pdev->dev, "i2c"); |
1123 | if (IS_ERR(i2c->clk)) { | 1131 | if (IS_ERR(i2c->clk)) { |
@@ -1127,9 +1135,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1127 | 1135 | ||
1128 | dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); | 1136 | dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); |
1129 | 1137 | ||
1130 | |||
1131 | /* map the registers */ | 1138 | /* map the registers */ |
1132 | |||
1133 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1139 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1134 | i2c->regs = devm_ioremap_resource(&pdev->dev, res); | 1140 | i2c->regs = devm_ioremap_resource(&pdev->dev, res); |
1135 | 1141 | ||
@@ -1140,22 +1146,17 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1140 | i2c->regs, res); | 1146 | i2c->regs, res); |
1141 | 1147 | ||
1142 | /* setup info block for the i2c core */ | 1148 | /* setup info block for the i2c core */ |
1143 | |||
1144 | i2c->adap.algo_data = i2c; | 1149 | i2c->adap.algo_data = i2c; |
1145 | i2c->adap.dev.parent = &pdev->dev; | 1150 | i2c->adap.dev.parent = &pdev->dev; |
1146 | |||
1147 | i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev); | 1151 | i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev); |
1148 | 1152 | ||
1149 | /* inititalise the i2c gpio lines */ | 1153 | /* inititalise the i2c gpio lines */ |
1150 | 1154 | if (i2c->pdata->cfg_gpio) | |
1151 | if (i2c->pdata->cfg_gpio) { | ||
1152 | i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); | 1155 | i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); |
1153 | } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) { | 1156 | else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) |
1154 | return -EINVAL; | 1157 | return -EINVAL; |
1155 | } | ||
1156 | 1158 | ||
1157 | /* initialise the i2c controller */ | 1159 | /* initialise the i2c controller */ |
1158 | |||
1159 | clk_prepare_enable(i2c->clk); | 1160 | clk_prepare_enable(i2c->clk); |
1160 | ret = s3c24xx_i2c_init(i2c); | 1161 | ret = s3c24xx_i2c_init(i2c); |
1161 | clk_disable(i2c->clk); | 1162 | clk_disable(i2c->clk); |
@@ -1164,10 +1165,11 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1164 | clk_unprepare(i2c->clk); | 1165 | clk_unprepare(i2c->clk); |
1165 | return ret; | 1166 | return ret; |
1166 | } | 1167 | } |
1167 | /* find the IRQ for this unit (note, this relies on the init call to | 1168 | |
1169 | /* | ||
1170 | * find the IRQ for this unit (note, this relies on the init call to | ||
1168 | * ensure no current IRQs pending | 1171 | * ensure no current IRQs pending |
1169 | */ | 1172 | */ |
1170 | |||
1171 | if (!(i2c->quirks & QUIRK_POLL)) { | 1173 | if (!(i2c->quirks & QUIRK_POLL)) { |
1172 | i2c->irq = ret = platform_get_irq(pdev, 0); | 1174 | i2c->irq = ret = platform_get_irq(pdev, 0); |
1173 | if (ret <= 0) { | 1175 | if (ret <= 0) { |
@@ -1176,9 +1178,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1176 | return ret; | 1178 | return ret; |
1177 | } | 1179 | } |
1178 | 1180 | ||
1179 | ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, | 1181 | ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, |
1180 | dev_name(&pdev->dev), i2c); | 1182 | 0, dev_name(&pdev->dev), i2c); |
1181 | |||
1182 | if (ret != 0) { | 1183 | if (ret != 0) { |
1183 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); | 1184 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); |
1184 | clk_unprepare(i2c->clk); | 1185 | clk_unprepare(i2c->clk); |
@@ -1193,12 +1194,12 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1193 | return ret; | 1194 | return ret; |
1194 | } | 1195 | } |
1195 | 1196 | ||
1196 | /* Note, previous versions of the driver used i2c_add_adapter() | 1197 | /* |
1198 | * Note, previous versions of the driver used i2c_add_adapter() | ||
1197 | * to add the bus at any number. We now pass the bus number via | 1199 | * to add the bus at any number. We now pass the bus number via |
1198 | * the platform data, so if unset it will now default to always | 1200 | * the platform data, so if unset it will now default to always |
1199 | * being bus 0. | 1201 | * being bus 0. |
1200 | */ | 1202 | */ |
1201 | |||
1202 | i2c->adap.nr = i2c->pdata->bus_num; | 1203 | i2c->adap.nr = i2c->pdata->bus_num; |
1203 | i2c->adap.dev.of_node = pdev->dev.of_node; | 1204 | i2c->adap.dev.of_node = pdev->dev.of_node; |
1204 | 1205 | ||