Re: [PATCH v5] iio: temperature: add support for Maxim thermocouple chips

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 1, 2016 at 3:55 AM, Marek Vasut <marex@xxxxxxx> wrote:
> On 07/01/2016 04:52 AM, Matt Ranostay wrote:
>> Add initial driver support for MAX6675, and MAX31855 thermocouple chips.
>>
>> Cc: Marek Vasut <marex@xxxxxxx>
>> Cc: Matt Porter <mporter@xxxxxxxxxxxx>
>> Signed-off-by: Matt Ranostay <mranostay@xxxxxxxxx>
>> ---
>>
>> Changes from v1:
>> * switch to iio_device_*_direct_mode wrappers
>> * add const to structs
>> * removed useless cast
>>
>> Changes from v2:
>> * mark buffer data invalid on disconnected thermocouple
>> * add .address = 0 to be consistent
>> * add missing scan_mask for the max31855 part
>>
>> Changes from v3:
>> * fixed several typos of max31855 part number
>>
>> Changes from v4:
>> * drop maxim_thermocouple_validate_buffer() due to peer review saying
>>   this is an incorrect way to signal an invalid reading
>
> [...]
>
>> +const struct iio_chan_spec max31855_channels[] = {
>> +     {       /* thermocouple temperature */
>> +             .type = IIO_TEMP,
>> +             .address = 2,
>> +             .info_mask_separate =
>> +                     BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> +             .scan_index = 0,
>> +             .scan_type = {
>> +                     .sign = 's',
>> +                     .realbits = 14,
>> +                     .storagebits = 16,
>> +                     .shift = 2,
>> +                     .endianness = IIO_BE,
>> +             },
>> +     },
>> +     {       /* cold junction temperature */
>> +             .type = IIO_TEMP,
>> +             .address = 0,
>> +             .channel2 = IIO_MOD_TEMP_AMBIENT,
>> +             .modified = 1,
>> +             .info_mask_separate =
>> +                     BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> +             .scan_index = 1,
>> +             .scan_type = {
>> +                     .sign = 's',
>> +                     .realbits = 12,
>> +                     .storagebits = 16,
>> +                     .shift = 4,
>> +                     .endianness = IIO_BE,
>> +             },
>> +     },
>> +     IIO_CHAN_SOFT_TIMESTAMP(2),
>> +};
>> +
>> +static const unsigned long max31855_scan_masks[] = {0x3, 0};
>> +
>> +struct maxim_thermocouple_chip {
>> +     const struct iio_chan_spec *channels;
>> +     const unsigned long *scan_masks;
>> +     int num_channels;
>
> const u8 or u32 ?
>
>> +     int read_size;
>
> const u8

Ok not sure saving 2 or 4 bytes of memory really matters that much :).

>
>> +     /* bit-check for valid input */
>> +     int status_bit;
>
> const bool ?

It is a bitmask of a single bit for the validation. I guess it could
be const u32
>
> You can save some slop in here, see also:
> http://www.catb.org/esr/structure-packing/
>
>> +};
>> +
>> +const struct maxim_thermocouple_chip maxim_thermocouple_chips[] = {
>> +     [MAX6675] = {
>> +                     .channels = max6675_channels,
>> +                     .num_channels = ARRAY_SIZE(max6675_channels),
>> +                     .read_size = 2,
>> +                     .status_bit = BIT(2),
>> +             },
>> +     [MAX31855] = {
>> +                     .channels = max31855_channels,
>> +                     .num_channels = ARRAY_SIZE(max31855_channels),
>> +                     .read_size = 4,
>> +                     .scan_masks = max31855_scan_masks,
>> +                     .status_bit = BIT(16),
>> +             },
>> +};
> [...]
>
> --
> Best regards,
> Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux