Commit 37c45df7 authored by Jean Delvare's avatar Jean Delvare Committed by Mauro Carvalho Chehab

V4L/DVB (7751): ir-kbd-i2c: Save a temporary memory allocation in ir_probe

Using i2c_transfer instead of i2c_master_recv in ir_probe saves a
temporary memory allocation.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b33d24c4
...@@ -509,8 +509,11 @@ static int ir_probe(struct i2c_adapter *adap) ...@@ -509,8 +509,11 @@ static int ir_probe(struct i2c_adapter *adap)
static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 }; static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 };
static const int probe_cx23885[] = { 0x6b, -1 }; static const int probe_cx23885[] = { 0x6b, -1 };
const int *probe; const int *probe;
struct i2c_client *c; struct i2c_msg msg = {
unsigned char buf; .flags = I2C_M_RD,
.len = 0,
.buf = NULL,
};
int i, rc; int i, rc;
switch (adap->id) { switch (adap->id) {
...@@ -536,23 +539,17 @@ static int ir_probe(struct i2c_adapter *adap) ...@@ -536,23 +539,17 @@ static int ir_probe(struct i2c_adapter *adap)
return 0; return 0;
} }
c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c)
return -ENOMEM;
c->adapter = adap;
for (i = 0; -1 != probe[i]; i++) { for (i = 0; -1 != probe[i]; i++) {
c->addr = probe[i]; msg.addr = probe[i];
rc = i2c_master_recv(c, &buf, 0); rc = i2c_transfer(adap, &msg, 1);
dprintk(1,"probe 0x%02x @ %s: %s\n", dprintk(1,"probe 0x%02x @ %s: %s\n",
probe[i], adap->name, probe[i], adap->name,
(0 == rc) ? "yes" : "no"); (1 == rc) ? "yes" : "no");
if (0 == rc) { if (1 == rc) {
ir_attach(adap, probe[i], 0, 0); ir_attach(adap, probe[i], 0, 0);
break; break;
} }
} }
kfree(c);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment