Skip to content

Commit 37c45df

Browse files
Jean Delvaremchehab
authored andcommitted
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: Jean Delvare <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent b33d24c commit 37c45df

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

drivers/media/video/ir-kbd-i2c.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,11 @@ static int ir_probe(struct i2c_adapter *adap)
509509
static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 };
510510
static const int probe_cx23885[] = { 0x6b, -1 };
511511
const int *probe;
512-
struct i2c_client *c;
513-
unsigned char buf;
512+
struct i2c_msg msg = {
513+
.flags = I2C_M_RD,
514+
.len = 0,
515+
.buf = NULL,
516+
};
514517
int i, rc;
515518

516519
switch (adap->id) {
@@ -536,23 +539,17 @@ static int ir_probe(struct i2c_adapter *adap)
536539
return 0;
537540
}
538541

539-
c = kzalloc(sizeof(*c), GFP_KERNEL);
540-
if (!c)
541-
return -ENOMEM;
542-
543-
c->adapter = adap;
544542
for (i = 0; -1 != probe[i]; i++) {
545-
c->addr = probe[i];
546-
rc = i2c_master_recv(c, &buf, 0);
543+
msg.addr = probe[i];
544+
rc = i2c_transfer(adap, &msg, 1);
547545
dprintk(1,"probe 0x%02x @ %s: %s\n",
548546
probe[i], adap->name,
549-
(0 == rc) ? "yes" : "no");
550-
if (0 == rc) {
547+
(1 == rc) ? "yes" : "no");
548+
if (1 == rc) {
551549
ir_attach(adap, probe[i], 0, 0);
552550
break;
553551
}
554552
}
555-
kfree(c);
556553
return 0;
557554
}
558555

0 commit comments

Comments
 (0)