diff mbox series

[04/12] thermal/drivers/exynos: simplify probe() with local dev variable

Message ID 20240709-thermal-probe-v1-4-241644e2b6e0@linaro.org (mailing list archive)
State New
Headers show
Series thermal/drivers: simplify probe() | expand

Commit Message

Krzysztof Kozlowski July 9, 2024, 12:59 p.m. UTC
Simplify the probe() function by using local 'dev' instead of
&pdev->dev.  While touching devm_kzalloc(), use preferred sizeof(*)
syntax.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/thermal/samsung/exynos_tmu.c | 42 +++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

Comments

Alim Akhtar July 10, 2024, 10:30 a.m. UTC | #1
Hello Krzysztof

> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Sent: Tuesday, July 9, 2024 6:30 PM
> To: Rafael J. Wysocki <rafael@kernel.org>; Daniel Lezcano
> <daniel.lezcano@linaro.org>; Zhang Rui <rui.zhang@intel.com>; Lukasz Luba
> <lukasz.luba@arm.com>; Florian Fainelli <florian.fainelli@broadcom.com>;
> Ray Jui <rjui@broadcom.com>; Scott Branden <sbranden@broadcom.com>;
> Broadcom internal kernel review list <bcm-kernel-feedback-
> list@broadcom.com>; Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>;
> Krzysztof Kozlowski <krzk@kernel.org>; Alim Akhtar
> <alim.akhtar@samsung.com>; Shawn Guo <shawnguo@kernel.org>; Sascha
> Hauer <s.hauer@pengutronix.de>; Pengutronix Kernel Team
> <kernel@pengutronix.de>; Fabio Estevam <festevam@gmail.com>; Amit
> Kucheria <amitk@kernel.org>; Thara Gopinath <thara.gopinath@gmail.com>
> Cc: linux-pm@vger.kernel.org; linux-rpi-kernel@lists.infradead.org; linux-
> arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linux-
> samsung-soc@vger.kernel.org; imx@lists.linux.dev; linux-arm-
> msm@vger.kernel.org; Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>
> Subject: [PATCH 04/12] thermal/drivers/exynos: simplify probe() with local
> dev variable
> 
> Simplify the probe() function by using local 'dev' instead of &pdev->dev.
> While touching devm_kzalloc(), use preferred sizeof(*) syntax.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

