diff mbox series

[5/8] hwmon: (lm90) define maximum number of channels that are supported

Message ID 20220520093243.2523749-6-sst@poczta.fm (mailing list archive)
State Changes Requested
Headers show
Series Add support for ADT7481 in lm90 | expand

Commit Message

Slawomir Stepien May 20, 2022, 9:32 a.m. UTC
From: Slawomir Stepien <slawomir.stepien@nokia.com>

Use this define in all the places where literal '3' was used in this
context.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
---
 drivers/hwmon/lm90.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

Comments

Guenter Roeck May 21, 2022, 2:36 a.m. UTC | #1
On Fri, May 20, 2022 at 11:32:41AM +0200, Slawomir Stepien wrote:
> From: Slawomir Stepien <slawomir.stepien@nokia.com>
> 
> Use this define in all the places where literal '3' was used in this
> context.

The literal '3' does not always reflect the number of channels.

> 
> Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
> ---
>  drivers/hwmon/lm90.c | 29 ++++++++++++++++-------------
>  1 file changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 00fd5734f217..f642c6fd1641 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -93,6 +93,9 @@
>  #include <linux/interrupt.h>
>  #include <linux/regulator/consumer.h>
>  
> +/* The maximum number of channels currently supported */
> +#define MAX_CHANNELS 3

#define<space>NAME<tab>value

> +
>  /*
>   * Addresses to scan
>   * Address is fully defined internally and cannot be changed except for
> @@ -521,9 +524,9 @@ enum lm90_temp11_reg_index {
>  struct lm90_data {
>  	struct i2c_client *client;
>  	struct device *hwmon_dev;
> -	u32 channel_config[4];
> +	u32 channel_config[MAX_CHANNELS + 1];
>  	struct hwmon_channel_info temp_info;
> -	const struct hwmon_channel_info *info[3];
> +	const struct hwmon_channel_info *info[MAX_CHANNELS];

This is wrong.

Guenter
Slawomir Stepien May 22, 2022, 2:59 p.m. UTC | #2
On maj 20, 2022 19:36, Guenter Roeck wrote:
> On Fri, May 20, 2022 at 11:32:41AM +0200, Slawomir Stepien wrote:
> > From: Slawomir Stepien <slawomir.stepien@nokia.com>
> > 
> > Use this define in all the places where literal '3' was used in this
> > context.
> 
> The literal '3' does not always reflect the number of channels.

You caught me.
But besides this problem with struct hwmon_chip_info the '3' was used in context of
max number of channels.

> > 
> > Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
> > ---
> >  drivers/hwmon/lm90.c | 29 ++++++++++++++++-------------
> >  1 file changed, 16 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> > index 00fd5734f217..f642c6fd1641 100644
> > --- a/drivers/hwmon/lm90.c
> > +++ b/drivers/hwmon/lm90.c
> > @@ -93,6 +93,9 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/regulator/consumer.h>
> >  
> > +/* The maximum number of channels currently supported */
> > +#define MAX_CHANNELS 3
> 
> #define<space>NAME<tab>value

OK

> > +
> >  /*
> >   * Addresses to scan
> >   * Address is fully defined internally and cannot be changed except for
> > @@ -521,9 +524,9 @@ enum lm90_temp11_reg_index {
> >  struct lm90_data {
> >  	struct i2c_client *client;
> >  	struct device *hwmon_dev;
> > -	u32 channel_config[4];
> > +	u32 channel_config[MAX_CHANNELS + 1];
> >  	struct hwmon_channel_info temp_info;
> > -	const struct hwmon_channel_info *info[3];
> > +	const struct hwmon_channel_info *info[MAX_CHANNELS];
> 
> This is wrong.

Yes, sorry for that. I have not checked struct hwmon_chip_info description.
diff mbox series

Patch

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 00fd5734f217..f642c6fd1641 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -93,6 +93,9 @@ 
 #include <linux/interrupt.h>
 #include <linux/regulator/consumer.h>
 
+/* The maximum number of channels currently supported */
+#define MAX_CHANNELS 3
+
 /*
  * Addresses to scan
  * Address is fully defined internally and cannot be changed except for
@@ -521,9 +524,9 @@  enum lm90_temp11_reg_index {
 struct lm90_data {
 	struct i2c_client *client;
 	struct device *hwmon_dev;
-	u32 channel_config[4];
+	u32 channel_config[MAX_CHANNELS + 1];
 	struct hwmon_channel_info temp_info;
-	const struct hwmon_channel_info *info[3];
+	const struct hwmon_channel_info *info[MAX_CHANNELS];
 	struct hwmon_chip_info chip;
 	struct mutex update_lock;
 	bool valid;		/* true if register values are valid */
@@ -1223,32 +1226,32 @@  static int lm90_set_temphyst(struct lm90_data *data, long val)
 	return err;
 }
 
-static const u8 lm90_temp_index[3] = {
+static const u8 lm90_temp_index[MAX_CHANNELS] = {
 	LOCAL_TEMP, REMOTE_TEMP, REMOTE2_TEMP
 };
 
-static const u8 lm90_temp_min_index[3] = {
+static const u8 lm90_temp_min_index[MAX_CHANNELS] = {
 	LOCAL_LOW, REMOTE_LOW, REMOTE2_LOW
 };
 
-static const u8 lm90_temp_max_index[3] = {
+static const u8 lm90_temp_max_index[MAX_CHANNELS] = {
 	LOCAL_HIGH, REMOTE_HIGH, REMOTE2_HIGH
 };
 
-static const u8 lm90_temp_crit_index[3] = {
+static const u8 lm90_temp_crit_index[MAX_CHANNELS] = {
 	LOCAL_CRIT, REMOTE_CRIT, REMOTE2_CRIT
 };
 
-static const u8 lm90_temp_emerg_index[3] = {
+static const u8 lm90_temp_emerg_index[MAX_CHANNELS] = {
 	LOCAL_EMERG, REMOTE_EMERG, REMOTE2_EMERG
 };
 
-static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
-static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
-static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
-static const u8 lm90_crit_alarm_bits_swapped[3] = { 1, 0, 9 };
-static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
-static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
+static const u8 lm90_min_alarm_bits[MAX_CHANNELS] = { 5, 3, 11 };
+static const u8 lm90_max_alarm_bits[MAX_CHANNELS] = { 6, 4, 12 };
+static const u8 lm90_crit_alarm_bits[MAX_CHANNELS] = { 0, 1, 9 };
+static const u8 lm90_crit_alarm_bits_swapped[MAX_CHANNELS] = { 1, 0, 9 };
+static const u8 lm90_emergency_alarm_bits[MAX_CHANNELS] = { 15, 13, 14 };
+static const u8 lm90_fault_bits[MAX_CHANNELS] = { 0, 2, 10 };
 
 static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val)
 {