Skip to content

Commit 50a762b

Browse files
seanyoungmchehab
authored andcommitted
media: rc: i2c: use dev_dbg rather hand-rolled debug
Use the dev_dbg dynamic infrastructure instead of rolling our own custom debug logic. Signed-off-by: Sean Young <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent afc7f24 commit 50a762b

File tree

1 file changed

+25
-36
lines changed

1 file changed

+25
-36
lines changed

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

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@
4646
#include <media/rc-core.h>
4747
#include <media/i2c/ir-kbd-i2c.h>
4848

49-
/* ----------------------------------------------------------------------- */
50-
/* insmod parameters */
51-
52-
static int debug;
53-
module_param(debug, int, 0644); /* debug level (0,1,2) */
54-
55-
56-
#define MODULE_NAME "ir-kbd-i2c"
57-
#define dprintk(level, fmt, arg...) if (debug >= level) \
58-
printk(KERN_DEBUG MODULE_NAME ": " fmt , ## arg)
59-
60-
/* ----------------------------------------------------------------------- */
6149

6250
static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol,
6351
u32 *scancode, u8 *ptoggle, int size)
@@ -96,7 +84,8 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol,
9684
if (!range)
9785
code += 64;
9886

99-
dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
87+
dev_dbg(&ir->rc->dev,
88+
"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
10089
start, range, toggle, dev, code);
10190

10291
*protocol = RC_PROTO_RC5;
@@ -113,13 +102,15 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol,
113102
*ptoggle = (dev & 0x80) != 0;
114103
*protocol = RC_PROTO_RC6_MCE;
115104
dev &= 0x7f;
116-
dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
117-
*ptoggle, vendor, dev, code);
105+
dev_dbg(&ir->rc->dev,
106+
"ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
107+
*ptoggle, vendor, dev, code);
118108
} else {
119109
*ptoggle = 0;
120110
*protocol = RC_PROTO_RC6_6A_32;
121-
dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n",
122-
vendor, dev, code);
111+
dev_dbg(&ir->rc->dev,
112+
"ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n",
113+
vendor, dev, code);
123114
}
124115

125116
*scancode = RC_SCANCODE_RC6_6A(vendor, dev, code);
@@ -162,7 +153,7 @@ static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol,
162153

163154
/* poll IR chip */
164155
if (1 != i2c_master_recv(ir->c, &b, 1)) {
165-
dprintk(1,"read error\n");
156+
dev_dbg(&ir->rc->dev, "read error\n");
166157
return -EIO;
167158
}
168159

@@ -179,13 +170,12 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol,
179170

180171
/* poll IR chip */
181172
if (4 != i2c_master_recv(ir->c, buf, 4)) {
182-
dprintk(1,"read error\n");
173+
dev_dbg(&ir->rc->dev, "read error\n");
183174
return -EIO;
184175
}
185176

186-
if(buf[0] !=0 || buf[1] !=0 || buf[2] !=0 || buf[3] != 0)
187-
dprintk(2, "%s: 0x%2x 0x%2x 0x%2x 0x%2x\n", __func__,
188-
buf[0], buf[1], buf[2], buf[3]);
177+
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0 || buf[3] != 0)
178+
dev_dbg(&ir->rc->dev, "%s: %*ph\n", __func__, 4, buf);
189179

190180
/* no key pressed or signal from other ir remote */
191181
if(buf[0] != 0x1 || buf[1] != 0xfe)
@@ -204,15 +194,15 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol,
204194

205195
/* poll IR chip */
206196
if (1 != i2c_master_recv(ir->c, &b, 1)) {
207-
dprintk(1,"read error\n");
197+
dev_dbg(&ir->rc->dev, "read error\n");
208198
return -EIO;
209199
}
210200

211201
/* it seems that 0xFE indicates that a button is still hold
212202
down, while 0xff indicates that no button is hold
213203
down. 0xfe sequences are sometimes interrupted by 0xFF */
214204

215-
dprintk(2,"key %02x\n", b);
205+
dev_dbg(&ir->rc->dev, "key %02x\n", b);
216206

217207
if (b == 0xff)
218208
return 0;
@@ -237,7 +227,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol,
237227
.buf = &key, .len = 1} };
238228
subaddr = 0x0d;
239229
if (2 != i2c_transfer(ir->c->adapter, msg, 2)) {
240-
dprintk(1, "read error\n");
230+
dev_dbg(&ir->rc->dev, "read error\n");
241231
return -EIO;
242232
}
243233

@@ -247,18 +237,17 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol,
247237
subaddr = 0x0b;
248238
msg[1].buf = &keygroup;
249239
if (2 != i2c_transfer(ir->c->adapter, msg, 2)) {
250-
dprintk(1, "read error\n");
240+
dev_dbg(&ir->rc->dev, "read error\n");
251241
return -EIO;
252242
}
253243

254244
if (keygroup == 0xff)
255245
return 0;
256246

257-
dprintk(1, "read key 0x%02x/0x%02x\n", key, keygroup);
247+
dev_dbg(&ir->rc->dev, "read key 0x%02x/0x%02x\n", key, keygroup);
258248
if (keygroup < 2 || keygroup > 4) {
259-
/* Only a warning */
260-
dprintk(1, "warning: invalid key group 0x%02x for key 0x%02x\n",
261-
keygroup, key);
249+
dev_warn(&ir->rc->dev, "warning: invalid key group 0x%02x for key 0x%02x\n",
250+
keygroup, key);
262251
}
263252
key |= (keygroup & 1) << 6;
264253

@@ -279,15 +268,15 @@ static int ir_key_poll(struct IR_i2c *ir)
279268
u8 toggle;
280269
int rc;
281270

282-
dprintk(3, "%s\n", __func__);
271+
dev_dbg(&ir->rc->dev, "%s\n", __func__);
283272
rc = ir->get_key(ir, &protocol, &scancode, &toggle);
284273
if (rc < 0) {
285-
dprintk(2,"error\n");
274+
dev_warn(&ir->rc->dev, "error %d\n", rc);
286275
return rc;
287276
}
288277

289278
if (rc) {
290-
dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n",
279+
dev_dbg(&ir->rc->dev, "%s: proto = 0x%04x, scancode = 0x%08x\n",
291280
__func__, protocol, scancode);
292281
rc_keydown(ir->rc, protocol, scancode, toggle);
293282
}
@@ -433,8 +422,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
433422

434423
/* Make sure we are all setup before going on */
435424
if (!name || !ir->get_key || !rc_proto || !ir_codes) {
436-
dprintk(1, ": Unsupported device at address 0x%02x\n",
437-
addr);
425+
dev_warn(&client->dev, "Unsupported device at address 0x%02x\n",
426+
addr);
438427
err = -ENODEV;
439428
goto err_out_free;
440429
}
@@ -459,7 +448,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
459448
rc->map_name = ir->ir_codes;
460449
rc->allowed_protocols = rc_proto;
461450
if (!rc->driver_name)
462-
rc->driver_name = MODULE_NAME;
451+
rc->driver_name = KBUILD_MODNAME;
463452

464453
err = rc_register_device(rc);
465454
if (err)

0 commit comments

Comments
 (0)