All of lore.kernel.org
 help / color / mirror / Atom feed
From: "corentin.labbe" <corentin.labbe@geomatys.fr>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: Clean up detect functions
Date: Tue, 20 Oct 2009 14:26:28 +0000	[thread overview]
Message-ID: <4ADDC894.7070807@geomatys.fr> (raw)
In-Reply-To: <20091006201323.0ab6d745@hyperion.delvare>

Jean Delvare a écrit :
> As kind is now hard-coded to -1, there is room for code clean-ups.

Acked-by: Corentin LABBE <corentin.labbe@geomatys.fr>

> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> CC: Corentin Labbe <corentin.labbe@geomatys.fr>
> Cc: Mark M. Hoffman <mhoffman@lightlink.com>
> Cc: Juerg Haefliger <juergh@gmail.com>
> Cc: Riku Voipio <riku.vipio@iki.fi>
> Cc: Hans J. Koch <hjk@linutronix.de>
> Cc: Rudolf Marek <r.marek@assembler.cz>
> ---
>  drivers/hwmon/adm1029.c    |   57 +++++++++++----------------------------
> 
> --- linux-2.6.32-rc3.orig/drivers/hwmon/adm1029.c	2009-10-06 10:33:15.000000000 +0200
> +++ linux-2.6.32-rc3/drivers/hwmon/adm1029.c	2009-10-06 12:53:55.000000000 +0200
> @@ -301,59 +301,36 @@ static int adm1029_detect(struct i2c_cli
>  			  struct i2c_board_info *info)
>  {
>  	struct i2c_adapter *adapter = client->adapter;
> +	u8 man_id, chip_id, temp_devices_installed, nb_fan_support;
>  
>  	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
>  		return -ENODEV;
>  
> -	/* Now we do the detection and identification. A negative kind
> -	 * means that the driver was loaded with no force parameter
> -	 * (default), so we must both detect and identify the chip
> -	 * (actually there is only one possible kind of chip for now, adm1029).
> -	 * A zero kind means that the driver was loaded with the force
> -	 * parameter, the detection step shall be skipped. A positive kind
> -	 * means that the driver was loaded with the force parameter and a
> -	 * given kind of chip is requested, so both the detection and the
> -	 * identification steps are skipped. */
> -
> -	/* Default to an adm1029 if forced */
> -	if (kind = 0)
> -		kind = adm1029;
> -
>  	/* ADM1029 doesn't have CHIP ID, check just MAN ID
>  	 * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED,
>  	 * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values
>  	 * documented
>  	 */
>  
> -	if (kind <= 0) {	/* identification */
> -		u8 man_id, chip_id, temp_devices_installed, nb_fan_support;
> -
> -		man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID);
> -		chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID);
> -		temp_devices_installed = i2c_smbus_read_byte_data(client,
> +	man_id = i2c_smbus_read_byte_data(client, ADM1029_REG_MAN_ID);
> +	chip_id = i2c_smbus_read_byte_data(client, ADM1029_REG_CHIP_ID);
> +	temp_devices_installed = i2c_smbus_read_byte_data(client,
>  					ADM1029_REG_TEMP_DEVICES_INSTALLED);
> -		nb_fan_support = i2c_smbus_read_byte_data(client,
> +	nb_fan_support = i2c_smbus_read_byte_data(client,
>  						ADM1029_REG_NB_FAN_SUPPORT);
> -		/* 0x41 is Analog Devices */
> -		if (man_id = 0x41 && (temp_devices_installed & 0xf9) = 0x01
> -		    && nb_fan_support = 0x03) {
> -			if ((chip_id & 0xF0) = 0x00) {
> -				kind = adm1029;
> -			} else {
> -				/* There are no "official" CHIP ID, so actually
> -				 * we use Major/Minor revision for that */
> -				printk(KERN_INFO
> -				       "adm1029: Unknown major revision %x, "
> -				       "please let us know\n", chip_id);
> -			}
> -		}
> -
> -		if (kind <= 0) {	/* identification failed */
> -			pr_debug("adm1029: Unsupported chip (man_id=0x%02X, "
> -				 "chip_id=0x%02X)\n", man_id, chip_id);
> -			return -ENODEV;
> -		}
> +	/* 0x41 is Analog Devices */
> +	if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01
> +	    || nb_fan_support != 0x03)
> +		return -ENODEV;
> +
> +	if ((chip_id & 0xF0) != 0x00) {
> +		/* There are no "official" CHIP ID, so actually
> +		 * we use Major/Minor revision for that */
> +		pr_info("adm1029: Unknown major revision %x, "
> +			"please let us know\n", chip_id);
> +		return -ENODEV;
>  	}
> +
>  	strlcpy(info->type, "adm1029", I2C_NAME_SIZE);
>  
>  	return 0;

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

      parent reply	other threads:[~2009-10-20 14:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-06 18:13 [lm-sensors] [PATCH] hwmon: Clean up detect functions Jean Delvare
2009-10-06 18:27 ` Hans J. Koch
2009-10-20 14:26 ` corentin.labbe [this message]

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=4ADDC894.7070807@geomatys.fr \
    --to=corentin.labbe@geomatys.fr \
    --cc=lm-sensors@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
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.