From: Markus Elfring <[email protected]>
Date: Fri, 16 Feb 2018 16:51:23 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation
Delete an unnecessary variable initialisation
Move two variable assignments
drivers/ata/pata_arasan_cf.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Fri, 16 Feb 2018 16:01:12 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/ata/pata_arasan_cf.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index b4d54771c9fe..be5fbcedecbf 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -809,10 +809,8 @@ static int arasan_cf_probe(struct platform_device *pdev)
}
acdev = devm_kzalloc(&pdev->dev, sizeof(*acdev), GFP_KERNEL);
- if (!acdev) {
- dev_warn(&pdev->dev, "kzalloc fail\n");
+ if (!acdev)
return -ENOMEM;
- }
if (pdata)
quirk = pdata->quirk;
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Fri, 16 Feb 2018 16:28:23 +0100
The local variable "ret" will eventually be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/ata/pata_arasan_cf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index be5fbcedecbf..ebecab8c3f36 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -796,7 +796,7 @@ static int arasan_cf_probe(struct platform_device *pdev)
struct resource *res;
u32 quirk;
irq_handler_t irq_handler = NULL;
- int ret = 0;
+ int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Fri, 16 Feb 2018 16:42:26 +0100
Move assignments for the local variables "irq_handler" and "pdata"
so that their setting will only be performed after a call
of the function "devm_kzalloc" succeeded by this function.
Thus adjust a corresponding if statement.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/ata/pata_arasan_cf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index ebecab8c3f36..27f241b1b1b1 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -790,12 +790,12 @@ static struct ata_port_operations arasan_cf_ops = {
static int arasan_cf_probe(struct platform_device *pdev)
{
struct arasan_cf_dev *acdev;
- struct arasan_cf_pdata *pdata = dev_get_platdata(&pdev->dev);
+ struct arasan_cf_pdata *pdata;
struct ata_host *host;
struct ata_port *ap;
struct resource *res;
u32 quirk;
- irq_handler_t irq_handler = NULL;
+ irq_handler_t irq_handler;
int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -812,6 +812,7 @@ static int arasan_cf_probe(struct platform_device *pdev)
if (!acdev)
return -ENOMEM;
+ pdata = dev_get_platdata(&pdev->dev);
if (pdata)
quirk = pdata->quirk;
else
@@ -819,10 +820,12 @@ static int arasan_cf_probe(struct platform_device *pdev)
/* if irq is 0, support only PIO */
acdev->irq = platform_get_irq(pdev, 0);
- if (acdev->irq)
+ if (acdev->irq) {
irq_handler = arasan_cf_interrupt;
- else
+ } else {
quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
+ irq_handler = NULL;
+ }
acdev->pbase = res->start;
acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start,
--
2.16.1
On Fri, Feb 16, 2018 at 04:59:01PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Fri, 16 Feb 2018 16:28:23 +0100
>
> The local variable "ret" will eventually be set to an appropriate value
> a bit later. Thus omit the explicit initialisation at the beginning.
>
> Signed-off-by: Markus Elfring <[email protected]>
Applied 1-2 to libata/for-4.17.
Thanks.
--
tejun
On Fri, Feb 16, 2018 at 05:00:11PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Fri, 16 Feb 2018 16:42:26 +0100
>
> Move assignments for the local variables "irq_handler" and "pdata"
> so that their setting will only be performed after a call
> of the function "devm_kzalloc" succeeded by this function.
> Thus adjust a corresponding if statement.
I'm not gonna apply this. If there's something preventing the
compiler from optimizing it, the right thing to do is fixing that.
Thanks.
--
tejun
On 16-02-18, 16:57, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Fri, 16 Feb 2018 16:01:12 +0100
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> drivers/ata/pata_arasan_cf.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
> index b4d54771c9fe..be5fbcedecbf 100644
> --- a/drivers/ata/pata_arasan_cf.c
> +++ b/drivers/ata/pata_arasan_cf.c
> @@ -809,10 +809,8 @@ static int arasan_cf_probe(struct platform_device *pdev)
> }
>
> acdev = devm_kzalloc(&pdev->dev, sizeof(*acdev), GFP_KERNEL);
> - if (!acdev) {
> - dev_warn(&pdev->dev, "kzalloc fail\n");
> + if (!acdev)
> return -ENOMEM;
> - }
>
> if (pdata)
> quirk = pdata->quirk;
Acked-by: Viresh Kumar <[email protected]>
--
viresh