mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
staging: iio: ad9834: use sysfs_emit() and simplify show functions
Replace sprintf() with sysfs_emit() in sysfs attribute show functions. sysfs_emit() is the preferred API for sysfs callbacks as it is aware of the PAGE_SIZE buffer limit. Also simplify the wavetype_available show functions by removing the intermediate string variable and returning directly from each branch. Signed-off-by: Gabriel Rondon <grondon@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
f619278080
commit
8a75ac8f0a
|
|
@ -281,16 +281,12 @@ ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
|
|||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad9834_state *st = iio_priv(indio_dev);
|
||||
char *str;
|
||||
|
||||
if (st->devid == ID_AD9833 || st->devid == ID_AD9837)
|
||||
str = "sine triangle square";
|
||||
else if (st->control & AD9834_OPBITEN)
|
||||
str = "sine";
|
||||
else
|
||||
str = "sine triangle";
|
||||
|
||||
return sprintf(buf, "%s\n", str);
|
||||
return sysfs_emit(buf, "sine triangle square\n");
|
||||
if (st->control & AD9834_OPBITEN)
|
||||
return sysfs_emit(buf, "sine\n");
|
||||
return sysfs_emit(buf, "sine triangle\n");
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, 0444,
|
||||
|
|
@ -303,14 +299,10 @@ ssize_t ad9834_show_out1_wavetype_available(struct device *dev,
|
|||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad9834_state *st = iio_priv(indio_dev);
|
||||
char *str;
|
||||
|
||||
if (st->control & AD9834_MODE)
|
||||
str = "";
|
||||
else
|
||||
str = "square";
|
||||
|
||||
return sprintf(buf, "%s\n", str);
|
||||
return sysfs_emit(buf, "\n");
|
||||
return sysfs_emit(buf, "square\n");
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_altvoltage0_out1_wavetype_available, 0444,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user