Re: [PATCH 3/4] iio: mxs-lradc: add scale_available file to channels

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

 



On 07/05/2013 10:30 AM, Hector Palacios wrote:
[...]
> +#define SHOW_SCALE_AVAILABLE_FUNC(ch) 					\
> +static ssize_t mxs_lradc_show_scale_available##ch(struct device *dev,	\
> +		struct device_attribute *attr, 				\
> +		char *buf)						\
> +{ 									\
> +	return c ch);	\
> +}

No need for a separate function for each channel. Use the address attribute
of the iio_dev_attr. E.g.

struct iio_dev_attr *iio_attr = to_iio_dev_attr(attr);

return mxs_lradc_show_scale_available_ch(dev, attr, buf, iio_attr->address);

The last parameter to IIO_DEVICE_ATTR initializes this field.

But I think you can need less boilerplate code if you use the
iio_chan_spec_ext_info feature. Take a look at IIO_ENUM_AVAILABLE and
friends to see how it is done.

- Lars
--
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