[1/7] thermal: rockchip: Simplify getting match data

Message ID 20221031175058.175698-2-sebastian.reichel@collabora.com
State New
Headers
Series RK3588 Thermal Support |

Commit Message

Sebastian Reichel Oct. 31, 2022, 5:50 p.m. UTC
  It's possible to directly get the match data in a generic
way nowadays.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/thermal/rockchip_thermal.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
  

Comments

Heiko Stübner Nov. 15, 2022, 11:19 a.m. UTC | #1
Am Montag, 31. Oktober 2022, 18:50:52 CET schrieb Sebastian Reichel:
> It's possible to directly get the match data in a generic
> way nowadays.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  drivers/thermal/rockchip_thermal.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 819e059cde71..0a0f38c29842 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -1353,16 +1353,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>  {
>  	struct device_node *np = pdev->dev.of_node;
>  	struct rockchip_thermal_data *thermal;
> -	const struct of_device_id *match;
>  	struct resource *res;
>  	int irq;
>  	int i;
>  	int error;
>  
> -	match = of_match_node(of_rockchip_thermal_match, np);
> -	if (!match)
> -		return -ENXIO;
> -
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
>  		return -EINVAL;
> @@ -1374,7 +1369,7 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
>  
>  	thermal->pdev = pdev;
>  
> -	thermal->chip = (const struct rockchip_tsadc_chip *)match->data;
> +	thermal->chip = (const struct rockchip_tsadc_chip *) device_get_match_data(&pdev->dev);

Nit: This can work without the explicit cast and most users
in the kernel also use it that way - makes reading far easier.

Otherwise
Reviewed-by: Heiko Stuebner <heiko@sntech.de>

Heiko

>  	if (!thermal->chip)
>  		return -EINVAL;
>  
>
  

Patch

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 819e059cde71..0a0f38c29842 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -1353,16 +1353,11 @@  static int rockchip_thermal_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct rockchip_thermal_data *thermal;
-	const struct of_device_id *match;
 	struct resource *res;
 	int irq;
 	int i;
 	int error;
 
-	match = of_match_node(of_rockchip_thermal_match, np);
-	if (!match)
-		return -ENXIO;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return -EINVAL;
@@ -1374,7 +1369,7 @@  static int rockchip_thermal_probe(struct platform_device *pdev)
 
 	thermal->pdev = pdev;
 
-	thermal->chip = (const struct rockchip_tsadc_chip *)match->data;
+	thermal->chip = (const struct rockchip_tsadc_chip *) device_get_match_data(&pdev->dev);
 	if (!thermal->chip)
 		return -EINVAL;