* [PATCH] max7301: fix the race between chip addition and pins reconfiguration
@ 2008-08-17 19:24 Dmitry Baryshkov
0 siblings, 0 replies; only message in thread
From: Dmitry Baryshkov @ 2008-08-17 19:24 UTC (permalink / raw)
To: linux-kernel
Cc: dbrownell, Dmitry Baryshkov, Juergen Beisert,
Guennadi Liakhovetski, Russell King
There is a small race and code ugliness in max7301: pins are
reconfigured after the chip is registered. Swap these calls
so that the device is registered in correct state.
Also this fixes the comile-time warning about unchecked gpiochip_remove.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: Juergen Beisert <j.beisert@pengutronix.de>
Cc: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
---
drivers/gpio/max7301.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 39c795a..c34f408 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -255,10 +255,6 @@ static int __devinit max7301_probe(struct spi_device *spi)
ts->chip.dev = &spi->dev;
ts->chip.owner = THIS_MODULE;
- ret = gpiochip_add(&ts->chip);
- if (ret)
- goto exit_destroy;
-
/*
* tristate all pins in hardware and cache the
* register values for later use.
@@ -269,17 +265,19 @@ static int __devinit max7301_probe(struct spi_device *spi)
max7301_write(spi, 0x08 + i, 0xAA);
ts->port_config[i] = 0xAA;
for (j = 0; j < 4; j++) {
- int idx = ts->chip.base + (i - 1) * 4 + j;
- ret = gpio_direction_input(idx);
+ int offset = (i - 1) * 4 + j;
+ ret = max7301_direction_input(&ts->chip, offset);
if (ret)
- goto exit_remove;
- gpio_free(idx);
+ goto exit_destroy;
}
}
+
+ ret = gpiochip_add(&ts->chip);
+ if (ret)
+ goto exit_destroy;
+
return ret;
-exit_remove:
- gpiochip_remove(&ts->chip);
exit_destroy:
dev_set_drvdata(&spi->dev, NULL);
mutex_destroy(&ts->lock);
--
1.5.6.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-17 19:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-17 19:24 [PATCH] max7301: fix the race between chip addition and pins reconfiguration Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox