From 7844b989b39cb1fdf21b74cd9b69fd0953b9f28d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 16:42:58 +0530 Subject: mfd: omap-usb-host: Staticize usbhs_driver_name usbhs_driver_name is used only in this file. Make it static. Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/omap-usb-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index d2b8e7189907..29ee54d68512 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -114,7 +114,7 @@ struct usbhs_hcd_omap { }; /*-------------------------------------------------------------------------*/ -const char usbhs_driver_name[] = USBHS_DRIVER_NAME; +static const char usbhs_driver_name[] = USBHS_DRIVER_NAME; static u64 usbhs_dmamask = DMA_BIT_MASK(32); /*-------------------------------------------------------------------------*/ -- cgit v1.2.3 From ffb011602d263ca57c05125c3b9ef476673e88f7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 17:05:19 +0530 Subject: mfd: db8500-prcmu: Use ANSI function declaration Silences the following warning: drivers/mfd/db8500-prcmu.c:2322:25: warning: non-ANSI function declaration of function 'prcmu_ac_sleep_req' Acked-by: Linus Walleij Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/db8500-prcmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 3c157faee645..961036e51212 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -2319,7 +2319,7 @@ unlock_and_return: /** * prcmu_ac_sleep_req - called when ARM no longer needs to talk to modem */ -void prcmu_ac_sleep_req() +void prcmu_ac_sleep_req(void) { u32 val; -- cgit v1.2.3 From 6746f2321c93f570386345c47c3aa262d17787c2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 17:05:20 +0530 Subject: mfd: db8500-prcmu: Staticize clk_mgt clk_mgt is used only in this file. Make it static. Acked-by: Linus Walleij Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/db8500-prcmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 961036e51212..f7460383d4be 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -465,7 +465,7 @@ static DEFINE_SPINLOCK(clk_mgt_lock); #define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \ { (PRCM_##_name##_MGT), 0 , _branch, _clk38div} -struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { +static struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { CLK_MGT_ENTRY(SGACLK, PLL_DIV, false), CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true), CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true), -- cgit v1.2.3 From 8455eaee41e78e9996c25c888cda9c6b597228b7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 17:37:42 +0530 Subject: mfd: ab8500-debugfs: Staticize local variables Local variables referenced only in this file are made static. Acked-by: Linus Walleij Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/ab8500-debugfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 7d1f1b08fc4b..a0afa64b471b 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -159,7 +159,7 @@ static struct hwreg_cfg hwreg_cfg = { static struct ab8500_prcmu_ranges *debug_ranges; -struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { +static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { [0x0] = { .num_ranges = 0, .range = NULL, @@ -488,7 +488,7 @@ struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { }, }; -struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { +static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { [0x0] = { .num_ranges = 0, .range = NULL, @@ -847,7 +847,7 @@ struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { }, }; -struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { +static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { [AB8500_M_FSM_RANK] = { .num_ranges = 1, .range = (struct ab8500_reg_range[]) { @@ -1377,7 +1377,7 @@ void ab8500_dump_all_banks(struct device *dev) /* Space for 500 registers. */ #define DUMP_MAX_REGS 700 -struct ab8500_register_dump +static struct ab8500_register_dump { u8 bank; u8 reg; -- cgit v1.2.3 From 4eaf415762672e4becc30e637028de9d3aae07bf Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 15:41:03 +0530 Subject: mfd: timberdale: Staticize local variables Local variables referenced only in this file are made static. Acked-by: Linus Walleij Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/timberdale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 0c1fcbc23d04..4c9c149f2be8 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -115,11 +115,11 @@ static const struct resource timberdale_ocores_resources[] = { }, }; -const struct max7301_platform_data timberdale_max7301_platform_data = { +static const struct max7301_platform_data timberdale_max7301_platform_data = { .base = 200 }; -const struct mc33880_platform_data timberdale_mc33880_platform_data = { +static const struct mc33880_platform_data timberdale_mc33880_platform_data = { .base = 100 }; -- cgit v1.2.3 From 624362676c1860874737dbd4db5fcee05d585722 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 15:41:04 +0530 Subject: mfd: timberdale: Remove redundant break break after goto is unreachable. Delete it. Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/timberdale.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 4c9c149f2be8..57dd89ddb683 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -781,7 +781,6 @@ static int timb_probe(struct pci_dev *dev, priv->fw.major, priv->fw.minor, ip_setup); err = -ENODEV; goto err_mfd; - break; } if (err) { -- cgit v1.2.3 From 0afb00e38bb220d198fd7778902d82e944e821a4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 23 Aug 2013 15:41:05 +0530 Subject: mfd: timberdale: Use module_pci_driver module_pci_driver removes some boilerplate and makes the code simple. Signed-off-by: Sachin Kamat Signed-off-by: Lee Jones --- drivers/mfd/timberdale.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 57dd89ddb683..a6755ec7bd6a 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c @@ -868,34 +868,7 @@ static struct pci_driver timberdale_pci_driver = { .remove = timb_remove, }; -static int __init timberdale_init(void) -{ - int err; - - err = pci_register_driver(&timberdale_pci_driver); - if (err < 0) { - printk(KERN_ERR - "Failed to register PCI driver for %s device.\n", - timberdale_pci_driver.name); - return -ENODEV; - } - - printk(KERN_INFO "Driver for %s has been successfully registered.\n", - timberdale_pci_driver.name); - - return 0; -} - -static void __exit timberdale_exit(void) -{ - pci_unregister_driver(&timberdale_pci_driver); - - printk(KERN_INFO "Driver for %s has been successfully unregistered.\n", - timberdale_pci_driver.name); -} - -module_init(timberdale_init); -module_exit(timberdale_exit); +module_pci_driver(timberdale_pci_driver); MODULE_AUTHOR("Mocean Laboratories "); MODULE_VERSION(DRV_VERSION); -- cgit v1.2.3 From f840e23bcf16068eeffe8991ac38b58b82160e43 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 19 Jul 2013 08:44:50 +0100 Subject: mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for sysfs The AB8500 debugfs driver allocates memory for a new sysfs entry, but fails to apply the proper post-allocation checks. If the device were to run out of memory, the allocation would return NULL. Without the correct checks the driver will continue to populate NULL->[show|store|...], which would obviously cause a pointer dereference Oops. Signed-off-by: Lee Jones --- drivers/mfd/ab8500-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index a0afa64b471b..fe8189c4385a 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -2800,6 +2800,9 @@ static ssize_t ab8500_subscribe_write(struct file *file, */ dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), GFP_KERNEL); + if (!dev_attr[irq_index]) + return -ENOMEM; + event_name[irq_index] = kmalloc(count, GFP_KERNEL); sprintf(event_name[irq_index], "%lu", user_val); dev_attr[irq_index]->show = show_irq; -- cgit v1.2.3 From d551c4c43ccac3ef272e10ac23a64eaac16c23fd Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 19 Jul 2013 08:53:24 +0100 Subject: mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for event name The AB8500 debugfs driver allocates memory to contain the name of a new sysfs entry, but fails to apply the proper post-allocation checks. If the device were to run out of memory, the allocation would return NULL. Without the correct checks the driver will continue to populate address NULL with the specified device name which would obviously cause a pointer dereference Oops. Signed-off-by: Lee Jones --- drivers/mfd/ab8500-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index fe8189c4385a..e33e385af0a2 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -2804,6 +2804,9 @@ static ssize_t ab8500_subscribe_write(struct file *file, return -ENOMEM; event_name[irq_index] = kmalloc(count, GFP_KERNEL); + if (!event_name[irq_index]) + return -ENOMEM; + sprintf(event_name[irq_index], "%lu", user_val); dev_attr[irq_index]->show = show_irq; dev_attr[irq_index]->store = NULL; -- cgit v1.2.3 From 02a0bf6e351de6bcda4ddeeb2af34197a4e6d591 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 19 Jul 2013 14:19:58 +0100 Subject: mfd: ucb1x00-core: Rewrite ucb1x00_add_dev() Error handling is on-its-head in this function. After invoking a function we should examine the return code and return the error value if there was one. Instead, this function checks for success and goes onto provide functionality if success was received. Not so bad in a simple function like this, but in a more complex one this could end up drowning in curly brackets. Signed-off-by: Lee Jones --- drivers/mfd/ucb1x00-core.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index b7cf98f75e7c..d5966e6b5a7d 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -393,22 +393,24 @@ static struct irq_chip ucb1x00_irqchip = { static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv) { struct ucb1x00_dev *dev; - int ret = -ENOMEM; + int ret; dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL); - if (dev) { - dev->ucb = ucb; - dev->drv = drv; - - ret = drv->add(dev); - - if (ret == 0) { - list_add_tail(&dev->dev_node, &ucb->devs); - list_add_tail(&dev->drv_node, &drv->devs); - } else { - kfree(dev); - } + if (!dev) + return -ENOMEM; + + dev->ucb = ucb; + dev->drv = drv; + + ret = drv->add(dev); + if (ret) { + kfree(dev); + return ret; } + + list_add_tail(&dev->dev_node, &ucb->devs); + list_add_tail(&dev->drv_node, &drv->devs); + return ret; } -- cgit v1.2.3