Re: [PATCH v7 4/5] iio: mcp9600: Recognize chip id for mcp9601
From: Ben Collins
Date: Wed Aug 20 2025 - 07:26:58 EST
> On Aug 20, 2025, at 7:11 AM, Ben Collins <bcollins@xxxxxxxxxx> wrote:
>
>>
>> On Aug 20, 2025, at 6:07 AM, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
>>
>> On Wed, Aug 20, 2025 at 2:45 AM Ben Collins <bcollins@xxxxxxxxxx> wrote:
>>>
>>> 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.
>>>
>>> Moved "struct mcp9600_data" up in the file since a later patch will
>>> need it and chip_info before the declerations.
>>
>> declarations
>>
>> ...
>>
>>> +struct mcp9600_data {
>>> + struct i2c_client *client;
>>> +};
>>> +
>>> #define MCP9600_CHANNELS(hj_num_ev, hj_ev_spec_off, cj_num_ev, cj_ev_spec_off) \
>>> { \
>>> { \
>>> @@ -123,10 +133,6 @@ static const struct iio_chan_spec mcp9600_channels[][2] = {
>>> MCP9600_CHANNELS(2, 0, 2, 0), /* Alerts: 1 2 3 4 */
>>> };
>>>
>>> -struct mcp9600_data {
>>> - struct i2c_client *client;
>>> -};
>>> -
>>
>> It's not obvious why this piece of change is needed. AFAICS it's a stray change.
>
> The explanation is in the changelog above. A follow up patch needs both struct
> declarations to be where I added one and moved mcp9600_data to. It’s just ordering
> so I don’t later have to forward declare new functions for filter_type, which make
> use of these structs, but need to be in the iio_chan_spec mcp9600_channels[]
> declaration.
>
> I guess I could move mcp9600_data in that series, but I had this in here before
> I split that series out, and it seemed simple enough to leave in.
Correction, patch 5/5 needs it. Either I move it in 4/5 (cleaner since I was
already adding a new related struct), or in 5/5, or a longer reorg to include
moving that struct and mcp9600_config() in the mcp9600-iir series.