Skip to content

Commit 03fb3ac

Browse files
committed
Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "A set of driver and core fixes as well as MAINTAINER update" * 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: MAINTAINERS: add maintainer for mediatek i2c controller driver i2c: mux: Replace zero-length array with flexible-array i2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()' i2c: altera: Fix race between xfer_msg and isr thread i2c: algo-pca: update contact email i2c: at91: Fix pinmux after devm_gpiod_get() for bus recovery i2c: use my kernel.org address from now on i2c: fix missing pm_runtime_put_sync in i2c_device_probe
2 parents 97076ea + efa7fb4 commit 03fb3ac

File tree

10 files changed

+58
-16
lines changed

10 files changed

+58
-16
lines changed

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ Vladimir Davydov <[email protected]> <[email protected]>
288288
289289
Takashi YOSHII <[email protected]>
290290
291+
292+
291293
292294
Yusuke Goda <[email protected]>
293295
Gustavo Padovan <[email protected]>

MAINTAINERS

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7941,7 +7941,7 @@ F: Documentation/i2c/busses/i2c-parport.rst
79417941
F: drivers/i2c/busses/i2c-parport.c
79427942

79437943
I2C SUBSYSTEM
7944-
M: Wolfram Sang <wsa@the-dreams.de>
7944+
M: Wolfram Sang <wsa@kernel.org>
79457945
79467946
S: Maintained
79477947
W: https://i2c.wiki.kernel.org/
@@ -10662,6 +10662,13 @@ L: [email protected]
1066210662
S: Maintained
1066310663
F: drivers/net/ethernet/mediatek/
1066410664

10665+
MEDIATEK I2C CONTROLLER DRIVER
10666+
M: Qii Wang <[email protected]>
10667+
10668+
S: Maintained
10669+
F: Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt
10670+
F: drivers/i2c/busses/i2c-mt65xx.c
10671+
1066510672
MEDIATEK JPEG DRIVER
1066610673
M: Rick Chang <[email protected]>
1066710674
M: Bin Liu <[email protected]>

drivers/i2c/algos/i2c-algo-pca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ int i2c_pca_add_numbered_bus(struct i2c_adapter *adap)
542542
EXPORT_SYMBOL(i2c_pca_add_numbered_bus);
543543

544544
MODULE_AUTHOR("Ian Campbell <[email protected]>, "
545-
"Wolfram Sang <w.sang@pengutronix.de>");
545+
"Wolfram Sang <kernel@pengutronix.de>");
546546
MODULE_DESCRIPTION("I2C-Bus PCA9564/PCA9665 algorithm");
547547
MODULE_LICENSE("GPL");
548548

drivers/i2c/busses/i2c-altera.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* @isr_mask: cached copy of local ISR enables.
7171
* @isr_status: cached copy of local ISR status.
7272
* @lock: spinlock for IRQ synchronization.
73+
* @isr_mutex: mutex for IRQ thread.
7374
*/
7475
struct altr_i2c_dev {
7576
void __iomem *base;
@@ -86,6 +87,7 @@ struct altr_i2c_dev {
8687
u32 isr_mask;
8788
u32 isr_status;
8889
spinlock_t lock; /* IRQ synchronization */
90+
struct mutex isr_mutex;
8991
};
9092

9193
static void
@@ -245,10 +247,11 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
245247
struct altr_i2c_dev *idev = _dev;
246248
u32 status = idev->isr_status;
247249

250+
mutex_lock(&idev->isr_mutex);
248251
if (!idev->msg) {
249252
dev_warn(idev->dev, "unexpected interrupt\n");
250253
altr_i2c_int_clear(idev, ALTR_I2C_ALL_IRQ);
251-
return IRQ_HANDLED;
254+
goto out;
252255
}
253256
read = (idev->msg->flags & I2C_M_RD) != 0;
254257

@@ -301,6 +304,8 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
301304
complete(&idev->msg_complete);
302305
dev_dbg(idev->dev, "Message Complete\n");
303306
}
307+
out:
308+
mutex_unlock(&idev->isr_mutex);
304309

305310
return IRQ_HANDLED;
306311
}
@@ -312,6 +317,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
312317
u32 value;
313318
u8 addr = i2c_8bit_addr_from_msg(msg);
314319

320+
mutex_lock(&idev->isr_mutex);
315321
idev->msg = msg;
316322
idev->msg_len = msg->len;
317323
idev->buf = msg->buf;
@@ -336,6 +342,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
336342
altr_i2c_int_enable(idev, imask, true);
337343
altr_i2c_fill_tx_fifo(idev);
338344
}
345+
mutex_unlock(&idev->isr_mutex);
339346

340347
time_left = wait_for_completion_timeout(&idev->msg_complete,
341348
ALTR_I2C_XFER_TIMEOUT);
@@ -409,6 +416,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
409416
idev->dev = &pdev->dev;
410417
init_completion(&idev->msg_complete);
411418
spin_lock_init(&idev->lock);
419+
mutex_init(&idev->isr_mutex);
412420

413421
ret = device_property_read_u32(idev->dev, "fifo-size",
414422
&idev->fifo_size);

