Message ID | 20200731104555.v3.3.Idbfcd2e92d2fd89b6ed2e83211bd3e6c06852c33@changeid (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | sx9310 iio driver updates | expand |
Quoting Daniel Campello (2020-07-31 09:48:40) > 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> > --- Reviewed-by: Stephen Boyd <swboyd@chromium.org>
On Fri, Jul 31, 2020 at 7:49 PM Daniel Campello <campello@chromium.org> wrote: > > Fixes enable/disable irq handling at various points. The driver needs to > only enable/disable irqs if there is an actual irq handler installed. ... > static int sx9310_enable_irq(struct sx9310_data *data, unsigned int irq) > { > - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, irq); > + if (data->client->irq) > + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, > + irq); > + return 0; Wouldn't it be better to insert rather if (!irq) return 0; than disrupting the entire function? > } > > static int sx9310_disable_irq(struct sx9310_data *data, unsigned int irq) > { > - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, 0); > + if (data->client->irq) > + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, > + 0); > + return 0; Ditto. > }
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 07895d4b935d12..c7a27c21c20cd1 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -323,12 +323,18 @@ static int sx9310_put_event_channel(struct sx9310_data *data, int channel) static int sx9310_enable_irq(struct sx9310_data *data, unsigned int irq) { - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, irq); + if (data->client->irq) + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, + irq); + return 0; } static int sx9310_disable_irq(struct sx9310_data *data, unsigned int irq) { - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, 0); + if (data->client->irq) + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, + 0); + return 0; } static int sx9310_read_prox_data(struct sx9310_data *data, @@ -382,7 +388,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, 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 { @@ -1011,10 +1017,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 v3: - Moved irq presence check down to lower methods Changes in v2: - Reordered error handling on sx9310_resume() drivers/iio/proximity/sx9310.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)