.. | .. |
---|
67 | 67 | |
---|
68 | 68 | /* STANDARD MODE frequency */ |
---|
69 | 69 | #define SYNQUACER_I2C_CLK_MASTER_STD(rate) \ |
---|
70 | | - DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2) |
---|
| 70 | + DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_MAX_STANDARD_MODE_FREQ) - 2, 2) |
---|
71 | 71 | /* FAST MODE frequency */ |
---|
72 | 72 | #define SYNQUACER_I2C_CLK_MASTER_FAST(rate) \ |
---|
73 | | - DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3) |
---|
| 73 | + DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_MAX_FAST_MODE_FREQ) - 2) * 2, 3) |
---|
74 | 74 | |
---|
75 | 75 | /* (clkrate <= 18000000) */ |
---|
76 | 76 | /* calculate the value of CS bits in CCR register on standard mode */ |
---|
.. | .. |
---|
144 | 144 | u32 timeout_ms; |
---|
145 | 145 | enum i2c_state state; |
---|
146 | 146 | struct i2c_adapter adapter; |
---|
147 | | - |
---|
148 | | - bool is_suspended; |
---|
149 | 147 | }; |
---|
150 | 148 | |
---|
151 | 149 | static inline int is_lastmsg(struct synquacer_i2c *i2c) |
---|
.. | .. |
---|
316 | 314 | unsigned long timeout; |
---|
317 | 315 | int ret; |
---|
318 | 316 | |
---|
319 | | - if (i2c->is_suspended) |
---|
320 | | - return -EBUSY; |
---|
321 | | - |
---|
322 | 317 | synquacer_i2c_hw_init(i2c); |
---|
323 | 318 | bsr = readb(i2c->base + SYNQUACER_I2C_REG_BSR); |
---|
324 | 319 | if (bsr & SYNQUACER_I2C_BSR_BB) { |
---|
.. | .. |
---|
403 | 398 | |
---|
404 | 399 | if (i2c->state == STATE_READ) |
---|
405 | 400 | goto prepare_read; |
---|
406 | | - |
---|
407 | | - /* fallthru */ |
---|
| 401 | + fallthrough; |
---|
408 | 402 | |
---|
409 | 403 | case STATE_WRITE: |
---|
410 | 404 | if (bsr & SYNQUACER_I2C_BSR_LRB) { |
---|
.. | .. |
---|
531 | 525 | .functionality = synquacer_i2c_functionality, |
---|
532 | 526 | }; |
---|
533 | 527 | |
---|
534 | | -static struct i2c_adapter synquacer_i2c_ops = { |
---|
| 528 | +static const struct i2c_adapter synquacer_i2c_ops = { |
---|
535 | 529 | .owner = THIS_MODULE, |
---|
536 | 530 | .name = "synquacer_i2c-adapter", |
---|
537 | 531 | .algo = &synquacer_i2c_algo, |
---|
.. | .. |
---|
541 | 535 | static int synquacer_i2c_probe(struct platform_device *pdev) |
---|
542 | 536 | { |
---|
543 | 537 | struct synquacer_i2c *i2c; |
---|
544 | | - struct resource *r; |
---|
545 | 538 | u32 bus_speed; |
---|
546 | 539 | int ret; |
---|
547 | 540 | |
---|
.. | .. |
---|
558 | 551 | &i2c->pclkrate); |
---|
559 | 552 | |
---|
560 | 553 | i2c->pclk = devm_clk_get(&pdev->dev, "pclk"); |
---|
561 | | - if (IS_ERR(i2c->pclk) && PTR_ERR(i2c->pclk) == -EPROBE_DEFER) |
---|
| 554 | + if (PTR_ERR(i2c->pclk) == -EPROBE_DEFER) |
---|
562 | 555 | return -EPROBE_DEFER; |
---|
563 | 556 | if (!IS_ERR_OR_NULL(i2c->pclk)) { |
---|
564 | 557 | dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk); |
---|
.. | .. |
---|
579 | 572 | return -EINVAL; |
---|
580 | 573 | } |
---|
581 | 574 | |
---|
582 | | - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
583 | | - i2c->base = devm_ioremap_resource(&pdev->dev, r); |
---|
| 575 | + i2c->base = devm_platform_ioremap_resource(pdev, 0); |
---|
584 | 576 | if (IS_ERR(i2c->base)) |
---|
585 | 577 | return PTR_ERR(i2c->base); |
---|
586 | 578 | |
---|
587 | 579 | i2c->irq = platform_get_irq(pdev, 0); |
---|
588 | | - if (i2c->irq < 0) { |
---|
589 | | - dev_err(&pdev->dev, "no IRQ resource found\n"); |
---|
590 | | - return -ENODEV; |
---|
591 | | - } |
---|
| 580 | + if (i2c->irq < 0) |
---|
| 581 | + return i2c->irq; |
---|
592 | 582 | |
---|
593 | 583 | ret = devm_request_irq(&pdev->dev, i2c->irq, synquacer_i2c_isr, |
---|
594 | 584 | 0, dev_name(&pdev->dev), i2c); |
---|
.. | .. |
---|
607 | 597 | i2c->adapter.nr = pdev->id; |
---|
608 | 598 | init_completion(&i2c->completion); |
---|
609 | 599 | |
---|
610 | | - if (bus_speed < 400000) |
---|
| 600 | + if (bus_speed < I2C_MAX_FAST_MODE_FREQ) |
---|
611 | 601 | i2c->speed_khz = SYNQUACER_I2C_SPEED_SM; |
---|
612 | 602 | else |
---|
613 | 603 | i2c->speed_khz = SYNQUACER_I2C_SPEED_FM; |
---|