diff mbox series

[v1,08/10] thermal: tsens: Get rid of 'id' field

Message ID 3810cbe6b499d265d7e3fb97c408cb80a12d5850.1533815718.git.amit.kucheria@linaro.org (mailing list archive)
State Superseded, archived
Delegated to: Andy Gross
Headers show
Series Another round of tsens cleanups | expand

Commit Message

Amit Kucheria Aug. 9, 2018, 12:32 p.m. UTC
The hw_id field in 'struct tsens_sensor' can do the job of tracking
unique ids for each sensor connected to each tsens device instance. It
also allows hw_ids to be overridden (e.g. 8916) in cases where some
sensors in a sequence are disabled on a particular platform.

Use the hw_id field instead of the id field consistently across the
tsens code.

While, we're at it, document the fields of struct tsens_sensor.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
---
 drivers/thermal/qcom/tsens.c |  5 ++---
 drivers/thermal/qcom/tsens.h | 10 +++++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

Comments

Matthias Kaehlcke Aug. 9, 2018, 8:55 p.m. UTC | #1
On Thu, Aug 09, 2018 at 06:02:40PM +0530, Amit Kucheria wrote:
> The hw_id field in 'struct tsens_sensor' can do the job of tracking
> unique ids for each sensor connected to each tsens device instance. It
> also allows hw_ids to be overridden (e.g. 8916) in cases where some
> sensors in a sequence are disabled on a particular platform.
> 
> Use the hw_id field instead of the id field consistently across the
> tsens code.
> 
> While, we're at it, document the fields of struct tsens_sensor.
> 
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> ---
>  drivers/thermal/qcom/tsens.c |  5 ++---
>  drivers/thermal/qcom/tsens.h | 10 +++++++++-
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 9a8e8f7b4ae1..fb728ec5d77f 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -17,7 +17,7 @@ static int tsens_get_temp(void *data, int *temp)
>  	const struct tsens_sensor *s = data;
>  	struct tsens_device *tmdev = s->tmdev;
>  
> -	return tmdev->ops->get_temp(tmdev, s->id, temp);
> +	return tmdev->ops->get_temp(tmdev, s->hw_id, temp);
>  }
>  
>  static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
> @@ -26,7 +26,7 @@ static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
>  	struct tsens_device *tmdev = s->tmdev;
>  
>  	if (tmdev->ops->get_trend)
> -		return  tmdev->ops->get_trend(tmdev, s->id, trend);
> +		return  tmdev->ops->get_trend(tmdev, s->hw_id, trend);
>  
>  	return -ENOTSUPP;
>  }
> @@ -83,7 +83,6 @@ static int tsens_register(struct tsens_device *tmdev)
>  
>  	for (i = 0;  i < tmdev->num_sensors; i++) {
>  		tmdev->sensor[i].tmdev = tmdev;
> -		tmdev->sensor[i].id = i;
>  		tzd = devm_thermal_zone_of_sensor_register(tmdev->dev, i,
>  							   &tmdev->sensor[i],
>  							   &tsens_of_ops);
> diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
> index b9c4bcf255fa..2a3174dfc1a9 100644
> --- a/drivers/thermal/qcom/tsens.h
> +++ b/drivers/thermal/qcom/tsens.h
> @@ -14,11 +14,19 @@
>  
>  struct tsens_device;
>  
> +/**
> + * struct tsens_sensor - sensor-specific data
> + * @tmdev: tsens device instance this sensor is connected to
> + * @tzd: thermal zone corresponding to this sensor
> + * @offset: offset from calibration data to convert ADC data to degrees
> + * @hw_id: unique sensor ID for each sensor connected to tsens device instance
> + * @slope: slope from calibration data to convert ADC data to degrees
> + * @status: 8960-specific status register addresses
> + */
>  struct tsens_sensor {
>  	struct tsens_device		*tmdev;
>  	struct thermal_zone_device	*tzd;
>  	int				offset;
> -	int				id;
>  	int				hw_id;
>  	int				slope;
>  	u32				status;

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 9a8e8f7b4ae1..fb728ec5d77f 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -17,7 +17,7 @@  static int tsens_get_temp(void *data, int *temp)
 	const struct tsens_sensor *s = data;
 	struct tsens_device *tmdev = s->tmdev;
 
-	return tmdev->ops->get_temp(tmdev, s->id, temp);
+	return tmdev->ops->get_temp(tmdev, s->hw_id, temp);
 }
 
 static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
@@ -26,7 +26,7 @@  static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
 	struct tsens_device *tmdev = s->tmdev;
 
 	if (tmdev->ops->get_trend)
-		return  tmdev->ops->get_trend(tmdev, s->id, trend);
+		return  tmdev->ops->get_trend(tmdev, s->hw_id, trend);
 
 	return -ENOTSUPP;
 }
@@ -83,7 +83,6 @@  static int tsens_register(struct tsens_device *tmdev)
 
 	for (i = 0;  i < tmdev->num_sensors; i++) {
 		tmdev->sensor[i].tmdev = tmdev;
-		tmdev->sensor[i].id = i;
 		tzd = devm_thermal_zone_of_sensor_register(tmdev->dev, i,
 							   &tmdev->sensor[i],
 							   &tsens_of_ops);
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index b9c4bcf255fa..2a3174dfc1a9 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -14,11 +14,19 @@ 
 
 struct tsens_device;
 
+/**
+ * struct tsens_sensor - sensor-specific data
+ * @tmdev: tsens device instance this sensor is connected to
+ * @tzd: thermal zone corresponding to this sensor
+ * @offset: offset from calibration data to convert ADC data to degrees
+ * @hw_id: unique sensor ID for each sensor connected to tsens device instance
+ * @slope: slope from calibration data to convert ADC data to degrees
+ * @status: 8960-specific status register addresses
+ */
 struct tsens_sensor {
 	struct tsens_device		*tmdev;
 	struct thermal_zone_device	*tzd;
 	int				offset;
-	int				id;
 	int				hw_id;
 	int				slope;
 	u32				status;