Skip to content

Commit

Permalink
iio: core: iio_chan_spec_ext_info: Add private handle
Browse files Browse the repository at this point in the history
There is currently no user, but we might need it in future.
So better add it now, before we have to convert drivers afterwards.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Michael Hennerich authored and Greg Kroah-Hartman committed Apr 30, 2012
1 parent 73e016e commit fc6d113
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static ssize_t iio_read_channel_ext_info(struct device *dev,

ext_info = &this_attr->c->ext_info[this_attr->address];

return ext_info->read(indio_dev, this_attr->c, buf);
return ext_info->read(indio_dev, ext_info->private, this_attr->c, buf);
}

static ssize_t iio_write_channel_ext_info(struct device *dev,
Expand All @@ -295,7 +295,8 @@ static ssize_t iio_write_channel_ext_info(struct device *dev,

ext_info = &this_attr->c->ext_info[this_attr->address];

return ext_info->write(indio_dev, this_attr->c, buf, len);
return ext_info->write(indio_dev, ext_info->private,
this_attr->c, buf, len);
}

static ssize_t iio_read_channel_info(struct device *dev,
Expand Down
12 changes: 7 additions & 5 deletions drivers/staging/iio/dac/ad5064.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ static const char ad5064_powerdown_modes[][15] = {
};

static ssize_t ad5064_read_powerdown_mode_available(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, char *buf)
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,
const struct iio_chan_spec *chan, char *buf)
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
{
struct ad5064_state *st = iio_priv(indio_dev);

Expand All @@ -160,7 +160,8 @@ static ssize_t ad5064_read_powerdown_mode(struct iio_dev *indio_dev,
}

static ssize_t ad5064_write_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, const char *buf, size_t len)
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
size_t len)
{
struct ad5064_state *st = iio_priv(indio_dev);
unsigned int mode, i;
Expand All @@ -187,15 +188,16 @@ static ssize_t ad5064_write_powerdown_mode(struct iio_dev *indio_dev,
}

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

return sprintf(buf, "%d\n", st->pwr_down[chan->channel]);
}

static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, const char *buf, size_t len)
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
size_t len)
{
struct ad5064_state *st = iio_priv(indio_dev);
bool pwr_down;
Expand Down
6 changes: 5 additions & 1 deletion drivers/staging/iio/dac/ad5446.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ static const char * const ad5446_powerdown_modes[] = {
};

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

static ssize_t ad5446_write_powerdown_mode(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
const char *buf, size_t len)
{
Expand All @@ -73,6 +74,7 @@ static ssize_t ad5446_write_powerdown_mode(struct iio_dev *indio_dev,
}

static ssize_t ad5446_read_powerdown_mode(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{
Expand All @@ -82,6 +84,7 @@ static ssize_t ad5446_read_powerdown_mode(struct iio_dev *indio_dev,
}

static ssize_t ad5446_read_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{
Expand All @@ -91,6 +94,7 @@ static ssize_t ad5446_read_dac_powerdown(struct iio_dev *indio_dev,
}

static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
const char *buf, size_t len)
{
Expand Down
11 changes: 7 additions & 4 deletions include/linux/iio/iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ struct iio_dev;
* @shared: Whether this attribute is shared between all channels.
* @read: Read callback for this info attribute, may be NULL.
* @write: Write callback for this info attribute, may be NULL.
* @private: Data private to the driver.
*/
struct iio_chan_spec_ext_info {
const char *name;
bool shared;
ssize_t (*read)(struct iio_dev *, struct iio_chan_spec const *,
char *buf);
ssize_t (*write)(struct iio_dev *, struct iio_chan_spec const *,
const char *buf, size_t len);
ssize_t (*read)(struct iio_dev *, uintptr_t private,
struct iio_chan_spec const *, char *buf);
ssize_t (*write)(struct iio_dev *, uintptr_t private,
struct iio_chan_spec const *, const char *buf,
size_t len);
uintptr_t private;
};

/**
Expand Down

0 comments on commit fc6d113

Please sign in to comment.