Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 317194
b: refs/heads/master
c: 26628f6
h: refs/heads/master
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Jun 5, 2012
1 parent 8c2a739 commit 702fcf8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 45 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5212cc8a9d833791a7aec566db136e78951f203d
refs/heads/master: 26628f6b53d1ae3610146607c0c7fcbaf403bee7
65 changes: 21 additions & 44 deletions trunk/drivers/staging/iio/dac/ad5064.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,57 +136,42 @@ static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
return ret;
}

static const char ad5064_powerdown_modes[][15] = {
[AD5064_LDAC_PWRDN_NONE] = "",
[AD5064_LDAC_PWRDN_1K] = "1kohm_to_gnd",
[AD5064_LDAC_PWRDN_100K] = "100kohm_to_gnd",
[AD5064_LDAC_PWRDN_3STATE] = "three_state",
static const char * const ad5064_powerdown_modes[] = {
"1kohm_to_gnd",
"100kohm_to_gnd",
"three_state",
};

static ssize_t ad5064_read_powerdown_mode_available(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
{
return sprintf(buf, "%s %s %s\n", ad5064_powerdown_modes[1],
ad5064_powerdown_modes[2], ad5064_powerdown_modes[3]);
}

static ssize_t ad5064_read_powerdown_mode(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
static int ad5064_get_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{
struct ad5064_state *st = iio_priv(indio_dev);

return sprintf(buf, "%s\n",
ad5064_powerdown_modes[st->pwr_down_mode[chan->channel]]);
return st->pwr_down_mode[chan->channel] - 1;
}

static ssize_t ad5064_write_powerdown_mode(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
size_t len)
static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, unsigned int mode)
{
struct ad5064_state *st = iio_priv(indio_dev);
unsigned int mode, i;
int ret;

mode = 0;

for (i = 1; i < ARRAY_SIZE(ad5064_powerdown_modes); ++i) {
if (sysfs_streq(buf, ad5064_powerdown_modes[i])) {
mode = i;
break;
}
}
if (mode == 0)
return -EINVAL;

mutex_lock(&indio_dev->mlock);
st->pwr_down_mode[chan->channel] = mode;
st->pwr_down_mode[chan->channel] = mode + 1;

ret = ad5064_sync_powerdown_mode(st, chan->channel);
mutex_unlock(&indio_dev->mlock);

return ret ? ret : len;
return ret;
}

static const struct iio_enum ad5064_powerdown_mode_enum = {
.items = ad5064_powerdown_modes,
.num_items = ARRAY_SIZE(ad5064_powerdown_modes),
.get = ad5064_get_powerdown_mode,
.set = ad5064_set_powerdown_mode,
};

static ssize_t ad5064_read_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
{
Expand Down Expand Up @@ -286,22 +271,14 @@ static const struct iio_info ad5064_info = {
.driver_module = THIS_MODULE,
};

static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
{
.name = "powerdown",
.read = ad5064_read_dac_powerdown,
.write = ad5064_write_dac_powerdown,
},
{
.name = "powerdown_mode",
.read = ad5064_read_powerdown_mode,
.write = ad5064_write_powerdown_mode,
},
{
.name = "powerdown_mode_available",
.shared = true,
.read = ad5064_read_powerdown_mode_available,
},
IIO_ENUM("powerdown_mode", false, &ad5064_powerdown_mode_enum),
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5064_powerdown_mode_enum),
{ },
};

Expand Down

0 comments on commit 702fcf8

Please sign in to comment.