Pull staging driver bugfixes from Greg KH: "Nothing major here, just 4 small bugfixes that resolve some issues reported for the IIO (staging and non-staging) and the tidspbridge driver" * tag 'staging-3.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: tidspbridge: fix an erroneous removal of parentheses iio: of_iio_channel_get_by_name() returns non-null pointers for error legs staging: iio/ad7291: fix error code in ad7291_probe() iio:adc:ad799x: Fix reading and writing of event values, apply shift
Unified · Split
| @@ -427,9 +427,12 @@ static int ad799x_write_event_value(struct iio_dev *indio_dev, · 426 unmodified lines | ||
| 427 | 427 | int ret; |
| 428 | 428 | struct ad799x_state *st = iio_priv(indio_dev); |
| 429 | 429 | |
| 430 | + if (val < 0 || val > RES_MASK(chan->scan_type.realbits)) | |
| 431 | + return -EINVAL; | |
| 432 | + | |
| 430 | 433 | mutex_lock(&indio_dev->mlock); |
| 431 | 434 | ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info), |
| 432 | − val); | |
| 435 | + val << chan->scan_type.shift); | |
| 433 | 436 | mutex_unlock(&indio_dev->mlock); |
| 434 | 437 | |
| 435 | 438 | return ret; |
| @@ -452,7 +455,8 @@ static int ad799x_read_event_value(struct iio_dev *indio_dev, · 16 unmodified lines | ||
| 452 | 455 | mutex_unlock(&indio_dev->mlock); |
| 453 | 456 | if (ret < 0) |
| 454 | 457 | return ret; |
| 455 | − *val = valin; | |
| 458 | + *val = (valin >> chan->scan_type.shift) & | |
| 459 | + RES_MASK(chan->scan_type.realbits); | |
| 456 | 460 | |
| 457 | 461 | return IIO_VAL_INT; |
| 458 | 462 | } |
| @@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, · 182 unmodified lines | ||
| 183 | 183 | else if (name && index >= 0) { |
| 184 | 184 | pr_err("ERROR: could not get IIO channel %s:%s(%i)\n", |
| 185 | 185 | np->full_name, name ? name : "", index); |
| 186 | − return chan; | |
| 186 | + return NULL; | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /* |
| @@ -193,8 +193,9 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, · 3 unmodified lines | ||
| 193 | 193 | */ |
| 194 | 194 | np = np->parent; |
| 195 | 195 | if (np && !of_get_property(np, "io-channel-ranges", NULL)) |
| 196 | − break; | |
| 196 | + return NULL; | |
| 197 | 197 | } |
| 198 | + | |
| 198 | 199 | return chan; |
| 199 | 200 | } |
| 200 | 201 | |
| @@ -317,6 +318,7 @@ struct iio_channel *iio_channel_get(struct device *dev, · 116 unmodified lines | ||
| 317 | 318 | if (channel != NULL) |
| 318 | 319 | return channel; |
| 319 | 320 | } |
| 321 | + | |
| 320 | 322 | return iio_channel_get_sys(name, channel_name); |
| 321 | 323 | } |
| 322 | 324 | EXPORT_SYMBOL_GPL(iio_channel_get); |
| @@ -465,7 +465,7 @@ static int ad7291_probe(struct i2c_client *client, · 464 unmodified lines | ||
| 465 | 465 | struct ad7291_platform_data *pdata = client->dev.platform_data; |
| 466 | 466 | struct ad7291_chip_info *chip; |
| 467 | 467 | struct iio_dev *indio_dev; |
| 468 | − int ret = 0; | |
| 468 | + int ret; | |
| 469 | 469 | |
| 470 | 470 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); |
| 471 | 471 | if (!indio_dev) |
| @@ -475,7 +475,7 @@ static int ad7291_probe(struct i2c_client *client, · 3 unmodified lines | ||
| 475 | 475 | if (pdata && pdata->use_external_ref) { |
| 476 | 476 | chip->reg = devm_regulator_get(&client->dev, "vref"); |
| 477 | 477 | if (IS_ERR(chip->reg)) |
| 478 | − return ret; | |
| 478 | + return PTR_ERR(chip->reg); | |
| 479 | 479 | |
| 480 | 480 | ret = regulator_enable(chip->reg); |
| 481 | 481 | if (ret) |
| @@ -280,8 +280,10 @@ static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt) · 279 unmodified lines | ||
| 280 | 280 | OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL); |
| 281 | 281 | |
| 282 | 282 | /* Wait until the state has moved to ON */ |
| 283 | − while (*pdata->dsp_prm_read(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST)& | |
| 284 | − OMAP_INTRANSITION_MASK); | |
| 283 | + while ((*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, | |
| 284 | + OMAP2_PM_PWSTST) & | |
| 285 | + OMAP_INTRANSITION_MASK) | |
| 286 | + ; | |
| 285 | 287 | /* Disable Automatic transition */ |
| 286 | 288 | (*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_DISABLE_AUTO, |
| 287 | 289 | OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL); |