All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <j.w.r.degoede-fbo2DhPpy/Q@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>,
	Linux I2C <i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org>,
	LM Sensors <lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org>
Subject: Re: [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c driver
Date: Wed, 16 Jul 2008 23:04:11 +0200	[thread overview]
Message-ID: <487E624B.4060908@hhs.nl> (raw)
In-Reply-To: <20080716173316.1e8c5c42-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

Jean Delvare wrote:
> The new-style thmc50 driver implements the optional detect()
> callback to cover the use cases of the legacy driver.
> 
> Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>

> @@ -307,21 +304,22 @@ static int thmc50_detect(struct i2c_adap
>  	}
>  	if (err == -ENODEV) {
>  		pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
> -		goto exit_free;
> +		return err;
>  	}
> -	data->type = kind;
>  
>  	if (kind == adm1022) {
>  		int id = i2c_adapter_id(client->adapter);
>  		int i;
>  
>  		type_name = "adm1022";
> -		data->has_temp3 = (config >> 7) & 1;	/* config MSB */
>  		for (i = 0; i + 1 < adm1022_temp3_num; i += 2)
>  			if (adm1022_temp3[i] == id &&
> -			    adm1022_temp3[i + 1] == address) {
> +			    adm1022_temp3[i + 1] == client->addr) {
>  				/* enable 2nd remote temp */
> -				data->has_temp3 = 1;
> +				config |= (1 << 7);
> +				i2c_smbus_write_byte_data(client,
> +							  THMC50_REG_CONF,
> +							  config);
>  				break;
>  			}
>  	} else {

Hmm, This does not seem right, you are _writing_ to the device in a the detect 
function changing its configuration. I understand you can no longer set 
data->has_temp3 as there is no data yet in the detect, instead the entire loop 
which checks if the device has temp3 forced through a module option should be 
moved to the probe function. Writing to a config register in the detect 
function feels wrong to me.

Regards,

Hans

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

WARNING: multiple messages have this Message-ID (diff)
From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>,
	Linux I2C <i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org>,
	LM Sensors <lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org>
Subject: Re: [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c
Date: Wed, 16 Jul 2008 20:59:37 +0000	[thread overview]
Message-ID: <487E624B.4060908@hhs.nl> (raw)
In-Reply-To: <20080716173316.1e8c5c42-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

Jean Delvare wrote:
> The new-style thmc50 driver implements the optional detect()
> callback to cover the use cases of the legacy driver.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> Cc: Krzysztof Helt <krzysztof.h1@wp.pl>

> @@ -307,21 +304,22 @@ static int thmc50_detect(struct i2c_adap
>  	}
>  	if (err = -ENODEV) {
>  		pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
> -		goto exit_free;
> +		return err;
>  	}
> -	data->type = kind;
>  
>  	if (kind = adm1022) {
>  		int id = i2c_adapter_id(client->adapter);
>  		int i;
>  
>  		type_name = "adm1022";
> -		data->has_temp3 = (config >> 7) & 1;	/* config MSB */
>  		for (i = 0; i + 1 < adm1022_temp3_num; i += 2)
>  			if (adm1022_temp3[i] = id &&
> -			    adm1022_temp3[i + 1] = address) {
> +			    adm1022_temp3[i + 1] = client->addr) {
>  				/* enable 2nd remote temp */
> -				data->has_temp3 = 1;
> +				config |= (1 << 7);
> +				i2c_smbus_write_byte_data(client,
> +							  THMC50_REG_CONF,
> +							  config);
>  				break;
>  			}
>  	} else {

Hmm, This does not seem right, you are _writing_ to the device in a the detect 
function changing its configuration. I understand you can no longer set 
data->has_temp3 as there is no data yet in the detect, instead the entire loop 
which checks if the device has temp3 forced through a module option should be 
moved to the probe function. Writing to a config register in the detect 
function feels wrong to me.

Regards,

Hans

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2008-07-16 21:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-16 15:33 [PATCH] hwmon: (thmc50) Convert to a new-style i2c driver Jean Delvare
2008-07-16 15:33 ` [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c Jean Delvare
     [not found] ` <20080716173316.1e8c5c42-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-16 20:59   ` Hans de Goede [this message]
2008-07-16 21:04     ` [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c driver Hans de Goede
2008-07-16 21:14     ` Jean Delvare
2008-07-16 21:14       ` [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c Jean Delvare
2008-07-16 21:31       ` [PATCH] hwmon: (thmc50) Convert to a new-style i2c driver Hans de Goede
2008-07-16 21:31         ` [lm-sensors] [PATCH] hwmon: (thmc50) Convert to a new-style i2c Hans de Goede

Reply instructions:

You may reply publicly 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=487E624B.4060908@hhs.nl \
    --to=j.w.r.degoede-fbo2dhppy/q@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=krzysztof.h1-5tc4TXWwyLM@public.gmane.org \
    --cc=lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.