Skip to content

Commit 788807d

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "i2c driver bugfixes (s3c2410, slave-eeprom, sh_mobile), size regression "bugfix" (i2c slave), documentation bugfix (st). Also, one documentation update (da9063), so some devicetrees can now be verified" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: sh_mobile: terminate DMA reads properly i2c: Only include slave support if selected i2c: s3c2410: fix ABBA deadlock by keeping clock prepared i2c: slave-eeprom: fix boundary check when using sysfs i2c: st: Rename clock reference to something that exists DT: i2c: Add devices handled by the da9063 MFD driver
2 parents 2141fd0 + 32e2240 commit 788807d

File tree

8 files changed

+41
-10
lines changed

8 files changed

+41
-10
lines changed

Documentation/devicetree/bindings/i2c/i2c-st.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ i2c0: i2c@fed40000 {
3131
compatible = "st,comms-ssc4-i2c";
3232
reg = <0xfed40000 0x110>;
3333
interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
34-
clocks = <&CLK_S_ICN_REG_0>;
34+
clocks = <&clk_s_a0_ls CLK_ICN_REG>;
3535
clock-names = "ssc";
3636
clock-frequency = <400000>;
3737
pinctrl-names = "default";

Documentation/devicetree/bindings/i2c/trivial-devices.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dallas,ds3232 Extremely Accurate I²C RTC with Integrated Crystal and SRAM
4747
dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O
4848
dallas,ds75 Digital Thermometer and Thermostat
4949
dlg,da9053 DA9053: flexible system level PMIC with multicore support
50+
dlg,da9063 DA9063: system PMIC for quad-core application processors
5051
epson,rx8025 High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE
5152
epson,rx8581 I2C-BUS INTERFACE REAL TIME CLOCK MODULE
5253
fsl,mag3110 MAG3110: Xtrinsic High Accuracy, 3D Magnetometer

drivers/i2c/busses/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ config I2C_XLR
881881
config I2C_RCAR
882882
tristate "Renesas R-Car I2C Controller"
883883
depends on ARCH_SHMOBILE || COMPILE_TEST
884+
select I2C_SLAVE
884885
help
885886
If you say yes to this option, support will be included for the
886887
R-Car I2C controller.

drivers/i2c/busses/i2c-s3c2410.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,16 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
785785
int ret;
786786

787787
pm_runtime_get_sync(&adap->dev);
788-
clk_prepare_enable(i2c->clk);
788+
ret = clk_enable(i2c->clk);
789+
if (ret)
790+
return ret;
789791

790792
for (retry = 0; retry < adap->retries; retry++) {
791793

792794
ret = s3c24xx_i2c_doxfer(i2c, msgs, num);
793795

794796
if (ret != -EAGAIN) {
795-
clk_disable_unprepare(i2c->clk);
797+
clk_disable(i2c->clk);
796798
pm_runtime_put(&adap->dev);
797799
return ret;
798800
}
@@ -802,7 +804,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
802804
udelay(100);
803805
}
804806

805-
clk_disable_unprepare(i2c->clk);
807+
clk_disable(i2c->clk);
806808
pm_runtime_put(&adap->dev);
807809
return -EREMOTEIO;
808810
}
@@ -1197,7 +1199,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
11971199

11981200
clk_prepare_enable(i2c->clk);
11991201
ret = s3c24xx_i2c_init(i2c);
1200-
clk_disable_unprepare(i2c->clk);
1202+
clk_disable(i2c->clk);
12011203
if (ret != 0) {
12021204
dev_err(&pdev->dev, "I2C controller init failed\n");
12031205
return ret;
@@ -1210,6 +1212,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
12101212
i2c->irq = ret = platform_get_irq(pdev, 0);
12111213
if (ret <= 0) {
12121214
dev_err(&pdev->dev, "cannot find IRQ\n");
1215+
clk_unprepare(i2c->clk);
12131216
return ret;
12141217
}
12151218

@@ -1218,13 +1221,15 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
12181221

12191222
if (ret != 0) {
12201223
dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
1224+
clk_unprepare(i2c->clk);
12211225
return ret;
12221226
}
12231227
}
12241228

12251229
ret = s3c24xx_i2c_register_cpufreq(i2c);
12261230
if (ret < 0) {
12271231
dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
1232+
clk_unprepare(i2c->clk);
12281233
return ret;
12291234
}
12301235

@@ -1241,6 +1246,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
12411246
if (ret < 0) {
12421247
dev_err(&pdev->dev, "failed to add bus to i2c core\n");
12431248
s3c24xx_i2c_deregister_cpufreq(i2c);
1249+
clk_unprepare(i2c->clk);
12441250
return ret;
12451251
}
12461252

