Re: [PATCH] mcp23s08: support mcp23s17 variant

From: Peter Korsgaard
Date: Mon Feb 14 2011 - 13:29:59 EST


>>>>> "Grant" == Grant Likely <grant.likely@xxxxxxxxxxxx> writes:

Hi,

>> - Â Â Â return (status < 0) ? status : rx[0];
>> +
>> + Â Â Â if (mcp->type == MCP_TYPE_S17) {
>> + Â Â Â Â Â Â Â tx[1] <<= 1;
>> +
>> + Â Â Â Â Â Â Â status = spi_write_then_read(mcp->spi, tx, sizeof tx, rx, 2);
>> + Â Â Â Â Â Â Â return (status < 0) ? status : (rx[0] | (rx[1] << 8));
>> + Â Â Â } else {
>> + Â Â Â Â Â Â Â status = spi_write_then_read(mcp->spi, tx, sizeof tx, rx, 1);
>> + Â Â Â Â Â Â Â return (status < 0) ? status : rx[0];
>> + Â Â Â }

Grant> Rather than checking ->type for every transaction, would a set of
Grant> callbacks for each type be better? It would probably have lower
Grant> overhead and be simpler to maintain.

We could. I didn't do it because the 8bit and 16bit cases are very
similar, and checking a simple integer is presumably a lot faster than
the spi access - But I can rework the patch if you insists.

>> +++ b/include/linux/spi/mcp23s08.h
>> @@ -2,21 +2,24 @@
>> Â/* FIXME driver should be able to handle IRQs... Â*/
>>
>> Âstruct mcp23s08_chip_info {
>> -    bool  Âis_present;       /* true iff populated */
>> - Â Â Â u8 Â Â Âpullups; Â Â Â Â Â Â Â Â/* BIT(x) means enable pullup x */
>> +    bool      Âis_present;   /* true if populated */
>> +    unsigned    Âpullups;    Â/* BIT(x) means enable pullup x */
>> Â};

Grant> Unrelated whitespace changes.

I wouldn't call it unrelated. It's to ensure it still lines up after the
s/u8/unsigned/.

--
Bye, Peter Korsgaard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/