clk: Fine-tuning for ten function implementations
Subsystems (3)
cover clk: Fine-tuning for ten function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 10:12:34 +0200
Some update suggestions were taken into account
from static source code analysis.
Markus Elfring (8):
Use devm_kcalloc() in si5351_i2c_probe()
Delete an error message for a failed memory allocation in si5351_i2c_probe() Adjust a null pointer check in si5351_dt_parse()
Replace four seq_printf() calls by seq_putc()
Combine two seq_puts() calls into one call in clk_summary_show() Improve a size determination in two functions
Use seq_puts() in nomadik_src_clk_show()
Delete error messages for a failed memory allocation in two functions
drivers/clk/clk-nomadik.c | 12 ++++-------- drivers/clk/clk-si5351.c | 10 ++++------ drivers/clk/clk.c | 19 +++++++++---------- 3 files changed, 17 insertions(+), 24 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/8 clk: si5351: Use devm_kcalloc() in si5351_i2c_probe()
From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 22:37:30 +0200
Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".
This issue was detected by using the Coccinelle software.
--- drivers/clk/clk-si5351.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clk-si5351.c +2 -2
@@ -1535,9 +1535,9 @@ static int si5351_i2c_probe(struct i2c_client *client,else parent_names[1 ] = si5351_pll_names[1 ]; - drvdata->msynth =devm_kzalloc (&client->dev, num_clocks * + drvdata->msynth =devm_kcalloc (&client->dev, num_clocks,sizeof (*drvdata->msynth),GFP_KERNEL ); - drvdata->clkout =devm_kzalloc (&client->dev, num_clocks * + drvdata->clkout =devm_kcalloc (&client->dev, num_clocks,sizeof (*drvdata->clkout),GFP_KERNEL ); drvdata->num_clkout = num_clocks;
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 1/8] clk: si5351: Use devm_kcalloc() in si5351_i2c_probe()
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 22:37:30 +0200Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "
devm_kcalloc".This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/8 clk: si5351: Delete an error message for a failed memory allocation in si5351_i2c_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 07:34:54 +0200
The script "checkpatch.pl" pointed information out like the following.
* CHECK: Comparison to NULL could be written "!drvdata"
Thus adjust this expression.
* WARNING: Possible unnecessary 'out of memory' message
Thus remove such a statement here.
--- drivers/clk/clk-si5351.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/clk-si5351.c +1 -3
@@ -1354,10 +1354,8 @@ static int si5351_i2c_probe(struct i2c_client *client,return -EINVAL ; drvdata =devm_kzalloc (&client->dev,sizeof (*drvdata),GFP_KERNEL ); -if (drvdata =NULL ) { -dev_err (&client->dev,"unable to allocate driver data\n" ); +if (!drvdata)return -ENOMEM ; - }i2c_set_clientdata (client, drvdata); drvdata->client = client;
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 2/8] clk: si5351: Delete an error message for a failed memory allocation in si5351_i2c_probe()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 07:34:54 +0200The script "checkpatch.pl" pointed information out like the following.
* CHECK: Comparison to NULL could be written "!drvdata"
Thus adjust this expression.
Quoted 8 lines
* WARNING: Possible unnecessary 'out of memory' message
Thus remove such a statement here.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/8 clk: si5351: Adjust a null pointer check in si5351_dt_parse()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 07:47:04 +0200
The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!np".
Thus adjust this expression.
--- drivers/clk/clk-si5351.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-si5351.c +1 -1
@@ -1140,7 +1140,7 @@ static int si5351_dt_parse(struct i2c_client *client,int num =0 ;u32 val; -if (np =NULL ) +if (!np)return 0 ; pdata =devm_kzalloc (&client->dev,sizeof (*pdata),GFP_KERNEL );
Signature · 1 line
2.12.2
PATCH 4/8 clk: Replace four seq_printf() calls by seq_putc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 08:45:43 +0200
Four single characters should be put into a sequence. Thus use the corresponding function "seq_putc".
This issue was detected by using the Coccinelle software.
--- drivers/clk/clk.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/clk/clk.c +4 -5
@@ -2081,11 +2081,11 @@ static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level)clk_dump_one (s, c, level);hlist_for_each_entry (child, &c->children, child_node) { -seq_printf (s,"," ); +seq_putc (s,',' );clk_dump_subtree (s, child, level +1 ); } -seq_printf (s,"}" ); +seq_putc (s,'}' ); }static int clk_dump (struct seq_file *s,void *data)
@@ -2094,14 +2094,13 @@ static int clk_dump(struct seq_file *s, void *data)bool first_node = true;struct hlist_head **lists = (struct hlist_head **)s->private; -seq_printf (s,"{" ); - +seq_putc (s,'{' );clk_prepare_lock ();for (; *lists; lists++) {hlist_for_each_entry (c, *lists, child_node) {if (!first_node) -seq_puts (s,"," ); +seq_putc (s,',' ); first_node = false;clk_dump_subtree (s, c,0 ); }
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 4/8] clk: Replace four seq_printf() calls by seq_putc()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 08:45:43 +0200Four single characters should be put into a sequence. Thus use the corresponding function "
seq_putc".This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 5/8 clk: Combine two seq_puts() calls into one call in clk_summary_show()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 09:12:35 +0200
Some text was put into a sequence by two separate function calls. Print the same data by a single function call instead.
--- drivers/clk/clk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/clk.c +3 -3
@@ -2030,9 +2030,9 @@ static int clk_summary_show(struct seq_file *s, void *data)struct clk_core *c;struct hlist_head **lists = (struct hlist_head **)s->private; -seq_puts (s," clock enable_cnt prepare_cnt rate accuracy phase\n" ); -seq_puts (s,"----------------------------------------------------------------------------------------\n" ); - +seq_puts (s, +" clock enable_cnt prepare_cnt rate accuracy phase\n" +"----------------------------------------------------------------------------------------\n" );clk_prepare_lock ();for (; *lists; lists++)
Signature · 1 line
2.12.2
PATCH 6/8 clk: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 09:30:52 +0200
Replace the specification of two 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.
--- drivers/clk/clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clk.c +2 -2
@@ -2939,7 +2939,7 @@ int clk_notifier_register(struct clk *clk, struct notifier_block *nb)/* if clk wasn't in the notifier list, allocate new clk_notifier */ if (cn->clk != clk) { - cn =kzalloc (sizeof (struct clk_notifier ),GFP_KERNEL ); + cn =kzalloc (sizeof (*cn),GFP_KERNEL );if (!cn) goto out;
@@ -3087,7 +3087,7 @@ int of_clk_add_provider(struct device_node *np,struct of_clk_provider *cp;int ret; - cp =kzalloc (sizeof (struct of_clk_provider ),GFP_KERNEL ); + cp =kzalloc (sizeof (*cp),GFP_KERNEL );if (!cp)return -ENOMEM ;
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 6/8] clk: Improve a size determination in two functions
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 09:30:52 +0200Replace the specification of two 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.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 7/8 clk: nomadik: Use seq_puts() in nomadik_src_clk_show()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 09:45:04 +0200
A string which did not contain a data format specification should be put into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
--- drivers/clk/clk-nomadik.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-nomadik.c +1 -1
@@ -467,7 +467,7 @@ static int nomadik_src_clk_show(struct seq_file *s, void *what)u32 src_pckensr0 =readl (src_base +SRC_PCKENSR0 );u32 src_pckensr1 =readl (src_base +SRC_PCKENSR1 ); -seq_printf (s,"Clock: Boot: Now: Request: ASKED:\n" ); +seq_puts (s,"Clock: Boot: Now: Request: ASKED:\n" );for (i =0 ; i <ARRAY_SIZE (src_clk_names); i++) {u32 pcksrb = (i <0x20 ) ? src_pcksr0_boot : src_pcksr1_boot;u32 pcksr = (i <0x20 ) ? src_pcksr0 : src_pcksr1;
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 7/8] clk: nomadik: Use seq_puts() in nomadik_src_clk_show()
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 09:45:04 +0200A string which did not contain a data format specification should be put into a sequence. Thus use the corresponding function "
seq_puts".This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 8/8 clk: nomadik: Delete error messages for a failed memory allocation in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 10:04:00 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: Possible unnecessary 'out of memory' message
Thus remove such statements here.
--- drivers/clk/clk-nomadik.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clk/clk-nomadik.c +3 -7
@@ -267,10 +267,8 @@ pll_clk_register(struct device *dev, const char *name, } pll =kzalloc (sizeof (*pll),GFP_KERNEL ); -if (!pll) { -pr_err ("%s: could not allocate PLL clk\n" , __func__); +if (!pll)return ERR_PTR (-ENOMEM ); - } init.name = name; init.ops = &pll_clk_ops;
@@ -356,11 +354,9 @@ src_clk_register(struct device *dev, const char *name,struct clk_init_data init; sclk =kzalloc (sizeof (*sclk),GFP_KERNEL ); -if (!sclk) { -pr_err ("could not allocate SRC clock %s\n" , - name); +if (!sclk)return ERR_PTR (-ENOMEM ); - } + init.name = name; init.ops = &src_clk_ops;/* Do not force-disable the static SDRAM controller */
Signature · 1 line
2.12.2
Stephen Boyd
AppliedRe: [PATCH 8/8] clk: nomadik: Delete error messages for a failed memory allocation in two functions
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 20 Apr 2017 10:04:00 +0200The script "checkpatch.pl" pointed information out like the following.
Quoted 7 lines
WARNING: Possible unnecessary 'out of memory' message
Thus remove such statements here.
Signed-off-by Markus Elfring <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project