Message ID | 20200728170317.v2.3.Idbfcd2e92d2fd89b6ed2e83211bd3e6c06852c33@changeid (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | sx9310 iio driver updates | expand |
Quoting Daniel Campello (2020-07-28 16:05:09) > Fixes enable/disable irq handling at various points. The driver needs to > only enable/disable irqs if there is an actual irq handler installed. > > Signed-off-by: Daniel Campello <campello@chromium.org> > --- > > Changes in v2: > - Reordered error handling on sx9310_resume() > > drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) > > diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c > index 07895d4b935d12..108d82ba81146e 100644 > --- a/drivers/iio/proximity/sx9310.c > +++ b/drivers/iio/proximity/sx9310.c > @@ -376,13 +376,15 @@ static int sx9310_read_proximity(struct sx9310_data *data, > if (ret < 0) > goto out; > > - ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); > - if (ret < 0) > - goto out_put_channel; > + if (data->client->irq) { > + ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); I still think it makes more sense to push the if condition inside the enable/disable irq functions so that the call sites read simpler. > + if (ret) > + goto out_put_channel; > + } > > mutex_unlock(&data->mutex); > > - if (data->client->irq > 0) { > + if (data->client->irq) { > ret = wait_for_completion_interruptible(&data->completion); > reinit_completion(&data->completion); > } else { > @@ -401,9 +403,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, > *val = sign_extend32(be16_to_cpu(rawval), > (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); > > - ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); > - if (ret < 0) > - goto out_put_channel; > + if (data->client->irq) { > + ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); > + if (ret) > + goto out_put_channel; > + } > > ret = sx9310_put_read_channel(data, chan->channel); > if (ret < 0) > @@ -414,7 +418,8 @@ static int sx9310_read_proximity(struct sx9310_data *data, > return IIO_VAL_INT; > > out_disable_irq: > - sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); > + if (data->client->irq) > + sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); And so this isn't duplicated check. > out_put_channel: > sx9310_put_read_channel(data, chan->channel); > out:
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 07895d4b935d12..108d82ba81146e 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -376,13 +376,15 @@ static int sx9310_read_proximity(struct sx9310_data *data, if (ret < 0) goto out; - ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } mutex_unlock(&data->mutex); - if (data->client->irq > 0) { + if (data->client->irq) { ret = wait_for_completion_interruptible(&data->completion); reinit_completion(&data->completion); } else { @@ -401,9 +403,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, *val = sign_extend32(be16_to_cpu(rawval), (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); - ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } ret = sx9310_put_read_channel(data, chan->channel); if (ret < 0) @@ -414,7 +418,8 @@ static int sx9310_read_proximity(struct sx9310_data *data, return IIO_VAL_INT; out_disable_irq: - sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (data->client->irq) + sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); out_put_channel: sx9310_put_read_channel(data, chan->channel); out: @@ -1011,10 +1016,11 @@ static int __maybe_unused sx9310_resume(struct device *dev) out: mutex_unlock(&data->mutex); + if (ret) + return ret; enable_irq(data->client->irq); - - return ret; + return 0; } static const struct dev_pm_ops sx9310_pm_ops = {
Fixes enable/disable irq handling at various points. The driver needs to only enable/disable irqs if there is an actual irq handler installed. Signed-off-by: Daniel Campello <campello@chromium.org> --- Changes in v2: - Reordered error handling on sx9310_resume() drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)