staging:iio:dds:ad9834 unwind use of is_visible for attrs.

Trivial usecase in which just having two different attr
groups covers all options.  Slightly more code, but a simpler
to follow result.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jonathan Cameron 2012-01-29 11:07:01 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель 15bbb7793a
Коммит b2c04a34aa
1 изменённых файлов: 32 добавлений и 21 удалений

Просмотреть файл

@ -281,29 +281,27 @@ static struct attribute *ad9834_attributes[] = {
NULL, NULL,
}; };
static umode_t ad9834_attr_is_visible(struct kobject *kobj, static struct attribute *ad9833_attributes[] = {
struct attribute *attr, int n) &iio_dev_attr_dds0_freq0.dev_attr.attr,
{ &iio_dev_attr_dds0_freq1.dev_attr.attr,
struct device *dev = container_of(kobj, struct device, kobj); &iio_const_attr_dds0_freq_scale.dev_attr.attr,
struct iio_dev *indio_dev = dev_get_drvdata(dev); &iio_dev_attr_dds0_phase0.dev_attr.attr,
struct ad9834_state *st = iio_priv(indio_dev); &iio_dev_attr_dds0_phase1.dev_attr.attr,
&iio_const_attr_dds0_phase_scale.dev_attr.attr,
umode_t mode = attr->mode; &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
&iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
if (((st->devid == ID_AD9833) || (st->devid == ID_AD9837)) && &iio_dev_attr_dds0_out_enable.dev_attr.attr,
((attr == &iio_dev_attr_dds0_out1_enable.dev_attr.attr) || &iio_dev_attr_dds0_out0_wavetype.dev_attr.attr,
(attr == &iio_dev_attr_dds0_out1_wavetype.dev_attr.attr) || &iio_dev_attr_dds0_out0_wavetype_available.dev_attr.attr,
(attr == NULL,
&iio_dev_attr_dds0_out1_wavetype_available.dev_attr.attr) || };
(attr == &iio_dev_attr_dds0_pincontrol_en.dev_attr.attr)))
mode = 0;
return mode;
}
static const struct attribute_group ad9834_attribute_group = { static const struct attribute_group ad9834_attribute_group = {
.attrs = ad9834_attributes, .attrs = ad9834_attributes,
.is_visible = ad9834_attr_is_visible, };
static const struct attribute_group ad9833_attribute_group = {
.attrs = ad9833_attributes,
}; };
static const struct iio_info ad9834_info = { static const struct iio_info ad9834_info = {
@ -311,6 +309,11 @@ static const struct iio_info ad9834_info = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
}; };
static const struct iio_info ad9833_info = {
.attrs = &ad9833_attribute_group,
.driver_module = THIS_MODULE,
};
static int __devinit ad9834_probe(struct spi_device *spi) static int __devinit ad9834_probe(struct spi_device *spi)
{ {
struct ad9834_platform_data *pdata = spi->dev.platform_data; struct ad9834_platform_data *pdata = spi->dev.platform_data;
@ -344,7 +347,15 @@ static int __devinit ad9834_probe(struct spi_device *spi)
st->reg = reg; st->reg = reg;
indio_dev->dev.parent = &spi->dev; indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name; indio_dev->name = spi_get_device_id(spi)->name;
switch (st->devid) {
case ID_AD9833:
case ID_AD9837:
indio_dev->info = &ad9833_info;
break;
default:
indio_dev->info = &ad9834_info; indio_dev->info = &ad9834_info;
break;
}
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
/* Setup default messages */ /* Setup default messages */