diff mbox

[v2,4/7] thermal: rcar_gen3_thermal: record and check number of TSCs found

Message ID 20170317155300.21566-5-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State Superseded, archived
Delegated to: Eduardo Valentin
Headers show

Commit Message

Niklas Söderlund March 17, 2017, 3:52 p.m. UTC
Record how many TSCs are found in struct rcar_gen3_thermal_priv, this is
needed to be able to add hardware interrupts for trip points later. Also
add a check to make sure at least one TSC is found.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/thermal/rcar_gen3_thermal.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Geert Uytterhoeven March 18, 2017, 2:09 p.m. UTC | #1
On Fri, Mar 17, 2017 at 4:52 PM, Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> Record how many TSCs are found in struct rcar_gen3_thermal_priv, this is
> needed to be able to add hardware interrupts for trip points later. Also
> add a check to make sure at least one TSC is found.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> ---
>  drivers/thermal/rcar_gen3_thermal.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
> index 9b6bc03dd142a8dd..3b6e85abfadc61a3 100644
> --- a/drivers/thermal/rcar_gen3_thermal.c
> +++ b/drivers/thermal/rcar_gen3_thermal.c
> @@ -74,6 +74,7 @@ struct rcar_gen3_thermal_tsc {
>  };
>
>  struct rcar_gen3_thermal_priv {
> +       unsigned int num_tscs;

I would insert this 32-bit number after the pointers below (which are 64-bit),
because of alignment rules and implicit gaps.

>         struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
>  };

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Wolfram Sang March 20, 2017, 8:09 p.m. UTC | #2
On Fri, Mar 17, 2017 at 04:52:57PM +0100, Niklas Söderlund wrote:
> Record how many TSCs are found in struct rcar_gen3_thermal_priv, this is
> needed to be able to add hardware interrupts for trip points later. Also
> add a check to make sure at least one TSC is found.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/thermal/rcar_gen3_thermal.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
> index 9b6bc03dd142a8dd..3b6e85abfadc61a3 100644
> --- a/drivers/thermal/rcar_gen3_thermal.c
> +++ b/drivers/thermal/rcar_gen3_thermal.c
> @@ -74,6 +74,7 @@ struct rcar_gen3_thermal_tsc {
>  };
>  
>  struct rcar_gen3_thermal_priv {
> +	unsigned int num_tscs;
>  	struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
>  };
>  
> @@ -305,6 +306,12 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
>  			goto error_unregister;
>  		}
>  		tsc->zone = zone;
> +		priv->num_tscs++;
> +	}
> +
> +	if (!priv->num_tscs) {
> +		ret = -ENODEV;
> +		goto error_unregister;

I would have probably done 'priv->num_tscs = i;' after the loop instead
of 'priv->num_tscs++;' in the loop, but that is super-minor.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
diff mbox

Patch

diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
index 9b6bc03dd142a8dd..3b6e85abfadc61a3 100644
--- a/drivers/thermal/rcar_gen3_thermal.c
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -74,6 +74,7 @@  struct rcar_gen3_thermal_tsc {
 };
 
 struct rcar_gen3_thermal_priv {
+	unsigned int num_tscs;
 	struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
 };
 
@@ -305,6 +306,12 @@  static int rcar_gen3_thermal_probe(struct platform_device *pdev)
 			goto error_unregister;
 		}
 		tsc->zone = zone;
+		priv->num_tscs++;
+	}
+
+	if (!priv->num_tscs) {
+		ret = -ENODEV;
+		goto error_unregister;
 	}
 
 	return 0;