2017-09-27 18:45:43

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] Ux500 clock: Adjustments for three function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 20:40:20 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation in three functions
Improve a size determination in three functions

drivers/clk/ux500/clk-prcc.c | 6 ++----
drivers/clk/ux500/clk-prcmu.c | 6 ++----
drivers/clk/ux500/clk-sysctrl.c | 6 ++----
3 files changed, 6 insertions(+), 12 deletions(-)

--
2.14.2


2017-09-27 18:47:18

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] clk/ux500: Delete an error message for a failed memory allocation in three functions

From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 20:23:58 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/clk/ux500/clk-prcc.c | 4 +---
drivers/clk/ux500/clk-prcmu.c | 4 +---
drivers/clk/ux500/clk-sysctrl.c | 4 +---
3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/ux500/clk-prcc.c b/drivers/clk/ux500/clk-prcc.c
index f50592775c9d..5ca07e6d1f64 100644
--- a/drivers/clk/ux500/clk-prcc.c
+++ b/drivers/clk/ux500/clk-prcc.c
@@ -108,10 +108,8 @@ static struct clk *clk_reg_prcc(const char *name,
}

clk = kzalloc(sizeof(struct clk_prcc), GFP_KERNEL);
- if (!clk) {
- pr_err("clk_prcc: %s could not allocate clk\n", __func__);
+ if (!clk)
return ERR_PTR(-ENOMEM);
- }

clk->base = ioremap(phy_base, SZ_4K);
if (!clk->base)
diff --git a/drivers/clk/ux500/clk-prcmu.c b/drivers/clk/ux500/clk-prcmu.c
index 6e3e16b2e5ca..c137934f23ab 100644
--- a/drivers/clk/ux500/clk-prcmu.c
+++ b/drivers/clk/ux500/clk-prcmu.c
@@ -259,10 +259,8 @@ static struct clk *clk_reg_prcmu(const char *name,
}

clk = kzalloc(sizeof(struct clk_prcmu), GFP_KERNEL);
- if (!clk) {
- pr_err("clk_prcmu: %s could not allocate clk\n", __func__);
+ if (!clk)
return ERR_PTR(-ENOMEM);
- }

clk->cg_sel = cg_sel;
clk->is_prepared = 1;
diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c
index 8a4e93ce1e42..e0a834c08a04 100644
--- a/drivers/clk/ux500/clk-sysctrl.c
+++ b/drivers/clk/ux500/clk-sysctrl.c
@@ -140,10 +140,8 @@ static struct clk *clk_reg_sysctrl(struct device *dev,
}

clk = devm_kzalloc(dev, sizeof(struct clk_sysctrl), GFP_KERNEL);
- if (!clk) {
- dev_err(dev, "clk_sysctrl: could not allocate clk\n");
+ if (!clk)
return ERR_PTR(-ENOMEM);
- }

/* set main clock registers */
clk->reg_sel[0] = reg_sel[0];
--
2.14.2

2017-09-27 18:48:28

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] clk/ux500: Improve a size determination in three functions

From: Markus Elfring <[email protected]>
Date: Wed, 27 Sep 2017 20:30:53 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/clk/ux500/clk-prcc.c | 2 +-
drivers/clk/ux500/clk-prcmu.c | 2 +-
drivers/clk/ux500/clk-sysctrl.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/ux500/clk-prcc.c b/drivers/clk/ux500/clk-prcc.c
index 5ca07e6d1f64..7cfb59c9136d 100644
--- a/drivers/clk/ux500/clk-prcc.c
+++ b/drivers/clk/ux500/clk-prcc.c
@@ -107,7 +107,7 @@ static struct clk *clk_reg_prcc(const char *name,
return ERR_PTR(-EINVAL);
}

- clk = kzalloc(sizeof(struct clk_prcc), GFP_KERNEL);
+ clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/clk/ux500/clk-prcmu.c b/drivers/clk/ux500/clk-prcmu.c
index c137934f23ab..9d1f2d4550ad 100644
--- a/drivers/clk/ux500/clk-prcmu.c
+++ b/drivers/clk/ux500/clk-prcmu.c
@@ -258,7 +258,7 @@ static struct clk *clk_reg_prcmu(const char *name,
return ERR_PTR(-EINVAL);
}

- clk = kzalloc(sizeof(struct clk_prcmu), GFP_KERNEL);
+ clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c
index e0a834c08a04..7c0403b733ae 100644
--- a/drivers/clk/ux500/clk-sysctrl.c
+++ b/drivers/clk/ux500/clk-sysctrl.c
@@ -139,7 +139,7 @@ static struct clk *clk_reg_sysctrl(struct device *dev,
return ERR_PTR(-EINVAL);
}

- clk = devm_kzalloc(dev, sizeof(struct clk_sysctrl), GFP_KERNEL);
+ clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL);
if (!clk)
return ERR_PTR(-ENOMEM);

--
2.14.2

2017-09-28 16:04:02

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH 1/2] clk/ux500: Delete an error message for a failed memory allocation in three functions

On 27 September 2017 at 20:46, SF Markus Elfring
<[email protected]> wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 27 Sep 2017 20:23:58 +0200
>
> Omit extra messages for a memory allocation failure in these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>

Acked-by: Ulf Hansson <[email protected]>

> ---
> drivers/clk/ux500/clk-prcc.c | 4 +---
> drivers/clk/ux500/clk-prcmu.c | 4 +---
> drivers/clk/ux500/clk-sysctrl.c | 4 +---
> 3 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/clk/ux500/clk-prcc.c b/drivers/clk/ux500/clk-prcc.c
> index f50592775c9d..5ca07e6d1f64 100644
> --- a/drivers/clk/ux500/clk-prcc.c
> +++ b/drivers/clk/ux500/clk-prcc.c
> @@ -108,10 +108,8 @@ static struct clk *clk_reg_prcc(const char *name,
> }
>
> clk = kzalloc(sizeof(struct clk_prcc), GFP_KERNEL);
> - if (!clk) {
> - pr_err("clk_prcc: %s could not allocate clk\n", __func__);
> + if (!clk)
> return ERR_PTR(-ENOMEM);
> - }
>
> clk->base = ioremap(phy_base, SZ_4K);
> if (!clk->base)
> diff --git a/drivers/clk/ux500/clk-prcmu.c b/drivers/clk/ux500/clk-prcmu.c
> index 6e3e16b2e5ca..c137934f23ab 100644
> --- a/drivers/clk/ux500/clk-prcmu.c
> +++ b/drivers/clk/ux500/clk-prcmu.c
> @@ -259,10 +259,8 @@ static struct clk *clk_reg_prcmu(const char *name,
> }
>
> clk = kzalloc(sizeof(struct clk_prcmu), GFP_KERNEL);
> - if (!clk) {
> - pr_err("clk_prcmu: %s could not allocate clk\n", __func__);
> + if (!clk)
> return ERR_PTR(-ENOMEM);
> - }
>
> clk->cg_sel = cg_sel;
> clk->is_prepared = 1;
> diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c
> index 8a4e93ce1e42..e0a834c08a04 100644
> --- a/drivers/clk/ux500/clk-sysctrl.c
> +++ b/drivers/clk/ux500/clk-sysctrl.c
> @@ -140,10 +140,8 @@ static struct clk *clk_reg_sysctrl(struct device *dev,
> }
>
> clk = devm_kzalloc(dev, sizeof(struct clk_sysctrl), GFP_KERNEL);
> - if (!clk) {
> - dev_err(dev, "clk_sysctrl: could not allocate clk\n");
> + if (!clk)
> return ERR_PTR(-ENOMEM);
> - }
>
> /* set main clock registers */
> clk->reg_sel[0] = reg_sel[0];
> --
> 2.14.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2017-09-28 16:04:23

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH 2/2] clk/ux500: Improve a size determination in three functions

On 27 September 2017 at 20:47, SF Markus Elfring
<[email protected]> wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 27 Sep 2017 20:30:53 +0200
>
> Replace the specification of data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>

Acked-by: Ulf Hansson <[email protected]>

> ---
> drivers/clk/ux500/clk-prcc.c | 2 +-
> drivers/clk/ux500/clk-prcmu.c | 2 +-
> drivers/clk/ux500/clk-sysctrl.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/ux500/clk-prcc.c b/drivers/clk/ux500/clk-prcc.c
> index 5ca07e6d1f64..7cfb59c9136d 100644
> --- a/drivers/clk/ux500/clk-prcc.c
> +++ b/drivers/clk/ux500/clk-prcc.c
> @@ -107,7 +107,7 @@ static struct clk *clk_reg_prcc(const char *name,
> return ERR_PTR(-EINVAL);
> }
>
> - clk = kzalloc(sizeof(struct clk_prcc), GFP_KERNEL);
> + clk = kzalloc(sizeof(*clk), GFP_KERNEL);
> if (!clk)
> return ERR_PTR(-ENOMEM);
>
> diff --git a/drivers/clk/ux500/clk-prcmu.c b/drivers/clk/ux500/clk-prcmu.c
> index c137934f23ab..9d1f2d4550ad 100644
> --- a/drivers/clk/ux500/clk-prcmu.c
> +++ b/drivers/clk/ux500/clk-prcmu.c
> @@ -258,7 +258,7 @@ static struct clk *clk_reg_prcmu(const char *name,
> return ERR_PTR(-EINVAL);
> }
>
> - clk = kzalloc(sizeof(struct clk_prcmu), GFP_KERNEL);
> + clk = kzalloc(sizeof(*clk), GFP_KERNEL);
> if (!clk)
> return ERR_PTR(-ENOMEM);
>
> diff --git a/drivers/clk/ux500/clk-sysctrl.c b/drivers/clk/ux500/clk-sysctrl.c
> index e0a834c08a04..7c0403b733ae 100644
> --- a/drivers/clk/ux500/clk-sysctrl.c
> +++ b/drivers/clk/ux500/clk-sysctrl.c
> @@ -139,7 +139,7 @@ static struct clk *clk_reg_sysctrl(struct device *dev,
> return ERR_PTR(-EINVAL);
> }
>
> - clk = devm_kzalloc(dev, sizeof(struct clk_sysctrl), GFP_KERNEL);
> + clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL);
> if (!clk)
> return ERR_PTR(-ENOMEM);
>
> --
> 2.14.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2017-11-14 02:01:08

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH 2/2] clk/ux500: Improve a size determination in three functions

On 09/27, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 27 Sep 2017 20:30:53 +0200
>
> Replace the specification of data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---

Applied to clk-next

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

From 1579800037150051055@xxx Thu Sep 28 16:05:20 +0000 2017
X-GM-THRID: 1579719749445909419
X-Gmail-Labels: Inbox,Category Forums

2017-11-14 02:01:53

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH 1/2] clk/ux500: Delete an error message for a failed memory allocation in three functions

On 09/27, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 27 Sep 2017 20:23:58 +0200
>
> Omit extra messages for a memory allocation failure in these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---

Applied to clk-next

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

From 1579800103060490751@xxx Thu Sep 28 16:06:23 +0000 2017
X-GM-THRID: 1579719796379794293
X-Gmail-Labels: Inbox,Category Forums