int cx231xx_ir_init(struct cx231xx *dev) { struct cx231xx_IR *ir; struct input_dev *input_dev; u8 ir_config; int err = -ENOMEM; if (dev->board.ir_codes == NULL) { /* No remote control support */ return 0; } ir = kzalloc(sizeof(*ir), GFP_KERNEL); input_dev = input_allocate_device(); if (!ir || !input_dev) goto err_out_free; ir->input = input_dev; /* Setup the proper handler based on the chip */ switch (dev->chip_id) { default: printk("Unrecognized cx231xx chip id: IR not supported\n"); goto err_out_free; } /* This is how often we ask the chip for IR information */ ir->polling = 100; /* ms */ /* init input device */ snprintf(ir->name, sizeof(ir->name), "cx231xx IR (%s)", dev->name); usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); strlcat(ir->phys, "/input0", sizeof(ir->phys)); err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER); if (err < 0) goto err_out_free; input_dev->name = ir->name; input_dev->phys = ir->phys; input_dev->id.bustype = BUS_USB; input_dev->id.version = 1; input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); input_dev->dev.parent = &dev->udev->dev; /* record handles to ourself */ ir->dev = dev; dev->ir = ir; cx231xx_ir_start(ir); /* all done */ err = ir_input_register(ir->input, dev->board.ir_codes); if (err) goto err_out_stop; return 0; err_out_stop: cx231xx_ir_stop(ir); dev->ir = NULL; err_out_free: kfree(ir); return err; }
int cx231xx_ir_init(struct cx231xx *dev) { struct cx231xx_IR *ir; struct input_dev *input_dev; u8 ir_config; int err = -ENOMEM; if (dev->board.ir_codes == NULL) { return 0; } ir = kzalloc(sizeof(*ir), GFP_KERNEL); input_dev = input_allocate_device(); if (!ir || !input_dev) goto err_out_free; ir->input = input_dev; switch (dev->chip_id) { default: printk("Unrecognized cx231xx chip id: IR not supported\n"); goto err_out_free; } ir->polling = 100; snprintf(ir->name, sizeof(ir->name), "cx231xx IR (%s)", dev->name); usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); strlcat(ir->phys, "/input0", sizeof(ir->phys)); ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes); input_dev->name = ir->name; input_dev->phys = ir->phys; input_dev->id.bustype = BUS_USB; input_dev->id.version = 1; input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); input_dev->dev.parent = &dev->udev->dev; ir->dev = dev; dev->ir = ir; cx231xx_ir_start(ir); err = input_register_device(ir->input); if (err) goto err_out_stop; return 0; err_out_stop: cx231xx_ir_stop(ir); dev->ir = NULL; err_out_free: input_free_device(input_dev); kfree(ir); return err; }