From ee4fec5f44a2c0f59327748217319f78e49b90a7 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 7 Jul 2016 02:08:38 +0000 Subject: memory: atmel-ebi: use PTR_ERR_OR_ZERO() to simplify the code Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR. Generated by coccinelle. Signed-off-by: Wei Yongjun Signed-off-by: Alexandre Belloni --- drivers/memory/atmel-ebi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'drivers/memory') diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index f87ad6f5d2dc..b5ed3bd082b5 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c @@ -410,10 +410,7 @@ static int at91sam9_ebi_init(struct at91_ebi *ebi) field.reg = AT91SAM9_SMC_MODE(AT91SAM9_SMC_GENERIC); fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); - if (IS_ERR(fields->mode)) - return PTR_ERR(fields->mode); - - return 0; + return PTR_ERR_OR_ZERO(fields->mode); } static int sama5d3_ebi_init(struct at91_ebi *ebi) @@ -441,10 +438,7 @@ static int sama5d3_ebi_init(struct at91_ebi *ebi) field.reg = SAMA5_SMC_MODE(SAMA5_SMC_GENERIC); fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); - if (IS_ERR(fields->mode)) - return PTR_ERR(fields->mode); - - return 0; + return PTR_ERR_OR_ZERO(fields->mode); } static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np, -- cgit v1.2.3 From 3f41a3c46727283a353f9a3fd510a4fc3d1c26b5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 23 Jul 2016 18:54:02 +0200 Subject: memory: omap-gpmc: Delete an unnecessary check before the function call "gpiochip_free_own_desc" The gpiochip_free_own_desc() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Roger Quadros --- drivers/memory/omap-gpmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/memory') diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 869c83fb3c5d..e138875a3196 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -2143,9 +2143,7 @@ err_child_fail: ret = -ENODEV; err_cs: - if (waitpin_desc) - gpiochip_free_own_desc(waitpin_desc); - + gpiochip_free_own_desc(waitpin_desc); err: gpmc_cs_free(cs); -- cgit v1.2.3 From 525fe43f55ff6d110680bb3d750bed3dda01b989 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 8 Aug 2016 10:03:16 +0200 Subject: memory: omap-gpmc: use devm_gpiochip_add_data() This saves a few codelines in the driver. Cc: Roger Quadros Cc: Tony Lindgren Signed-off-by: Linus Walleij Signed-off-by: Roger Quadros --- drivers/memory/omap-gpmc.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers/memory') diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index e138875a3196..e5f9c1783226 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -2264,7 +2264,7 @@ static int gpmc_gpio_init(struct gpmc_device *gpmc) gpmc->gpio_chip.get = gpmc_gpio_get; gpmc->gpio_chip.base = -1; - ret = gpiochip_add(&gpmc->gpio_chip); + ret = devm_gpiochip_add_data(gpmc->dev, &gpmc->gpio_chip, NULL); if (ret < 0) { dev_err(gpmc->dev, "could not register gpio chip: %d\n", ret); return ret; @@ -2273,11 +2273,6 @@ static int gpmc_gpio_init(struct gpmc_device *gpmc) return 0; } -static void gpmc_gpio_exit(struct gpmc_device *gpmc) -{ - gpiochip_remove(&gpmc->gpio_chip); -} - static int gpmc_probe(struct platform_device *pdev) { int rc; @@ -2364,7 +2359,7 @@ static int gpmc_probe(struct platform_device *pdev) rc = gpmc_setup_irq(gpmc); if (rc) { dev_err(gpmc->dev, "gpmc_setup_irq failed\n"); - goto setup_irq_failed; + goto gpio_init_failed; } rc = gpmc_probe_dt_children(pdev); @@ -2377,8 +2372,6 @@ static int gpmc_probe(struct platform_device *pdev) dt_children_failed: gpmc_free_irq(gpmc); -setup_irq_failed: - gpmc_gpio_exit(gpmc); gpio_init_failed: gpmc_mem_exit(); pm_runtime_put_sync(&pdev->dev); @@ -2392,7 +2385,6 @@ static int gpmc_remove(struct platform_device *pdev) struct gpmc_device *gpmc = platform_get_drvdata(pdev); gpmc_free_irq(gpmc); - gpmc_gpio_exit(gpmc); gpmc_mem_exit(); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); -- cgit v1.2.3 From 3950fffdf0c088dd4d9e85c9a5a6be4c6e8b5a07 Mon Sep 17 00:00:00 2001 From: Baoyou Xie Date: Sun, 28 Aug 2016 13:28:15 +0800 Subject: memory: omap-gpmc: make gpmc_clk_ticks_to_ns() static We get 1 warning when build kernel with W=1: drivers/memory/omap-gpmc.c:354:14: warning: no previous prototype for 'gpmc_clk_ticks_to_ns' [-Wmissing-prototypes] In fact, this function is only used in the file in which it is declared and don't need a declaration, but can be made static. so this patch marks it 'static'. Signed-off-by: Baoyou Xie Signed-off-by: Roger Quadros --- drivers/memory/omap-gpmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/memory') diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index e5f9c1783226..c2c32edfed95 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -350,8 +350,8 @@ static unsigned int gpmc_ps_to_ticks(unsigned int time_ps) return (time_ps + tick_ps - 1) / tick_ps; } -unsigned int gpmc_clk_ticks_to_ns(unsigned ticks, int cs, - enum gpmc_clk_domain cd) +static unsigned int gpmc_clk_ticks_to_ns(unsigned int ticks, int cs, + enum gpmc_clk_domain cd) { return ticks * gpmc_get_clk_period(cs, cd) / 1000; } -- cgit v1.2.3 From 7922118f8f3e76eb6534e9221a6c9f496c0ae699 Mon Sep 17 00:00:00 2001 From: LABBE Corentin Date: Tue, 16 Aug 2016 15:53:18 +0200 Subject: memory: atmel-sdramc: fix a possible NULL dereference of_match_device could return NULL, and so cause a NULL pointer dereference later. For fixing this problem, we use of_device_get_match_data(), this will simplify the code a little by using a standard function for getting the match data. Signed-off-by: LABBE Corentin Signed-off-by: Alexandre Belloni --- drivers/memory/atmel-sdramc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/memory') diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c index 53a341f3b305..12080b05e3e6 100644 --- a/drivers/memory/atmel-sdramc.c +++ b/drivers/memory/atmel-sdramc.c @@ -53,12 +53,10 @@ static const struct of_device_id atmel_ramc_of_match[] = { static int atmel_ramc_probe(struct platform_device *pdev) { - const struct of_device_id *match; const struct at91_ramc_caps *caps; struct clk *clk; - match = of_match_device(atmel_ramc_of_match, &pdev->dev); - caps = match->data; + caps = of_device_get_match_data(&pdev->dev); if (caps->has_ddrck) { clk = devm_clk_get(&pdev->dev, "ddrck"); -- cgit v1.2.3