aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/max7301.c
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2008-10-16 01:03:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:40 -0400
commitc557fa3e4c156b8713c177d9dde08920130bf551 (patch)
treea79b6e702b0d76ba79c2204af527a0c193a68253 /drivers/gpio/max7301.c
parent4fd5463c43d75ec919e27abdcfde1b199c19541e (diff)
gpio: max7301: fix the race between chip addition and pins reconfiguration
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> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio/max7301.c')
-rw-r--r--drivers/gpio/max7301.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 1b5ad97b9e5..8b24d784db9 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -255,10 +255,6 @@ static int __devinit max7301_probe(struct spi_device *spi)
255 ts->chip.dev = &spi->dev; 255 ts->chip.dev = &spi->dev;
256 ts->chip.owner = THIS_MODULE; 256 ts->chip.owner = THIS_MODULE;
257 257
258 ret = gpiochip_add(&ts->chip);
259 if (ret)
260 goto exit_destroy;
261
262 /* 258 /*
263 * tristate all pins in hardware and cache the 259 * tristate all pins in hardware and cache the
264 * register values for later use. 260 * register values for later use.
@@ -269,17 +265,19 @@ static int __devinit max7301_probe(struct spi_device *spi)
269 max7301_write(spi, 0x08 + i, 0xAA); 265 max7301_write(spi, 0x08 + i, 0xAA);
270 ts->port_config[i] = 0xAA; 266 ts->port_config[i] = 0xAA;
271 for (j = 0; j < 4; j++) { 267 for (j = 0; j < 4; j++) {
272 int idx = ts->chip.base + (i - 1) * 4 + j; 268 int offset = (i - 1) * 4 + j;
273 ret = gpio_direction_input(idx); 269 ret = max7301_direction_input(&ts->chip, offset);
274 if (ret) 270 if (ret)
275 goto exit_remove; 271 goto exit_destroy;
276 gpio_free(idx);
277 } 272 }
278 } 273 }
274
275 ret = gpiochip_add(&ts->chip);
276 if (ret)
277 goto exit_destroy;
278
279 return ret; 279 return ret;
280 280
281exit_remove:
282 gpiochip_remove(&ts->chip);
283exit_destroy: 281exit_destroy:
284 dev_set_drvdata(&spi->dev, NULL); 282 dev_set_drvdata(&spi->dev, NULL);
285 mutex_destroy(&ts->lock); 283 mutex_destroy(&ts->lock);