diff mbox series

[RFC,1/3] clk: bd718x7: Clean up the code, no functional changes

Message ID 20220605165703.1565234-2-michael@amarulasolutions.com (mailing list archive)
State RFC, archived
Headers show
Series [RFC,1/3] clk: bd718x7: Clean up the code, no functional changes | expand

Commit Message

Michael Nazzareno Trimarchi June 5, 2022, 4:57 p.m. UTC
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 drivers/clk/clk-bd718x7.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Matti Vaittinen June 6, 2022, 5:49 a.m. UTC | #1
On 6/5/22 19:57, Michael Trimarchi wrote:
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---
>   drivers/clk/clk-bd718x7.c | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c
> index ac40b669d60b..04cc0beb67df 100644
> --- a/drivers/clk/clk-bd718x7.c
> +++ b/drivers/clk/clk-bd718x7.c
> @@ -81,27 +81,28 @@ static int bd71837_clk_probe(struct platform_device *pdev)
>   	struct bd718xx_clk *c;
>   	int rval = -ENOMEM;
>   	const char *parent_clk;
> +	struct device *dev = &pdev->dev;

I am not a fan of assigning pointers to struct members to local 
variables unless they're shortening lines to fit on one row instead of 
using two. Whenever we add such a variable we hide information. After 
that being said - in this particular case the device 'dev' points to is 
quite obvious so I am not completely against the change if other see the 
value.

>   	struct device *parent = pdev->dev.parent;
>   	struct clk_init_data init = {
>   		.name = "bd718xx-32k-out",
>   		.ops = &bd71837_clk_ops,
> +		.num_parents = 1,

I like this. Thanks.

>   	};

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

Best Regards
	-- Matti
diff mbox series

Patch

diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c
index ac40b669d60b..04cc0beb67df 100644
--- a/drivers/clk/clk-bd718x7.c
+++ b/drivers/clk/clk-bd718x7.c
@@ -81,27 +81,28 @@  static int bd71837_clk_probe(struct platform_device *pdev)
 	struct bd718xx_clk *c;
 	int rval = -ENOMEM;
 	const char *parent_clk;
+	struct device *dev = &pdev->dev;
 	struct device *parent = pdev->dev.parent;
 	struct clk_init_data init = {
 		.name = "bd718xx-32k-out",
 		.ops = &bd71837_clk_ops,
+		.num_parents = 1,
 	};
 	enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;
 
-	c = devm_kzalloc(&pdev->dev, sizeof(*c), GFP_KERNEL);
+	c = devm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
 	if (!c)
 		return -ENOMEM;
 
-	c->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+	c->regmap = dev_get_regmap(parent, NULL);
 	if (!c->regmap)
 		return -ENODEV;
 
-	init.num_parents = 1;
 	parent_clk = of_clk_get_parent_name(parent->of_node, 0);
 
 	init.parent_names = &parent_clk;
 	if (!parent_clk) {
-		dev_err(&pdev->dev, "No parent clk found\n");
+		dev_err(dev, "No parent clk found\n");
 		return -EINVAL;
 	}
 	switch (chip) {
@@ -119,7 +120,7 @@  static int bd71837_clk_probe(struct platform_device *pdev)
 		c->mask = CLK_OUT_EN_MASK;
 		break;
 	default:
-		dev_err(&pdev->dev, "Unknown clk chip\n");
+		dev_err(dev, "Unknown clk chip\n");
 		return -EINVAL;
 	}
 	c->pdev = pdev;
@@ -128,15 +129,15 @@  static int bd71837_clk_probe(struct platform_device *pdev)
 	of_property_read_string_index(parent->of_node,
 				      "clock-output-names", 0, &init.name);
 
-	rval = devm_clk_hw_register(&pdev->dev, &c->hw);
+	rval = devm_clk_hw_register(dev, &c->hw);
 	if (rval) {
-		dev_err(&pdev->dev, "failed to register 32K clk");
+		dev_err(dev, "failed to register 32K clk");
 		return rval;
 	}
-	rval = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_simple_get,
+	rval = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
 					   &c->hw);
 	if (rval)
-		dev_err(&pdev->dev, "adding clk provider failed\n");
+		dev_err(dev, "adding clk provider failed\n");
 
 	return rval;
 }