lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250818190325.23fd310c@jic23-huawei>
Date: Mon, 18 Aug 2025 19:03:25 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Ben Collins <bcollins@...nel.org>
Cc: David Lechner <dlechner@...libre.com>, Nuno Sá
 <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, Ben Collins
 <bcollins@...ter.com>, linux-iio@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 3/5] iio: mcp9600: Recognize chip id for mcp9601

On Sun, 17 Aug 2025 23:59:51 -0400
Ben Collins <bcollins@...nel.org> wrote:

> From: Ben Collins <bcollins@...ter.com>
> 
> The current driver works with mcp9601, but emits a warning because it
> does not recognize the chip id.
> 
> MCP9601 is a superset of MCP9600. The drivers works without changes
> on this chipset.
> 
> However, the 9601 chip supports open/closed-circuit detection if wired
> properly, so we'll need to be able to differentiate between them.
> 
> Signed-off-by: Ben Collins <bcollins@...ter.com>

Hi Ben

One minor thing inline that need fixing up.

> diff --git a/drivers/iio/temperature/mcp9600.c b/drivers/iio/temperature/mcp9600.c
> index 40906bb200ec9..54de38a39292e 100644
> --- a/drivers/iio/temperature/mcp9600.c
> +++ b/drivers/iio/temperature/mcp9600.c
> @@ -42,6 +42,7 @@

> @@ -416,16 +422,33 @@ static int mcp9600_probe_alerts(struct iio_dev *indio_dev)
>  
>  static int mcp9600_probe(struct i2c_client *client)
>  {
> +	const struct mcp_chip_info *chip_info = i2c_get_match_data(client);
>  	struct iio_dev *indio_dev;
>  	struct mcp9600_data *data;
> -	int ret, ch_sel;
> +	int ch_sel, dev_id, ret;
> +
> +	if (chip_info == NULL)
> +		return dev_err_probe(&client->dev, -EINVAL,
> +                                     "No chip-info found for device\n");

This line seems to be indented with spaces, not tabs then spaces which
is the coding style. I only noticed because of the shift seen in this reply.



> +
> +	dev_id = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID);
> +	if (dev_id < 0)
> +		return dev_err_probe(&client->dev, dev_id,
> +				     "Failed to read device ID\n");
> +
> +	switch (dev_id) {
> +	case MCP9600_DEVICE_ID_MCP9600:
> +	case MCP9600_DEVICE_ID_MCP9601:
> +		if (dev_id != chip_info->chip_id)
> +			dev_warn(&client->dev,
> +				 "Expected id %02x, but device responded with %02x\n",
> +				 chip_info->chip_id, dev_id);
> +		break;
>  
> -	ret = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID);
> -	if (ret < 0)
> -		return dev_err_probe(&client->dev, ret, "Failed to read device ID\n");
> -	if (ret != MCP9600_DEVICE_ID_MCP9600)
> -		dev_warn(&client->dev, "Expected ID %x, got %x\n",
> -				MCP9600_DEVICE_ID_MCP9600, ret);
> +	default:
> +		dev_warn(&client->dev, "Unknown id %x, using %x\n", dev_id,
> +			 chip_info->chip_id);
> +	}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