Commit 03fb3aca authored by Linus Torvalds's avatar Linus Torvalds

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
parents 97076ea4 efa7fb4c
...@@ -288,6 +288,8 @@ Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> ...@@ -288,6 +288,8 @@ Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com>
Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com> Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
Takashi YOSHII <takashi.yoshii.zj@renesas.com> Takashi YOSHII <takashi.yoshii.zj@renesas.com>
Will Deacon <will@kernel.org> <will.deacon@arm.com> Will Deacon <will@kernel.org> <will.deacon@arm.com>
Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>
Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de>
Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com> Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
Yusuke Goda <goda.yusuke@renesas.com> Yusuke Goda <goda.yusuke@renesas.com>
Gustavo Padovan <gustavo@las.ic.unicamp.br> Gustavo Padovan <gustavo@las.ic.unicamp.br>
......
...@@ -7941,7 +7941,7 @@ F: Documentation/i2c/busses/i2c-parport.rst ...@@ -7941,7 +7941,7 @@ F: Documentation/i2c/busses/i2c-parport.rst
F: drivers/i2c/busses/i2c-parport.c F: drivers/i2c/busses/i2c-parport.c
I2C SUBSYSTEM I2C SUBSYSTEM
M: Wolfram Sang <wsa@the-dreams.de> M: Wolfram Sang <wsa@kernel.org>
L: linux-i2c@vger.kernel.org L: linux-i2c@vger.kernel.org
S: Maintained S: Maintained
W: https://i2c.wiki.kernel.org/ W: https://i2c.wiki.kernel.org/
...@@ -10662,6 +10662,13 @@ L: netdev@vger.kernel.org ...@@ -10662,6 +10662,13 @@ L: netdev@vger.kernel.org
S: Maintained S: Maintained
F: drivers/net/ethernet/mediatek/ F: drivers/net/ethernet/mediatek/
MEDIATEK I2C CONTROLLER DRIVER
M: Qii Wang <qii.wang@mediatek.com>
L: linux-i2c@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/i2c/i2c-mt65xx.txt
F: drivers/i2c/busses/i2c-mt65xx.c
MEDIATEK JPEG DRIVER MEDIATEK JPEG DRIVER
M: Rick Chang <rick.chang@mediatek.com> M: Rick Chang <rick.chang@mediatek.com>
M: Bin Liu <bin.liu@mediatek.com> M: Bin Liu <bin.liu@mediatek.com>
......
...@@ -542,7 +542,7 @@ int i2c_pca_add_numbered_bus(struct i2c_adapter *adap) ...@@ -542,7 +542,7 @@ int i2c_pca_add_numbered_bus(struct i2c_adapter *adap)
EXPORT_SYMBOL(i2c_pca_add_numbered_bus); EXPORT_SYMBOL(i2c_pca_add_numbered_bus);
MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>, " MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>, "
"Wolfram Sang <w.sang@pengutronix.de>"); "Wolfram Sang <kernel@pengutronix.de>");
MODULE_DESCRIPTION("I2C-Bus PCA9564/PCA9665 algorithm"); MODULE_DESCRIPTION("I2C-Bus PCA9564/PCA9665 algorithm");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
* @isr_mask: cached copy of local ISR enables. * @isr_mask: cached copy of local ISR enables.
* @isr_status: cached copy of local ISR status. * @isr_status: cached copy of local ISR status.
* @lock: spinlock for IRQ synchronization. * @lock: spinlock for IRQ synchronization.
* @isr_mutex: mutex for IRQ thread.
*/ */
struct altr_i2c_dev { struct altr_i2c_dev {
void __iomem *base; void __iomem *base;
...@@ -86,6 +87,7 @@ struct altr_i2c_dev { ...@@ -86,6 +87,7 @@ struct altr_i2c_dev {
u32 isr_mask; u32 isr_mask;
u32 isr_status; u32 isr_status;
spinlock_t lock; /* IRQ synchronization */ spinlock_t lock; /* IRQ synchronization */
struct mutex isr_mutex;
}; };
static void static void
...@@ -245,10 +247,11 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev) ...@@ -245,10 +247,11 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
struct altr_i2c_dev *idev = _dev; struct altr_i2c_dev *idev = _dev;
u32 status = idev->isr_status; u32 status = idev->isr_status;
mutex_lock(&idev->isr_mutex);
if (!idev->msg) { if (!idev->msg) {
dev_warn(idev->dev, "unexpected interrupt\n"); dev_warn(idev->dev, "unexpected interrupt\n");
altr_i2c_int_clear(idev, ALTR_I2C_ALL_IRQ); altr_i2c_int_clear(idev, ALTR_I2C_ALL_IRQ);
return IRQ_HANDLED; goto out;
} }
read = (idev->msg->flags & I2C_M_RD) != 0; read = (idev->msg->flags & I2C_M_RD) != 0;
...@@ -301,6 +304,8 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev) ...@@ -301,6 +304,8 @@ static irqreturn_t altr_i2c_isr(int irq, void *_dev)
complete(&idev->msg_complete); complete(&idev->msg_complete);
dev_dbg(idev->dev, "Message Complete\n"); dev_dbg(idev->dev, "Message Complete\n");
} }
out:
mutex_unlock(&idev->isr_mutex);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -312,6 +317,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg) ...@@ -312,6 +317,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
u32 value; u32 value;
u8 addr = i2c_8bit_addr_from_msg(msg); u8 addr = i2c_8bit_addr_from_msg(msg);
mutex_lock(&idev->isr_mutex);
idev->msg = msg; idev->msg = msg;
idev->msg_len = msg->len; idev->msg_len = msg->len;
idev->buf = msg->buf; idev->buf = msg->buf;
...@@ -336,6 +342,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg) ...@@ -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_int_enable(idev, imask, true);
altr_i2c_fill_tx_fifo(idev); altr_i2c_fill_tx_fifo(idev);
} }
mutex_unlock(&idev->isr_mutex);
time_left = wait_for_completion_timeout(&idev->msg_complete, time_left = wait_for_completion_timeout(&idev->msg_complete,
ALTR_I2C_XFER_TIMEOUT); ALTR_I2C_XFER_TIMEOUT);
...@@ -409,6 +416,7 @@ static int altr_i2c_probe(struct platform_device *pdev) ...@@ -409,6 +416,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
idev->dev = &pdev->dev; idev->dev = &pdev->dev;
init_completion(&idev->msg_complete); init_completion(&idev->msg_complete);
spin_lock_init(&idev->lock); spin_lock_init(&idev->lock);
mutex_init(&idev->isr_mutex);
ret = device_property_read_u32(idev->dev, "fifo-size", ret = device_property_read_u32(idev->dev, "fifo-size",
&idev->fifo_size); &idev->fifo_size);
......
...@@ -845,6 +845,18 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev, ...@@ -845,6 +845,18 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
PINCTRL_STATE_DEFAULT); PINCTRL_STATE_DEFAULT);
dev->pinctrl_pins_gpio = pinctrl_lookup_state(dev->pinctrl, dev->pinctrl_pins_gpio = pinctrl_lookup_state(dev->pinctrl,
"gpio"); "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); rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER) if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
...@@ -855,9 +867,7 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev, ...@@ -855,9 +867,7 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
return -EPROBE_DEFER; return -EPROBE_DEFER;
if (IS_ERR(rinfo->sda_gpiod) || if (IS_ERR(rinfo->sda_gpiod) ||
IS_ERR(rinfo->scl_gpiod) || IS_ERR(rinfo->scl_gpiod)) {
IS_ERR(dev->pinctrl_pins_default) ||
IS_ERR(dev->pinctrl_pins_gpio)) {
dev_info(&pdev->dev, "recovery information incomplete\n"); dev_info(&pdev->dev, "recovery information incomplete\n");
if (!IS_ERR(rinfo->sda_gpiod)) { if (!IS_ERR(rinfo->sda_gpiod)) {
gpiod_put(rinfo->sda_gpiod); gpiod_put(rinfo->sda_gpiod);
...@@ -867,9 +877,13 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev, ...@@ -867,9 +877,13 @@ static int at91_init_twi_recovery_info(struct platform_device *pdev,
gpiod_put(rinfo->scl_gpiod); gpiod_put(rinfo->scl_gpiod);
rinfo->scl_gpiod = NULL; rinfo->scl_gpiod = NULL;
} }
pinctrl_select_state(dev->pinctrl, dev->pinctrl_pins_default);
return -EINVAL; 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"); dev_info(&pdev->dev, "using scl, sda for recovery\n");
rinfo->prepare_recovery = at91_prepare_twi_recovery; rinfo->prepare_recovery = at91_prepare_twi_recovery;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Mux support by Rodolfo Giometti <giometti@enneenne.com> and * Mux support by Rodolfo Giometti <giometti@enneenne.com> and
* Michael Lawnick <michael.lawnick.ext@nsn.com> * Michael Lawnick <michael.lawnick.ext@nsn.com>
* *
* 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 #define pr_fmt(fmt) "i2c-core: " fmt
...@@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev) ...@@ -338,8 +338,10 @@ static int i2c_device_probe(struct device *dev)
} else if (ACPI_COMPANION(dev)) { } else if (ACPI_COMPANION(dev)) {
irq = i2c_acpi_get_irq(client); irq = i2c_acpi_get_irq(client);
} }
if (irq == -EPROBE_DEFER) if (irq == -EPROBE_DEFER) {
return irq; status = irq;
goto put_sync_adapter;
}
if (irq < 0) if (irq < 0)
irq = 0; irq = 0;
...@@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev) ...@@ -353,15 +355,19 @@ static int i2c_device_probe(struct device *dev)
*/ */
if (!driver->id_table && if (!driver->id_table &&
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) && !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
!i2c_of_match_device(dev->driver->of_match_table, client)) !i2c_of_match_device(dev->driver->of_match_table, client)) {
return -ENODEV; status = -ENODEV;
goto put_sync_adapter;
}
if (client->flags & I2C_CLIENT_WAKE) { if (client->flags & I2C_CLIENT_WAKE) {
int wakeirq; int wakeirq;
wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
if (wakeirq == -EPROBE_DEFER) if (wakeirq == -EPROBE_DEFER) {
return wakeirq; status = wakeirq;
goto put_sync_adapter;
}
device_init_wakeup(&client->dev, true); device_init_wakeup(&client->dev, true);
...@@ -408,6 +414,10 @@ static int i2c_device_probe(struct device *dev) ...@@ -408,6 +414,10 @@ static int i2c_device_probe(struct device *dev)
err_clear_wakeup_irq: err_clear_wakeup_irq:
dev_pm_clear_wake_irq(&client->dev); dev_pm_clear_wake_irq(&client->dev);
device_init_wakeup(&client->dev, false); 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; return status;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (C) 2008 Jochen Friedrich <jochen@scram.de> * Copyright (C) 2008 Jochen Friedrich <jochen@scram.de>
* based on a previous patch from Jon Smirl <jonsmirl@gmail.com> * based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
* *
* 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> #include <dt-bindings/i2c/i2c.h>
......
...@@ -272,6 +272,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) ...@@ -272,6 +272,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
err_rollback_available: err_rollback_available:
device_remove_file(&pdev->dev, &dev_attr_available_masters); device_remove_file(&pdev->dev, &dev_attr_available_masters);
err_rollback: err_rollback:
i2c_demux_deactivate_master(priv);
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
of_node_put(priv->chan[j].parent_np); of_node_put(priv->chan[j].parent_np);
of_changeset_destroy(&priv->chan[j].chgset); of_changeset_destroy(&priv->chan[j].chgset);
......
...@@ -29,7 +29,7 @@ struct i2c_mux_core { ...@@ -29,7 +29,7 @@ struct i2c_mux_core {
int num_adapters; int num_adapters;
int max_adapters; int max_adapters;
struct i2c_adapter *adapter[0]; struct i2c_adapter *adapter[];
}; };
struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent, struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* i2c.h - definitions for the Linux i2c bus interface * i2c.h - definitions for the Linux i2c bus interface
* Copyright (C) 1995-2000 Simon G. Vogl * 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 <kmalkki@cc.hut.fi> and * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
* Frodo Looijaard <frodol@dds.nl> * Frodo Looijaard <frodol@dds.nl>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment