From c0fc208e487a985c4d083c498fecf791e6e965b7 Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Fri, 24 Aug 2012 03:34:42 +0530 Subject: tty: max3100: use module_spi_driver the driver's module init and exit functions can be replaced with module_spi_driver as they do only spi_register_driver and spi_unregister_driver in module's init and exit paths. Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/max3100.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers/tty/serial/max3100.c') diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index b4902b99cfd2..46043c2521ce 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -910,17 +910,7 @@ static struct spi_driver max3100_driver = { .resume = max3100_resume, }; -static int __init max3100_init(void) -{ - return spi_register_driver(&max3100_driver); -} -module_init(max3100_init); - -static void __exit max3100_exit(void) -{ - spi_unregister_driver(&max3100_driver); -} -module_exit(max3100_exit); +module_spi_driver(max3100_driver); MODULE_DESCRIPTION("MAX3100 driver"); MODULE_AUTHOR("Christian Pellegrin "); -- cgit v1.2.1 From 41fda9c4d9437846f4ca667e134c6d840f67b9c2 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 17 Sep 2012 12:00:44 +0100 Subject: tty: serial: max3100: Fix error case We don't want to free a random address if the entry is wrong, cover this and WARN if it ever happens. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/max3100.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/tty/serial/max3100.c') diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 46043c2521ce..0f24486be532 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -827,14 +827,16 @@ static int __devexit max3100_remove(struct spi_device *spi) /* find out the index for the chip we are removing */ for (i = 0; i < MAX_MAX3100; i++) - if (max3100s[i] == s) + if (max3100s[i] == s) { + dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i); + uart_remove_one_port(&max3100_uart_driver, &max3100s[i]->port); + kfree(max3100s[i]); + max3100s[i] = NULL; break; + } - dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i); - uart_remove_one_port(&max3100_uart_driver, &max3100s[i]->port); - kfree(max3100s[i]); - max3100s[i] = NULL; - + WARN_ON(i == MAX_MAX3100); + /* check if this is the last chip we have */ for (i = 0; i < MAX_MAX3100; i++) if (max3100s[i]) { -- cgit v1.2.1