Skip to content

Commit c52f2ba

Browse files
seanyoungmchehab
authored andcommitted
[media] sir_ir: remove init_chrdev and init_sir_ir functions
Inlining these functions into the probe function makes it much more readable. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent f23f540 commit c52f2ba

1 file changed

Lines changed: 22 additions & 36 deletions

File tree

‎drivers/media/rc/sir_ir.c‎

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static DEFINE_SPINLOCK(hardware_lock);
5353

5454
/* Communication with user-space */
5555
static void add_read_queue(int flag, unsigned long val);
56-
static int init_chrdev(void);
5756
/* Hardware */
5857
static irqreturn_t sir_interrupt(int irq, void *dev_id);
5958
static void send_space(unsigned long len);
@@ -120,28 +119,6 @@ static void add_read_queue(int flag, unsigned long val)
120119
ir_raw_event_store_with_filter(rcdev, &ev);
121120
}
122121

123-
static int init_chrdev(void)
124-
{
125-
rcdev = devm_rc_allocate_device(&sir_ir_dev->dev, RC_DRIVER_IR_RAW);
126-
if (!rcdev)
127-
return -ENOMEM;
128-
129-
rcdev->input_name = "SIR IrDA port";
130-
rcdev->input_phys = KBUILD_MODNAME "/input0";
131-
rcdev->input_id.bustype = BUS_HOST;
132-
rcdev->input_id.vendor = 0x0001;
133-
rcdev->input_id.product = 0x0001;
134-
rcdev->input_id.version = 0x0100;
135-
rcdev->tx_ir = sir_tx_ir;
136-
rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
137-
rcdev->driver_name = KBUILD_MODNAME;
138-
rcdev->map_name = RC_MAP_RC6_MCE;
139-
rcdev->timeout = IR_DEFAULT_TIMEOUT;
140-
rcdev->dev.parent = &sir_ir_dev->dev;
141-
142-
return devm_rc_register_device(&sir_ir_dev->dev, rcdev);
143-
}
144-
145122
/* SECTION: Hardware */
146123
static void sir_timeout(unsigned long data)
147124
{
@@ -323,11 +300,27 @@ static void drop_hardware(void)
323300
}
324301

325302
/* SECTION: Initialisation */
326-
327-
static int init_sir_ir(void)
303+
static int sir_ir_probe(struct platform_device *dev)
328304
{
329305
int retval;
330306

307+
rcdev = devm_rc_allocate_device(&sir_ir_dev->dev, RC_DRIVER_IR_RAW);
308+
if (!rcdev)
309+
return -ENOMEM;
310+
311+
rcdev->input_name = "SIR IrDA port";
312+
rcdev->input_phys = KBUILD_MODNAME "/input0";
313+
rcdev->input_id.bustype = BUS_HOST;
314+
rcdev->input_id.vendor = 0x0001;
315+
rcdev->input_id.product = 0x0001;
316+
rcdev->input_id.version = 0x0100;
317+
rcdev->tx_ir = sir_tx_ir;
318+
rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
319+
rcdev->driver_name = KBUILD_MODNAME;
320+
rcdev->map_name = RC_MAP_RC6_MCE;
321+
rcdev->timeout = IR_DEFAULT_TIMEOUT;
322+
rcdev->dev.parent = &sir_ir_dev->dev;
323+
331324
setup_timer(&timerlist, sir_timeout, 0);
332325

333326
/* get I/O port access and IRQ line */
@@ -343,20 +336,13 @@ static int init_sir_ir(void)
343336
}
344337
pr_info("I/O port 0x%.4x, IRQ %d.\n", io, irq);
345338

346-
init_hardware();
347-
348-
return 0;
349-
}
350-
351-
static int sir_ir_probe(struct platform_device *dev)
352-
{
353-
int retval;
354-
355-
retval = init_chrdev();
339+
retval = devm_rc_register_device(&sir_ir_dev->dev, rcdev);
356340
if (retval < 0)
357341
return retval;
358342

359-
return init_sir_ir();
343+
init_hardware();
344+
345+
return 0;
360346
}
361347

362348
static int sir_ir_remove(struct platform_device *dev)

0 commit comments

Comments
 (0)