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

[media] iguanair: intermittent initialization failure

On cold boot the device does not initialize until the first packet is
received, and that packet is not processed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Sean Young and committed by
Mauro Carvalho Chehab
c6a3ea57 d0aab656

+15 -10
+15 -10
drivers/media/rc/iguanair.c
··· 58 58 char phys[64]; 59 59 }; 60 60 61 + #define CMD_NOP 0x00 61 62 #define CMD_GET_VERSION 0x01 62 63 #define CMD_GET_BUFSIZE 0x11 63 64 #define CMD_GET_FEATURES 0x10 ··· 197 196 198 197 if (urb->status) 199 198 dev_dbg(ir->dev, "Error: out urb status = %d\n", urb->status); 199 + 200 + /* if we sent an nop packet, do not expect a response */ 201 + if (urb->status == 0 && ir->packet->header.cmd == CMD_NOP) 202 + complete(&ir->completion); 200 203 } 201 204 202 205 static int iguanair_send(struct iguanair *ir, unsigned size) ··· 224 219 { 225 220 int rc; 226 221 222 + /* 223 + * On cold boot, the iguanair initializes on the first packet 224 + * received but does not process that packet. Send an empty 225 + * packet. 226 + */ 227 227 ir->packet->header.start = 0; 228 228 ir->packet->header.direction = DIR_OUT; 229 - ir->packet->header.cmd = CMD_GET_VERSION; 229 + ir->packet->header.cmd = CMD_NOP; 230 + iguanair_send(ir, sizeof(ir->packet->header)); 230 231 232 + ir->packet->header.cmd = CMD_GET_VERSION; 231 233 rc = iguanair_send(ir, sizeof(ir->packet->header)); 232 234 if (rc) { 233 235 dev_info(ir->dev, "failed to get version\n"); ··· 267 255 ir->packet->header.cmd = CMD_GET_FEATURES; 268 256 269 257 rc = iguanair_send(ir, sizeof(ir->packet->header)); 270 - if (rc) { 258 + if (rc) 271 259 dev_info(ir->dev, "failed to get features\n"); 272 - goto out; 273 - } 274 - 275 260 out: 276 261 return rc; 277 262 } 278 263 279 264 static int iguanair_receiver(struct iguanair *ir, bool enable) 280 265 { 281 - int rc; 282 - 283 266 ir->packet->header.start = 0; 284 267 ir->packet->header.direction = DIR_OUT; 285 268 ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF; ··· 282 275 if (enable) 283 276 ir_raw_event_reset(ir->rc); 284 277 285 - rc = iguanair_send(ir, sizeof(ir->packet->header)); 286 - 287 - return rc; 278 + return iguanair_send(ir, sizeof(ir->packet->header)); 288 279 } 289 280 290 281 /*