diff mbox

[1/2] si2168: return error if set_frontend is called with invalid parameters

Message ID 1421411720-2364-1-git-send-email-olli.salonen@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Olli Salonen Jan. 16, 2015, 12:35 p.m. UTC
This patch should is based on Antti's silabs branch.

According to dvb-frontend.h set_frontend may be called with bandwidth_hz set to 0 if automatic bandwidth is required. Si2168 does not support automatic bandwidth and does not declare FE_CAN_BANDWIDTH_AUTO in caps.

This patch will change the behaviour in a way that EINVAL is returned if bandwidth_hz is 0.

Cc-to: Antti Palosaari <crope@iki.fi>
Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/dvb-frontends/si2168.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Antti Palosaari Jan. 16, 2015, 2:22 p.m. UTC | #1
On 01/16/2015 02:35 PM, Olli Salonen wrote:
> This patch should is based on Antti's silabs branch.
>
> According to dvb-frontend.h set_frontend may be called with bandwidth_hz set to 0 if automatic bandwidth is required. Si2168 does not support automatic bandwidth and does not declare FE_CAN_BANDWIDTH_AUTO in caps.
>
> This patch will change the behaviour in a way that EINVAL is returned if bandwidth_hz is 0.
>
> Cc-to: Antti Palosaari <crope@iki.fi>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>

Reviewed-by: Antti Palosaari <crope@iki.fi>

Antti


> ---
>   drivers/media/dvb-frontends/si2168.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
> index 7f966f3..7fef5ab 100644
> --- a/drivers/media/dvb-frontends/si2168.c
> +++ b/drivers/media/dvb-frontends/si2168.c
> @@ -180,7 +180,12 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
>   		goto err;
>   	}
>
> -	if (c->bandwidth_hz <= 5000000)
> +	if (c->bandwidth_hz == 0) {
> +		ret = -EINVAL;
> +		dev_err(&client->dev, "automatic bandwidth not supported");
> +		goto err;
> +	}
> +	else if (c->bandwidth_hz <= 5000000)
>   		bandwidth = 0x05;
>   	else if (c->bandwidth_hz <= 6000000)
>   		bandwidth = 0x06;
>
Lad, Prabhakar Jan. 16, 2015, 2:31 p.m. UTC | #2
Hi Olli,

Thanks for the patch.

On Fri, Jan 16, 2015 at 12:35 PM, Olli Salonen <olli.salonen@iki.fi> wrote:
> This patch should is based on Antti's silabs branch.
>
> According to dvb-frontend.h set_frontend may be called with bandwidth_hz set to 0 if automatic bandwidth is required. Si2168 does not support automatic bandwidth and does not declare FE_CAN_BANDWIDTH_AUTO in caps.
>
> This patch will change the behaviour in a way that EINVAL is returned if bandwidth_hz is 0.
>
> Cc-to: Antti Palosaari <crope@iki.fi>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>  drivers/media/dvb-frontends/si2168.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
> index 7f966f3..7fef5ab 100644
> --- a/drivers/media/dvb-frontends/si2168.c
> +++ b/drivers/media/dvb-frontends/si2168.c
> @@ -180,7 +180,12 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
>                 goto err;
>         }
>
> -       if (c->bandwidth_hz <= 5000000)
> +       if (c->bandwidth_hz == 0) {
> +               ret = -EINVAL;
> +               dev_err(&client->dev, "automatic bandwidth not supported");
> +               goto err;
> +       }
> +       else if (c->bandwidth_hz <= 5000000)
>                 bandwidth = 0x05;

Checkpatch should catch it. did you run checkpatch ?

Thanks,
--Prabhakar Lad
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 7f966f3..7fef5ab 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -180,7 +180,12 @@  static int si2168_set_frontend(struct dvb_frontend *fe)
 		goto err;
 	}
 
-	if (c->bandwidth_hz <= 5000000)
+	if (c->bandwidth_hz == 0) {
+		ret = -EINVAL;
+		dev_err(&client->dev, "automatic bandwidth not supported");
+		goto err;
+	}
+	else if (c->bandwidth_hz <= 5000000)
 		bandwidth = 0x05;
 	else if (c->bandwidth_hz <= 6000000)
 		bandwidth = 0x06;