@@ -1262,6 +1268,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
12621268
{
12631269
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
12641270

1271+
clk_unprepare(i2c->clk);
1272+
12651273
pm_runtime_disable(&i2c->adap.dev);
12661274
pm_runtime_disable(&pdev->dev);
12671275

@@ -1293,13 +1301,16 @@ static int s3c24xx_i2c_resume_noirq(struct device *dev)
12931301
{
12941302
struct platform_device *pdev = to_platform_device(dev);
12951303
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
1304+
int ret;
12961305

12971306
if (!IS_ERR(i2c->sysreg))
12981307
regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, i2c->sys_i2c_cfg);
12991308

1300-
clk_prepare_enable(i2c->clk);
1309+
ret = clk_enable(i2c->clk);
1310+
if (ret)
1311+
return ret;
13011312
s3c24xx_i2c_init(i2c);
1302-
clk_disable_unprepare(i2c->clk);
1313+
clk_disable(i2c->clk);
13031314
i2c->suspended = 0;
13041315

13051316
return 0;

drivers/i2c/busses/i2c-sh_mobile.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct sh_mobile_i2c_data {
139139
int pos;
140140
int sr;
141141
bool send_stop;
142+
bool stop_after_dma;
142143

143144
struct resource *res;
144145
struct dma_chan *dma_tx;
@@ -407,7 +408,7 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
407408

408409
if (pd->pos == pd->msg->len) {
409410
/* Send stop if we haven't yet (DMA case) */
410-
if (pd->send_stop && (iic_rd(pd, ICCR) & ICCR_BBSY))
411+
if (pd->send_stop && pd->stop_after_dma)
411412
i2c_op(pd, OP_TX_STOP, 0);
412413
return 1;
413414
}
@@ -449,6 +450,13 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
449450
real_pos = pd->pos - 2;
450451

451452
if (pd->pos == pd->msg->len) {
453+
if (pd->stop_after_dma) {
454+
/* Simulate PIO end condition after DMA transfer */
455+
i2c_op(pd, OP_RX_STOP, 0);
456+
pd->pos++;
457+
break;
458+
}
459+
452460
if (real_pos < 0) {
453461
i2c_op(pd, OP_RX_STOP, 0);
454462
break;
@@ -536,6 +544,7 @@ static void sh_mobile_i2c_dma_callback(void *data)
536544

537545
sh_mobile_i2c_dma_unmap(pd);
538546
pd->pos = pd->msg->len;
547+
pd->stop_after_dma = true;
539548

540549
iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
541550
}
@@ -726,6 +735,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
726735
bool do_start = pd->send_stop || !i;
727736
msg = &msgs[i];
728737
pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP;
738+
pd->stop_after_dma = false;
729739

730740
err = start_ch(pd, msg, do_start);
731741
if (err)

drivers/i2c/i2c-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
29722972
}
29732973
EXPORT_SYMBOL(i2c_smbus_xfer);
29742974

2975+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
29752976
int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
29762977
{
29772978
int ret;
@@ -3019,6 +3020,7 @@ int i2c_slave_unregister(struct i2c_client *client)
30193020
return ret;
30203021
}
30213022
EXPORT_SYMBOL_GPL(i2c_slave_unregister);
3023+
#endif
30223024

30233025
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
30243026
MODULE_DESCRIPTION("I2C-Bus main module");

drivers/i2c/i2c-slave-eeprom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj
7474
struct eeprom_data *eeprom;
7575
unsigned long flags;
7676

77-
if (off + count >= attr->size)
77+
if (off + count > attr->size)
7878
return -EFBIG;
7979

8080
eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));
@@ -92,7 +92,7 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob
9292
struct eeprom_data *eeprom;
9393
unsigned long flags;
9494

95-
if (off + count >= attr->size)
95+
if (off + count > attr->size)
9696
return -EFBIG;
9797

9898
eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));

include/linux/i2c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ struct i2c_client {
228228
struct device dev; /* the device structure */
229229
int irq; /* irq issued by device */
230230
struct list_head detected;
231+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
231232
i2c_slave_cb_t slave_cb; /* callback for slave mode */
233+
#endif
232234
};
233235
#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
234236

@@ -253,6 +255,7 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
253255

254256
/* I2C slave support */
255257

258+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
256259
enum i2c_slave_event {
257260
I2C_SLAVE_REQ_READ_START,
258261
I2C_SLAVE_REQ_READ_END,
@@ -269,6 +272,7 @@ static inline int i2c_slave_event(struct i2c_client *client,
269272
{
270273
return client->slave_cb(client, event, val);
271274
}
275+
#endif
272276

273277
/**
274278
* struct i2c_board_info - template for device creation
@@ -404,8 +408,10 @@ struct i2c_algorithm {
404408
/* To determine what the adapter supports */
405409
u32 (*functionality) (struct i2c_adapter *);
406410

411+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
407412
int (*reg_slave)(struct i2c_client *client);
408413
int (*unreg_slave)(struct i2c_client *client);
414+
#endif
409415
};
410416

411417
/**

0 commit comments

Comments
 (0)