>  drivers/thermal/samsung/exynos_tmu.c | 42 +++++++++++++++++----------
> ---------
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c
> b/drivers/thermal/samsung/exynos_tmu.c
> index 6482513bfe66..1152871cc982 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -1004,11 +1004,11 @@ static const struct thermal_zone_device_ops
> exynos_sensor_ops = {
> 
>  static int exynos_tmu_probe(struct platform_device *pdev)  {
> +	struct device *dev = &pdev->dev;
>  	struct exynos_tmu_data *data;
>  	int ret;
> 
> -	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
> -					GFP_KERNEL);
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
> 
> @@ -1020,7 +1020,7 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
>  	 * TODO: Add regulator as an SOC feature, so that regulator enable
>  	 * is a compulsory call.
>  	 */
> -	ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu");
> +	ret = devm_regulator_get_enable_optional(dev, "vtmu");
>  	switch (ret) {
>  	case 0:
>  	case -ENODEV:
> @@ -1028,8 +1028,7 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
>  	case -EPROBE_DEFER:
>  		return -EPROBE_DEFER;
>  	default:
> -		dev_err(&pdev->dev, "Failed to get enabled regulator:
> %d\n",
> -			ret);
> +		dev_err(dev, "Failed to get enabled regulator: %d\n", ret);
>  		return ret;
>  	}
> 
> @@ -1037,44 +1036,44 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
>  	if (ret)
>  		return ret;
> 
> -	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
> +	data->clk = devm_clk_get(dev, "tmu_apbif");
>  	if (IS_ERR(data->clk)) {
> -		dev_err(&pdev->dev, "Failed to get clock\n");
> +		dev_err(dev, "Failed to get clock\n");
>  		return PTR_ERR(data->clk);
>  	}
> 
> -	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
> +	data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif");
>  	if (IS_ERR(data->clk_sec)) {
>  		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
> -			dev_err(&pdev->dev, "Failed to get triminfo
> clock\n");
> +			dev_err(dev, "Failed to get triminfo clock\n");
>  			return PTR_ERR(data->clk_sec);
>  		}
>  	} else {
>  		ret = clk_prepare(data->clk_sec);
>  		if (ret) {
> -			dev_err(&pdev->dev, "Failed to get clock\n");
> +			dev_err(dev, "Failed to get clock\n");
>  			return ret;
>  		}
>  	}
> 
>  	ret = clk_prepare(data->clk);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Failed to get clock\n");
> +		dev_err(dev, "Failed to get clock\n");
>  		goto err_clk_sec;
>  	}
> 
>  	switch (data->soc) {
>  	case SOC_ARCH_EXYNOS5433:
>  	case SOC_ARCH_EXYNOS7:
> -		data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk");
> +		data->sclk = devm_clk_get(dev, "tmu_sclk");
>  		if (IS_ERR(data->sclk)) {
> -			dev_err(&pdev->dev, "Failed to get sclk\n");
> +			dev_err(dev, "Failed to get sclk\n");
>  			ret = PTR_ERR(data->sclk);
>  			goto err_clk;
>  		} else {
>  			ret = clk_prepare_enable(data->sclk);
>  			if (ret) {
> -				dev_err(&pdev->dev, "Failed to enable
> sclk\n");
> +				dev_err(dev, "Failed to enable sclk\n");
>  				goto err_clk;
>  			}
>  		}
> @@ -1085,33 +1084,32 @@ static int exynos_tmu_probe(struct
> platform_device *pdev)
> 
>  	ret = exynos_tmu_initialize(pdev);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Failed to initialize TMU\n");
> +		dev_err(dev, "Failed to initialize TMU\n");
>  		goto err_sclk;
>  	}
> 
> -	data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
> +	data->tzd = devm_thermal_of_zone_register(dev, 0, data,
>  						  &exynos_sensor_ops);
>  	if (IS_ERR(data->tzd)) {
>  		ret = PTR_ERR(data->tzd);
>  		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev, "Failed to register sensor:
> %d\n",
> -				ret);
> +			dev_err(dev, "Failed to register sensor: %d\n", ret);
>  		goto err_sclk;
>  	}
> 
>  	ret = exynos_thermal_zone_configure(pdev);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Failed to configure the thermal
> zone\n");
> +		dev_err(dev, "Failed to configure the thermal zone\n");
>  		goto err_sclk;
>  	}
> 
> -	ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL,
> +	ret = devm_request_threaded_irq(dev, data->irq, NULL,
>  					exynos_tmu_threaded_irq,
>  					IRQF_TRIGGER_RISING
>  						| IRQF_SHARED |
> IRQF_ONESHOT,
> -					dev_name(&pdev->dev), data);
> +					dev_name(dev), data);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Failed to request irq: %d\n", data-
> >irq);
> +		dev_err(dev, "Failed to request irq: %d\n", data->irq);
>  		goto err_sclk;
>  	}
> 
> 
> --
> 2.43.0
diff mbox series

Patch

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 6482513bfe66..1152871cc982 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1004,11 +1004,11 @@  static const struct thermal_zone_device_ops exynos_sensor_ops = {
 
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct exynos_tmu_data *data;
 	int ret;
 
-	data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data),
-					GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -1020,7 +1020,7 @@  static int exynos_tmu_probe(struct platform_device *pdev)
 	 * TODO: Add regulator as an SOC feature, so that regulator enable
 	 * is a compulsory call.
 	 */
