Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Iker Perez <iker.perez@codethink.co.uk>,
	Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v1 1/5] hwmon: (lm75) Add kind field to struct lm75_data
Date: Tue, 9 Jul 2019 06:20:55 -0700
Message-ID: <e8f78059-db4a-1829-8c9b-7b006335bc60@roeck-us.net> (raw)
In-Reply-To: <20190709095052.7964-2-iker.perez@codethink.co.uk>

On 7/9/19 2:50 AM, Iker Perez wrote:
> From: Iker Perez del Palomar Sustatxa <iker.perez@codethink.co.uk>
> 
> The purpose of this change is to store the kind of device the
> kernel is working with.
> 
> Signed-off-by: Iker Perez del Palomar Sustatxa <iker.perez@codethink.co.uk>
> ---
>   drivers/hwmon/lm75.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index 3fb9c0a2d6d0..0209e0719784 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -68,6 +68,7 @@ struct lm75_data {
>   	u8			resolution;	/* In bits, between 9 and 16 */
>   	u8			resolution_limits;
>   	unsigned int		sample_time;	/* In ms */
> +	enum lm75_type		kind;
>   };
>   
>   /*-----------------------------------------------------------------------*/
> @@ -237,15 +238,16 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
>   	struct device *dev = &client->dev;
>   	struct device *hwmon_dev;
>   	struct lm75_data *data;
> +	struct lm75_data device_data;
>   	int status, err;
>   	u8 set_mask, clr_mask;
>   	int new;
> -	enum lm75_type kind;
>   
> +	data = &device_data;

This makes no sense.

>   	if (client->dev.of_node)
> -		kind = (enum lm75_type)of_device_get_match_data(&client->dev);
> +		data->kind = (enum lm75_type)of_device_get_match_data(&client->dev);
>   	else
> -		kind = id->driver_data;
> +		data->kind = id->driver_data;
>   
... because data is overwritten a couple of lines below when it is allocated.

You would do something like

	data->kind = kind;

after data was allocated. Looking at the above code, though, I really wonder if
and how you tested it.

Guenter

>   	if (!i2c_check_functionality(client->adapter,
>   			I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
> @@ -267,7 +269,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
>   	set_mask = 0;
>   	clr_mask = LM75_SHUTDOWN;		/* continuous conversions */
>   
> -	switch (kind) {
> +	switch (data->kind) {
>   	case adt75:
>   		clr_mask |= 1 << 5;		/* not one-shot mode */
>   		data->resolution = 12;
> 


  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09  9:50 [PATCH v1 0/5] Help with lm75.c changes Iker Perez
2019-07-09  9:50 ` [PATCH v1 1/5] hwmon: (lm75) Add kind field to struct lm75_data Iker Perez
2019-07-09 13:20   ` Guenter Roeck [this message]
2019-07-09  9:50 ` [PATCH v1 2/5] hwmon: (lm75) Include hwmon_chip in the permitted types to be writen Iker Perez
2019-07-09 13:26   ` Guenter Roeck
2019-07-09  9:50 ` [PATCH v1 3/5] hwmon: (lm75) Give write permission to hwmon_chip_update_interval Iker Perez
2019-07-09  9:50 ` [PATCH v1 4/5] hwmon: (lm75) Create function from code to write into registers Iker Perez
2019-07-09 13:39   ` Guenter Roeck
2019-07-09  9:50 ` [PATCH v1 5/5] First approach to sample time writing method Iker Perez
2019-07-09 13:33   ` Guenter Roeck
2019-07-09 13:43 ` [PATCH v1 0/5] Help with lm75.c changes Guenter Roeck
2019-07-09 15:11   ` Iker Perez del Palomar

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8f78059-db4a-1829-8c9b-7b006335bc60@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=iker.perez@codethink.co.uk \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox