Message ID | 20191114200408.28883-3-brad@nextdimension.cc (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | si2157: Analog tuning and optimizations | expand |
Hello, On 11/14/19 10:03 PM, Brad Love wrote: > Check error status bit on command execute, if error bit is > set return -EAGAIN. Ignore -EAGAIN in probe during device check. You should open when and why this error condition happens and try to fix things on first hand that error situation never appears. As you added that kind of special error handling to does it mean it happens during probe? If yes, then something must be wrong before probe is called. Also succeeding probe on "error again" does not sound very correct. Antti > > Signed-off-by: Brad Love <brad@nextdimension.cc> > --- > Since v2: > - Fix -EAGAIN returned by si2141 in si2157_init > > drivers/media/tuners/si2157.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c > index 12f88304ac0f..69c625eaee25 100644 > --- a/drivers/media/tuners/si2157.c > +++ b/drivers/media/tuners/si2157.c > @@ -47,14 +47,20 @@ static int si2157_cmd_execute(struct i2c_client *client, struct si2157_cmd *cmd) > break; > } > > - dev_dbg(&client->dev, "cmd execution took %d ms\n", > - jiffies_to_msecs(jiffies) - > - (jiffies_to_msecs(timeout) - TIMEOUT)); > + dev_dbg(&client->dev, "cmd execution took %d ms, status=%x\n", > + jiffies_to_msecs(jiffies) - > + (jiffies_to_msecs(timeout) - TIMEOUT), > + cmd->args[0]); > > if (!((cmd->args[0] >> 7) & 0x01)) { > ret = -ETIMEDOUT; > goto err_mutex_unlock; > } > + /* check error status bit */ > + if (cmd->args[0] & 0x40) { > + ret = -EAGAIN; > + goto err_mutex_unlock; > + } > } > > mutex_unlock(&dev->i2c_mutex); > @@ -106,7 +112,7 @@ static int si2157_init(struct dvb_frontend *fe) > } > cmd.rlen = 1; > ret = si2157_cmd_execute(client, &cmd); > - if (ret) > + if (ret && (dev->chiptype != SI2157_CHIPTYPE_SI2141 || ret != -EAGAIN)) > goto err; > > /* Si2141 needs a second command before it answers the revision query */ > @@ -478,7 +484,7 @@ static int si2157_probe(struct i2c_client *client, > cmd.wlen = 0; > cmd.rlen = 1; > ret = si2157_cmd_execute(client, &cmd); > - if (ret) > + if (ret && ret != -EAGAIN) > goto err_kfree; > > memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops)); >
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 12f88304ac0f..69c625eaee25 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -47,14 +47,20 @@ static int si2157_cmd_execute(struct i2c_client *client, struct si2157_cmd *cmd) break; } - dev_dbg(&client->dev, "cmd execution took %d ms\n", - jiffies_to_msecs(jiffies) - - (jiffies_to_msecs(timeout) - TIMEOUT)); + dev_dbg(&client->dev, "cmd execution took %d ms, status=%x\n", + jiffies_to_msecs(jiffies) - + (jiffies_to_msecs(timeout) - TIMEOUT), + cmd->args[0]); if (!((cmd->args[0] >> 7) & 0x01)) { ret = -ETIMEDOUT; goto err_mutex_unlock; } + /* check error status bit */ + if (cmd->args[0] & 0x40) { + ret = -EAGAIN; + goto err_mutex_unlock; + } } mutex_unlock(&dev->i2c_mutex); @@ -106,7 +112,7 @@ static int si2157_init(struct dvb_frontend *fe) } cmd.rlen = 1; ret = si2157_cmd_execute(client, &cmd); - if (ret) + if (ret && (dev->chiptype != SI2157_CHIPTYPE_SI2141 || ret != -EAGAIN)) goto err; /* Si2141 needs a second command before it answers the revision query */ @@ -478,7 +484,7 @@ static int si2157_probe(struct i2c_client *client, cmd.wlen = 0; cmd.rlen = 1; ret = si2157_cmd_execute(client, &cmd); - if (ret) + if (ret && ret != -EAGAIN) goto err_kfree; memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
Check error status bit on command execute, if error bit is set return -EAGAIN. Ignore -EAGAIN in probe during device check. Signed-off-by: Brad Love <brad@nextdimension.cc> --- Since v2: - Fix -EAGAIN returned by si2141 in si2157_init drivers/media/tuners/si2157.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)