iio: core: add char type for sysfs attributes
authorAndrea Merello <andrea.merello@gmail.com>
Wed, 20 Nov 2019 14:47:51 +0000 (15:47 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 23 Nov 2019 12:33:07 +0000 (12:33 +0000)
commit8cb3403633146afe1ba81f79224679f5df2940d4
treec9ebfe584e1e769c5615579a272a9fbd68cee373
parent57a4274ce168d4e63a7b5f4a8a776f7bdd5666a9
iio: core: add char type for sysfs attributes

This patch introduces IIO_VAL_CHAR type for standard IIO attributes to
allow for attributes that needs to be represented by character rather
than a number. This is preparatory for introducing a new attribute whose
purpose is to describe thermocouple type, that can be i.e. "J", "K", etc..

The char-type value is stored in the first "value" integer that is passed
to the .[read/write]_raw() callbacks.

Note that in order to make it possible for the IIO core to correctly parse
this type (actually, to avoid integer parsing), it became mandatory for
any driver that wish to use IIO_VAL_CHAR on a writable attribute to
implement .write_raw_get_fmt().

Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: Patrick Havelange <patrick.havelange@essensium.com>
Cc: Matt Weber <matthew.weber@rockwellcollins.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: Chuhong Yuan <hslester96@gmail.com>
Cc: Daniel Gomez <dagmcr@gmail.com>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-core.c
include/linux/iio/types.h