drivers/i2c/busses/i2c-at91-master.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,18 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
845845
PINCTRL_STATE_DEFAULT);
846846
dev->pinctrl_pins_gpio = pinctrl_lookup_state(dev->pinctrl,
847847
"gpio");
848+
if (IS_ERR(dev->pinctrl_pins_default) ||
849+
IS_ERR(dev->pinctrl_pins_gpio)) {
850+
dev_info(&pdev->dev, "pinctrl states incomplete for recovery\n");
851+
return -EINVAL;
852+
}
853+
854+
/*
855+
* pins will be taken as GPIO, so we might as well inform pinctrl about
856+
* this and move the state to GPIO
857+
*/
858+
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_gpio);
859+
848860
rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
849861
if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER)
850862
return -EPROBE_DEFER;
@@ -855,9 +867,7 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
855867
return -EPROBE_DEFER;
856868

857869
if (IS_ERR(rinfo->sda_gpiod) ||
858-
IS_ERR(rinfo->scl_gpiod) ||
859-
IS_ERR(dev->pinctrl_pins_default) ||
860-
IS_ERR(dev->pinctrl_pins_gpio)) {
870+
IS_ERR(rinfo->scl_gpiod)) {
861871
dev_info(&pdev->dev, "recovery information incomplete\n");
862872
if (!IS_ERR(rinfo->sda_gpiod)) {
863873
gpiod_put(rinfo->sda_gpiod);
@@ -867,9 +877,13 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
867877
gpiod_put(rinfo->scl_gpiod);
868878
rinfo->scl_gpiod = NULL;
869879
}
880+
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
870881
return -EINVAL;
871882
}
872883

884+
/* change the state of the pins back to their default state */
885+
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
886+
873887
dev_info(&pdev->dev, "using scl, sda for recovery\n");
874888

875889
rinfo->prepare_recovery = at91_prepare_twi_recovery;

drivers/i2c/i2c-core-base.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Mux support by Rodolfo Giometti <[email protected]> and
88
* Michael Lawnick <[email protected]>
99
*
10-
* Copyright (C) 2013-2017 Wolfram Sang <wsa@the-dreams.de>
10+
* Copyright (C) 2013-2017 Wolfram Sang <wsa@kernel.org>
1111
*/
1212

1313
#define pr_fmt(fmt) "i2c-core: " fmt
@@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
338338
} else if (ACPI_COMPANION(dev)) {
339339
irq = i2c_acpi_get_irq(client);
340340
}
341-
if (irq == -EPROBE_DEFER)
342-
return irq;
341+
if (irq == -EPROBE_DEFER) {
342+
status = irq;
343+
goto put_sync_adapter;
344+
}
343345

344346
if (irq < 0)
345347
irq = 0;
@@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
353355
*/
354356
if (!driver->id_table &&
355357
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
356-
!i2c_of_match_device(dev->driver->of_match_table, client))
357-
return -ENODEV;
358+
!i2c_of_match_device(dev->driver->of_match_table, client)) {
359+
status = -ENODEV;
360+
goto put_sync_adapter;
361+
}
358362

359363
if (client->flags & I2C_CLIENT_WAKE) {
360364
int wakeirq;
361365

362366
wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
363-
if (wakeirq == -EPROBE_DEFER)
364-
return wakeirq;
367+
if (wakeirq == -EPROBE_DEFER) {
368+
status = wakeirq;
369+
goto put_sync_adapter;
370+
}
365371

366372
device_init_wakeup(&client->dev, true);
367373

@@ -408,6 +414,10 @@ static int i2c_device_probe(struct device *dev)
408414
err_clear_wakeup_irq:
409415
dev_pm_clear_wake_irq(&client->dev);
410416
device_init_wakeup(&client->dev, false);
417+
put_sync_adapter:
418+
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
419+
pm_runtime_put_sync(&client->adapter->dev);
420+
411421
return status;
412422
}
413423

drivers/i2c/i2c-core-of.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (C) 2008 Jochen Friedrich <[email protected]>
66
* based on a previous patch from Jon Smirl <[email protected]>
77
*
8-
* Copyright (C) 2013, 2018 Wolfram Sang <wsa@the-dreams.de>
8+
* Copyright (C) 2013, 2018 Wolfram Sang <wsa@kernel.org>
99
*/
1010

1111
#include <dt-bindings/i2c/i2c.h>

drivers/i2c/muxes/i2c-demux-pinctrl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
272272
err_rollback_available:
273273
device_remove_file(&pdev->dev, &dev_attr_available_masters);
274274
err_rollback:
275+
i2c_demux_deactivate_master(priv);
275276
for (j = 0; j < i; j++) {
276277
of_node_put(priv->chan[j].parent_np);
277278
of_changeset_destroy(&priv->chan[j].chgset);

include/linux/i2c-mux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct i2c_mux_core {
2929

3030
int num_adapters;
3131
int max_adapters;
32-
struct i2c_adapter *adapter[0];
32+
struct i2c_adapter *adapter[];
3333
};
3434

3535
struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,

include/linux/i2c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* i2c.h - definitions for the Linux i2c bus interface
44
* Copyright (C) 1995-2000 Simon G. Vogl
5-
* Copyright (C) 2013-2019 Wolfram Sang <wsa@the-dreams.de>
5+
* Copyright (C) 2013-2019 Wolfram Sang <wsa@kernel.org>
66
*
77
* With some changes from Kyösti Mälkki <[email protected]> and
88
* Frodo Looijaard <[email protected]>

0 commit comments

Comments
 (0)