diff mbox

[09/10] mn88472: check if firmware is already running before loading it

Message ID 1426460275-3766-9-git-send-email-benjamin@southpole.se (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Larsson March 15, 2015, 10:57 p.m. UTC
Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Comments

Antti Palosaari March 16, 2015, 9:45 p.m. UTC | #1
On 03/16/2015 12:57 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>

Applied! Please try to add some commit message, even patch topic says it 
all...

regards
Antti

> ---
>   drivers/staging/media/mn88472/mn88472.c | 21 ++++++++++++++++-----
>   1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index 4a00a4d..c041fbf 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -258,7 +258,7 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	int ret, len, remaining;
>   	const struct firmware *fw = NULL;
>   	u8 *fw_file = MN88472_FIRMWARE;
> -	unsigned int csum;
> +	unsigned int tmp;
>
>   	dev_dbg(&client->dev, "\n");
>
> @@ -274,6 +274,17 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	if (ret)
>   		goto err;
>
> +	/* check if firmware is already running */
> +	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
> +	if (ret)
> +		goto err;
> +
> +	if (!(tmp & 0x1)) {
> +		dev_info(&client->dev, "firmware already running\n");
> +		dev->warm = true;
> +		return 0;
> +	}
> +
>   	/* request the firmware, this will block and timeout */
>   	ret = request_firmware(&fw, fw_file, &client->dev);
>   	if (ret) {
> @@ -305,18 +316,18 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	}
>
>   	/* parity check of firmware */
> -	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
> +	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
>   	if (ret) {
>   		dev_err(&client->dev,
>   				"parity reg read failed=%d\n", ret);
>   		goto err;
>   	}
> -	if (csum & 0x10) {
> +	if (tmp & 0x10) {
>   		dev_err(&client->dev,
> -				"firmware parity check failed=0x%x\n", csum);
> +				"firmware parity check failed=0x%x\n", tmp);
>   		goto err;
>   	}
> -	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
> +	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
>
>   	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
>   	if (ret)
>
diff mbox

Patch

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index 4a00a4d..c041fbf 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -258,7 +258,7 @@  static int mn88472_init(struct dvb_frontend *fe)
 	int ret, len, remaining;
 	const struct firmware *fw = NULL;
 	u8 *fw_file = MN88472_FIRMWARE;
-	unsigned int csum;
+	unsigned int tmp;
 
 	dev_dbg(&client->dev, "\n");
 
@@ -274,6 +274,17 @@  static int mn88472_init(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
+	/* check if firmware is already running */
+	ret = regmap_read(dev->regmap[0], 0xf5, &tmp);
+	if (ret)
+		goto err;
+
+	if (!(tmp & 0x1)) {
+		dev_info(&client->dev, "firmware already running\n");
+		dev->warm = true;
+		return 0;
+	}
+
 	/* request the firmware, this will block and timeout */
 	ret = request_firmware(&fw, fw_file, &client->dev);
 	if (ret) {
@@ -305,18 +316,18 @@  static int mn88472_init(struct dvb_frontend *fe)
 	}
 
 	/* parity check of firmware */
-	ret = regmap_read(dev->regmap[0], 0xf8, &csum);
+	ret = regmap_read(dev->regmap[0], 0xf8, &tmp);
 	if (ret) {
 		dev_err(&client->dev,
 				"parity reg read failed=%d\n", ret);
 		goto err;
 	}
-	if (csum & 0x10) {
+	if (tmp & 0x10) {
 		dev_err(&client->dev,
-				"firmware parity check failed=0x%x\n", csum);
+				"firmware parity check failed=0x%x\n", tmp);
 		goto err;
 	}
-	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", csum);
+	dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp);
 
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
 	if (ret)