summaryrefslogtreecommitdiffstats
path: root/drivers/media/tuners
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2013-11-07 17:01:31 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-19 09:20:17 -0200
commit050ae82c35fd8bb72b27becb1b9d19c7f5978234 (patch)
treecc5566bebb7e48bf84f3d5b4d331536f4b44e5b7 /drivers/media/tuners
parent0d62f800b5f1398972a0d27ba136e72121db02d6 (diff)
downloadblackbird-op-linux-050ae82c35fd8bb72b27becb1b9d19c7f5978234.tar.gz
blackbird-op-linux-050ae82c35fd8bb72b27becb1b9d19c7f5978234.zip
[media] m88ts2022: do not use dynamic stack allocation
I2C transfer were using dynamic stack allocation. Get rid of it. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/tuners')
-rw-r--r--drivers/media/tuners/m88ts2022.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 0625e36d0a92..4b3eec28fb76 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -26,17 +26,22 @@
static int m88ts2022_wr_regs(struct m88ts2022_priv *priv,
u8 reg, const u8 *val, int len)
{
+#define MAX_WR_LEN 3
+#define MAX_WR_XFER_LEN (MAX_WR_LEN + 1)
int ret;
- u8 buf[1 + len];
+ u8 buf[MAX_WR_XFER_LEN];
struct i2c_msg msg[1] = {
{
.addr = priv->cfg->i2c_addr,
.flags = 0,
- .len = sizeof(buf),
+ .len = 1 + len,
.buf = buf,
}
};
+ if (WARN_ON(len > MAX_WR_LEN))
+ return -EINVAL;
+
buf[0] = reg;
memcpy(&buf[1], val, len);
@@ -57,8 +62,10 @@ static int m88ts2022_wr_regs(struct m88ts2022_priv *priv,
static int m88ts2022_rd_regs(struct m88ts2022_priv *priv, u8 reg,
u8 *val, int len)
{
+#define MAX_RD_LEN 1
+#define MAX_RD_XFER_LEN (MAX_RD_LEN)
int ret;
- u8 buf[len];
+ u8 buf[MAX_RD_XFER_LEN];
struct i2c_msg msg[2] = {
{
.addr = priv->cfg->i2c_addr,
@@ -68,11 +75,14 @@ static int m88ts2022_rd_regs(struct m88ts2022_priv *priv, u8 reg,
}, {
.addr = priv->cfg->i2c_addr,
.flags = I2C_M_RD,
- .len = sizeof(buf),
+ .len = len,
.buf = buf,
}
};
+ if (WARN_ON(len > MAX_RD_LEN))
+ return -EINVAL;
+
ret = i2c_transfer(priv->i2c, msg, 2);
if (ret == 2) {
memcpy(val, buf, len);
OpenPOWER on IntegriCloud