Skip to content

Commit

Permalink
Merge tag 'iio-fixes-for-3.16b' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/jic23/iio into staging-linus

Jonathan writes:

Second set of IIO fixes for the 3.16 cycle.

* A fix for a bug in setting threshold levels within the ad799x driver
  which prevents correct setting of the thresholds.
* In ad7291 fix an case where a ERR_PTR value was returned directly
  instead of having PTR_ERR applied.  Hence it would report success
  instead of failure.
* of_iio_channel_get_by_name returned a non null pointer if it fails
  and the callee was expecting NULL to indicate failure.  Fixed by
  returning NULL in the error cases.
  • Loading branch information
Greg Kroah-Hartman committed Jun 29, 2014
2 parents ff4f58f + a2c1249 commit 6b64168
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions drivers/iio/adc/ad799x.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,12 @@ static int ad799x_write_event_value(struct iio_dev *indio_dev,
int ret;
struct ad799x_state *st = iio_priv(indio_dev);

if (val < 0 || val > RES_MASK(chan->scan_type.realbits))
return -EINVAL;

mutex_lock(&indio_dev->mlock);
ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info),
val);
val << chan->scan_type.shift);
mutex_unlock(&indio_dev->mlock);

return ret;
Expand All @@ -452,7 +455,8 @@ static int ad799x_read_event_value(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
if (ret < 0)
return ret;
*val = valin;
*val = (valin >> chan->scan_type.shift) &
RES_MASK(chan->scan_type.realbits);

return IIO_VAL_INT;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/iio/inkern.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
else if (name && index >= 0) {
pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
np->full_name, name ? name : "", index);
return chan;
return NULL;
}

/*
Expand All @@ -193,8 +193,9 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
*/
np = np->parent;
if (np && !of_get_property(np, "io-channel-ranges", NULL))
break;
return NULL;
}

return chan;
}

Expand Down Expand Up @@ -317,6 +318,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
if (channel != NULL)
return channel;
}

return iio_channel_get_sys(name, channel_name);
}
EXPORT_SYMBOL_GPL(iio_channel_get);
Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/iio/adc/ad7291.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static int ad7291_probe(struct i2c_client *client,
struct ad7291_platform_data *pdata = client->dev.platform_data;
struct ad7291_chip_info *chip;
struct iio_dev *indio_dev;
int ret = 0;
int ret;

indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
if (!indio_dev)
Expand All @@ -475,7 +475,7 @@ static int ad7291_probe(struct i2c_client *client,
if (pdata && pdata->use_external_ref) {
chip->reg = devm_regulator_get(&client->dev, "vref");
if (IS_ERR(chip->reg))
return ret;
return PTR_ERR(chip->reg);

ret = regulator_enable(chip->reg);
if (ret)
Expand Down

0 comments on commit 6b64168

Please sign in to comment.