Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] tda10071: protect firmware command exec with mutex

There should be clearly some lock in order to make sure firmware
command in execution is not disturbed by another command. It has
worked as callbacks are serialized somehow pretty well and command
execution happens usually without any delays.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Antti Palosaari and committed by
Mauro Carvalho Chehab
e14432a5 54ab48ed

+10 -3
+9 -3
drivers/media/dvb-frontends/tda10071.c
··· 61 61 goto error; 62 62 } 63 63 64 + mutex_lock(&dev->cmd_execute_mutex); 65 + 64 66 /* write cmd and args for firmware */ 65 67 ret = regmap_bulk_write(dev->regmap, 0x00, cmd->args, cmd->len); 66 68 if (ret) 67 - goto error; 69 + goto error_mutex_unlock; 68 70 69 71 /* start cmd execution */ 70 72 ret = regmap_write(dev->regmap, 0x1f, 1); 71 73 if (ret) 72 - goto error; 74 + goto error_mutex_unlock; 73 75 74 76 /* wait cmd execution terminate */ 75 77 for (i = 1000, uitmp = 1; i && uitmp; i--) { 76 78 ret = regmap_read(dev->regmap, 0x1f, &uitmp); 77 79 if (ret) 78 - goto error; 80 + goto error_mutex_unlock; 79 81 80 82 usleep_range(200, 5000); 81 83 } 82 84 85 + mutex_unlock(&dev->cmd_execute_mutex); 83 86 dev_dbg(&client->dev, "loop=%d\n", i); 84 87 85 88 if (i == 0) { ··· 91 88 } 92 89 93 90 return ret; 91 + error_mutex_unlock: 92 + mutex_unlock(&dev->cmd_execute_mutex); 94 93 error: 95 94 dev_dbg(&client->dev, "failed=%d\n", ret); 96 95 return ret; ··· 1172 1167 } 1173 1168 1174 1169 dev->client = client; 1170 + mutex_init(&dev->cmd_execute_mutex); 1175 1171 dev->clk = pdata->clk; 1176 1172 dev->i2c_wr_max = pdata->i2c_wr_max; 1177 1173 dev->ts_mode = pdata->ts_mode;
+1
drivers/media/dvb-frontends/tda10071_priv.h
··· 30 30 struct dvb_frontend fe; 31 31 struct i2c_client *client; 32 32 struct regmap *regmap; 33 + struct mutex cmd_execute_mutex; 33 34 u32 clk; 34 35 u16 i2c_wr_max; 35 36 u8 ts_mode;