Skip to content

Commit

Permalink
gpio: pcf857x: use client->irq for gpio_to_irq()
Browse files Browse the repository at this point in the history
6e20a0a
(gpio: pcf857x: enable gpio_to_irq() support)
added gpio_to_irq() support on pcf857x driver,
but it used pdata->irq.
This patch modifies driver to use client->irq instead of it.
It modifies kzm9g board platform settings,
and device probe information too.
This patch is tested on kzm9g board

Reported-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Kuninori Morimoto authored and Linus Walleij committed Dec 7, 2012
1 parent 86605cf commit 805f864
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-shmobile/board-kzm9g.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ static struct platform_device fsi_ak4648_device = {
/* I2C */
static struct pcf857x_platform_data pcf8575_pdata = {
.gpio_base = GPIO_PCF8575_BASE,
.irq = intcs_evt2irq(0x3260), /* IRQ19 */
};

static struct i2c_board_info i2c0_devices[] = {
Expand All @@ -570,6 +569,7 @@ static struct i2c_board_info i2c1_devices[] = {
static struct i2c_board_info i2c3_devices[] = {
{
I2C_BOARD_INFO("pcf8575", 0x20),
.irq = intcs_evt2irq(0x3260), /* IRQ19 */
.platform_data = &pcf8575_pdata,
},
};
Expand Down
29 changes: 11 additions & 18 deletions drivers/gpio/gpio-pcf857x.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,27 @@ static void pcf857x_irq_domain_cleanup(struct pcf857x *gpio)

static int pcf857x_irq_domain_init(struct pcf857x *gpio,
struct pcf857x_platform_data *pdata,
struct device *dev)
struct i2c_client *client)
{
int status;

gpio->irq_domain = irq_domain_add_linear(dev->of_node,
gpio->irq_domain = irq_domain_add_linear(client->dev.of_node,
gpio->chip.ngpio,
&pcf857x_irq_domain_ops,
NULL);
if (!gpio->irq_domain)
goto fail;

/* enable real irq */
status = request_irq(pdata->irq, pcf857x_irq_demux, 0,
dev_name(dev), gpio);
status = request_irq(client->irq, pcf857x_irq_demux, 0,
dev_name(&client->dev), gpio);
if (status)
goto fail;

/* enable gpio_to_irq() */
INIT_WORK(&gpio->work, pcf857x_irq_demux_work);
gpio->chip.to_irq = pcf857x_to_irq;
gpio->irq = pdata->irq;
gpio->irq = client->irq;

return 0;

Expand Down Expand Up @@ -285,8 +285,8 @@ static int pcf857x_probe(struct i2c_client *client,
gpio->chip.ngpio = id->driver_data;

/* enable gpio_to_irq() if platform has settings */
if (pdata && pdata->irq) {
status = pcf857x_irq_domain_init(gpio, pdata, &client->dev);
if (pdata && client->irq) {
status = pcf857x_irq_domain_init(gpio, pdata, client);
if (status < 0) {
dev_err(&client->dev, "irq_domain init failed\n");
goto fail;
Expand Down Expand Up @@ -368,15 +368,6 @@ static int pcf857x_probe(struct i2c_client *client,
if (status < 0)
goto fail;

/* NOTE: these chips can issue "some pin-changed" IRQs, which we
* don't yet even try to use. Among other issues, the relevant
* genirq state isn't available to modular drivers; and most irq
* methods can't be called from sleeping contexts.
*/

dev_info(&client->dev, "%s\n",
client->irq ? " (irq ignored)" : "");

/* Let platform code set up the GPIOs and their users.
* Now is the first time anyone could use them.
*/
Expand All @@ -388,13 +379,15 @@ static int pcf857x_probe(struct i2c_client *client,
dev_warn(&client->dev, "setup --> %d\n", status);
}

dev_info(&client->dev, "probed\n");

return 0;

fail:
dev_dbg(&client->dev, "probe error %d for '%s'\n",
status, client->name);

if (pdata && pdata->irq)
if (pdata && client->irq)
pcf857x_irq_domain_cleanup(gpio);

kfree(gpio);
Expand All @@ -418,7 +411,7 @@ static int pcf857x_remove(struct i2c_client *client)
}
}

if (pdata && pdata->irq)
if (pdata && client->irq)
pcf857x_irq_domain_cleanup(gpio);

status = gpiochip_remove(&gpio->chip);
Expand Down
3 changes: 0 additions & 3 deletions include/linux/i2c/pcf857x.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @setup: optional callback issued once the GPIOs are valid
* @teardown: optional callback issued before the GPIOs are invalidated
* @context: optional parameter passed to setup() and teardown()
* @irq: optional interrupt number
*
* In addition to the I2C_BOARD_INFO() state appropriate to each chip,
* the i2c_board_info used with the pcf875x driver must provide its
Expand Down Expand Up @@ -40,8 +39,6 @@ struct pcf857x_platform_data {
int gpio, unsigned ngpio,
void *context);
void *context;

int irq;
};

#endif /* __LINUX_PCF857X_H */

0 comments on commit 805f864

Please sign in to comment.