Skip to content

Commit

Permalink
Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
torvalds committed May 19, 2020
2 parents 97076ea + efa7fb4 commit 03fb3ac
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ Vladimir Davydov <[email protected]> <[email protected]>
Vladimir Davydov <[email protected]> <[email protected]>
Takashi YOSHII <[email protected]>
Will Deacon <[email protected]> <[email protected]>
Wolfram Sang <[email protected]> <[email protected]>
Wolfram Sang <[email protected]> <[email protected]>
Yakir Yang <[email protected]> <[email protected]>
Yusuke Goda <[email protected]>
Gustavo Padovan <[email protected]>
Expand Down
9 changes: 8 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -7941,7 +7941,7 @@ F: Documentation/i2c/busses/i2c-parport.rst
F: drivers/i2c/busses/i2c-parport.c

I2C SUBSYSTEM
M: Wolfram Sang <wsa@the-dreams.de>
M: Wolfram Sang <wsa@kernel.org>
L: [email protected]
S: Maintained
W: https://i2c.wiki.kernel.org/
Expand Down Expand Up @@ -10662,6 +10662,13 @@ L: [email protected]
S: Maintained
F: drivers/net/ethernet/mediatek/

MEDIATEK I2C CONTROLLER DRIVER
M: Qii Wang <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt
F: drivers/i2c/busses/i2c-mt65xx.c

MEDIATEK JPEG DRIVER
M: Rick Chang <[email protected]>
M: Bin Liu <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/algos/i2c-algo-pca.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ int i2c_pca_add_numbered_bus(struct i2c_adapter *adap)
EXPORT_SYMBOL(i2c_pca_add_numbered_bus);

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

Expand Down
10 changes: 9 additions & 1 deletion drivers/i2c/busses/i2c-altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* @isr_mask: cached copy of local ISR enables.
* @isr_status: cached copy of local ISR status.
* @lock: spinlock for IRQ synchronization.
* @isr_mutex: mutex for IRQ thread.
*/
struct altr_i2c_dev {
void __iomem *base;
Expand All @@ -86,6 +87,7 @@ struct altr_i2c_dev {
u32 isr_mask;
u32 isr_status;
spinlock_t lock; /* IRQ synchronization */
struct mutex isr_mutex;
};

static void
Expand Down Expand Up @@ -245,10 +247,11 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
struct altr_i2c_dev *idev = _dev;
u32 status = idev->isr_status;

mutex_lock(&idev->isr_mutex);
if (!idev->msg) {
dev_warn(idev->dev, "unexpected interrupt\n");
altr_i2c_int_clear(idev, ALTR_I2C_ALL_IRQ);
return IRQ_HANDLED;
goto out;
}
read = (idev->msg->flags & I2C_M_RD) != 0;

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

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

mutex_lock(&idev->isr_mutex);
idev->msg = msg;
idev->msg_len = msg->len;
idev->buf = msg->buf;
Expand All @@ -336,6 +342,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
altr_i2c_int_enable(idev, imask, true);
altr_i2c_fill_tx_fifo(idev);
}
mutex_unlock(&idev->isr_mutex);

time_left = wait_for_completion_timeout(&idev->msg_complete,
ALTR_I2C_XFER_TIMEOUT);
Expand Down Expand Up @@ -409,6 +416,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
idev->dev = &pdev->dev;
init_completion(&idev->msg_complete);
spin_lock_init(&idev->lock);
mutex_init(&idev->isr_mutex);

ret = device_property_read_u32(idev->dev, "fifo-size",
&idev->fifo_size);
Expand Down
20 changes: 17 additions & 3 deletions drivers/i2c/busses/i2c-at91-master.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,18 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
PINCTRL_STATE_DEFAULT);
dev->pinctrl_pins_gpio = pinctrl_lookup_state(dev->pinctrl,
"gpio");
if (IS_ERR(dev->pinctrl_pins_default) ||
IS_ERR(dev->pinctrl_pins_gpio)) {
dev_info(&pdev->dev, "pinctrl states incomplete for recovery\n");
return -EINVAL;
}

/*
* pins will be taken as GPIO, so we might as well inform pinctrl about
* this and move the state to GPIO
*/
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_gpio);

rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER)
return -EPROBE_DEFER;
Expand All @@ -855,9 +867,7 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
return -EPROBE_DEFER;

if (IS_ERR(rinfo->sda_gpiod) ||
IS_ERR(rinfo->scl_gpiod) ||
IS_ERR(dev->pinctrl_pins_default) ||
IS_ERR(dev->pinctrl_pins_gpio)) {
IS_ERR(rinfo->scl_gpiod)) {
dev_info(&pdev->dev, "recovery information incomplete\n");
if (!IS_ERR(rinfo->sda_gpiod)) {
gpiod_put(rinfo->sda_gpiod);
Expand All @@ -867,9 +877,13 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
gpiod_put(rinfo->scl_gpiod);
rinfo->scl_gpiod = NULL;
}
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
return -EINVAL;
}

/* change the state of the pins back to their default state */
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);

dev_info(&pdev->dev, "using scl, sda for recovery\n");

rinfo->prepare_recovery = at91_prepare_twi_recovery;
Expand Down
24 changes: 17 additions & 7 deletions drivers/i2c/i2c-core-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Mux support by Rodolfo Giometti <[email protected]> and
* Michael Lawnick <[email protected]>
*
* Copyright (C) 2013-2017 Wolfram Sang <wsa@the-dreams.de>
* Copyright (C) 2013-2017 Wolfram Sang <wsa@kernel.org>
*/

#define pr_fmt(fmt) "i2c-core: " fmt
Expand Down Expand Up @@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
} else if (ACPI_COMPANION(dev)) {
irq = i2c_acpi_get_irq(client);
}
if (irq == -EPROBE_DEFER)
return irq;
if (irq == -EPROBE_DEFER) {
status = irq;
goto put_sync_adapter;
}

if (irq < 0)
irq = 0;
Expand All @@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
*/
if (!driver->id_table &&
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
!i2c_of_match_device(dev->driver->of_match_table, client))
return -ENODEV;
!i2c_of_match_device(dev->driver->of_match_table, client)) {
status = -ENODEV;
goto put_sync_adapter;
}

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

wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
if (wakeirq == -EPROBE_DEFER)
return wakeirq;
if (wakeirq == -EPROBE_DEFER) {
status = wakeirq;
goto put_sync_adapter;
}

device_init_wakeup(&client->dev, true);

Expand Down Expand Up @@ -408,6 +414,10 @@ static int i2c_device_probe(struct device *dev)
err_clear_wakeup_irq:
dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false);
put_sync_adapter:
if (client->flags & I2C_CLIENT_HOST_NOTIFY)
pm_runtime_put_sync(&client->adapter->dev);

return status;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-core-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2008 Jochen Friedrich <[email protected]>
* based on a previous patch from Jon Smirl <[email protected]>
*
* Copyright (C) 2013, 2018 Wolfram Sang <wsa@the-dreams.de>
* Copyright (C) 2013, 2018 Wolfram Sang <wsa@kernel.org>
*/

#include <dt-bindings/i2c/i2c.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/i2c/muxes/i2c-demux-pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
err_rollback_available:
device_remove_file(&pdev->dev, &dev_attr_available_masters);
err_rollback:
i2c_demux_deactivate_master(priv);
for (j = 0; j < i; j++) {
of_node_put(priv->chan[j].parent_np);
of_changeset_destroy(&priv->chan[j].chgset);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/i2c-mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct i2c_mux_core {

int num_adapters;
int max_adapters;
struct i2c_adapter *adapter[0];
struct i2c_adapter *adapter[];
};

struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
Expand Down
2 changes: 1 addition & 1 deletion include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* i2c.h - definitions for the Linux i2c bus interface
* Copyright (C) 1995-2000 Simon G. Vogl
* Copyright (C) 2013-2019 Wolfram Sang <wsa@the-dreams.de>
* Copyright (C) 2013-2019 Wolfram Sang <wsa@kernel.org>
*
* With some changes from Kyösti Mälkki <[email protected]> and
* Frodo Looijaard <[email protected]>
Expand Down

0 comments on commit 03fb3ac

Please sign in to comment.