-	ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu");
+	ret = devm_regulator_get_enable_optional(dev, "vtmu");
 	switch (ret) {
 	case 0:
 	case -ENODEV:
@@ -1028,8 +1028,7 @@  static int exynos_tmu_probe(struct platform_device *pdev)
 	case -EPROBE_DEFER:
 		return -EPROBE_DEFER;
 	default:
-		dev_err(&pdev->dev, "Failed to get enabled regulator: %d\n",
-			ret);
+		dev_err(dev, "Failed to get enabled regulator: %d\n", ret);
 		return ret;
 	}
 
@@ -1037,44 +1036,44 @@  static int exynos_tmu_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	data->clk = devm_clk_get(&pdev->dev, "tmu_apbif");
+	data->clk = devm_clk_get(dev, "tmu_apbif");
 	if (IS_ERR(data->clk)) {
-		dev_err(&pdev->dev, "Failed to get clock\n");
+		dev_err(dev, "Failed to get clock\n");
 		return PTR_ERR(data->clk);
 	}
 
-	data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif");
+	data->clk_sec = devm_clk_get(dev, "tmu_triminfo_apbif");
 	if (IS_ERR(data->clk_sec)) {
 		if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
-			dev_err(&pdev->dev, "Failed to get triminfo clock\n");
+			dev_err(dev, "Failed to get triminfo clock\n");
 			return PTR_ERR(data->clk_sec);
 		}
 	} else {
 		ret = clk_prepare(data->clk_sec);
 		if (ret) {
-			dev_err(&pdev->dev, "Failed to get clock\n");
+			dev_err(dev, "Failed to get clock\n");
 			return ret;
 		}
 	}
 
 	ret = clk_prepare(data->clk);
 	if (ret) {
-		dev_err(&pdev->dev, "Failed to get clock\n");
+		dev_err(dev, "Failed to get clock\n");
 		goto err_clk_sec;
 	}
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS5433:
 	case SOC_ARCH_EXYNOS7:
-		data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk");
+		data->sclk = devm_clk_get(dev, "tmu_sclk");
 		if (IS_ERR(data->sclk)) {
-			dev_err(&pdev->dev, "Failed to get sclk\n");
+			dev_err(dev, "Failed to get sclk\n");
 			ret = PTR_ERR(data->sclk);
 			goto err_clk;
 		} else {
 			ret = clk_prepare_enable(data->sclk);
 			if (ret) {
-				dev_err(&pdev->dev, "Failed to enable sclk\n");
+				dev_err(dev, "Failed to enable sclk\n");
 				goto err_clk;
 			}
 		}
@@ -1085,33 +1084,32 @@  static int exynos_tmu_probe(struct platform_device *pdev)
 
 	ret = exynos_tmu_initialize(pdev);
 	if (ret) {
-		dev_err(&pdev->dev, "Failed to initialize TMU\n");
+		dev_err(dev, "Failed to initialize TMU\n");
 		goto err_sclk;
 	}
 
-	data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
+	data->tzd = devm_thermal_of_zone_register(dev, 0, data,
 						  &exynos_sensor_ops);
 	if (IS_ERR(data->tzd)) {
 		ret = PTR_ERR(data->tzd);
 		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to register sensor: %d\n",
-				ret);
+			dev_err(dev, "Failed to register sensor: %d\n", ret);
 		goto err_sclk;
 	}
 
 	ret = exynos_thermal_zone_configure(pdev);
 	if (ret) {
-		dev_err(&pdev->dev, "Failed to configure the thermal zone\n");
+		dev_err(dev, "Failed to configure the thermal zone\n");
 		goto err_sclk;
 	}
 
-	ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL,
+	ret = devm_request_threaded_irq(dev, data->irq, NULL,
 					exynos_tmu_threaded_irq,
 					IRQF_TRIGGER_RISING
 						| IRQF_SHARED | IRQF_ONESHOT,
-					dev_name(&pdev->dev), data);
+					dev_name(dev), data);
 	if (ret) {
-		dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
+		dev_err(dev, "Failed to request irq: %d\n", data->irq);
 		goto err_sclk;
 	}