Skip to content

Commit 76a65f0

Browse files
jarodwilsonbwhacks
authored andcommitted
lirc_sir: make device registration work
commit 4b71ca6 upstream. For one, the driver device pointer needs to be filled in, or the lirc core will refuse to load the driver. And we really need to wire up all the platform_device bits. This has been tested via the lirc sourceforge tree and verified to work, been sitting there for months, finally getting around to sending it. :\ CC: Josh Boyer <jwboyer@redhat.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1 parent a044f55 commit 76a65f0

1 file changed

Lines changed: 58 additions & 2 deletions

File tree

‎drivers/staging/media/lirc/lirc_sir.c‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <linux/io.h>
5454
#include <asm/irq.h>
5555
#include <linux/fcntl.h>
56+
#include <linux/platform_device.h>
5657
#ifdef LIRC_ON_SA1100
5758
#include <asm/hardware.h>
5859
#ifdef CONFIG_SA1100_COLLIE
@@ -488,9 +489,11 @@ static struct lirc_driver driver = {
488489
.owner = THIS_MODULE,
489490
};
490491

492+
static struct platform_device *lirc_sir_dev;
491493

492494
static int init_chrdev(void)
493495
{
496+
driver.dev = &lirc_sir_dev->dev;
494497
driver.minor = lirc_register_driver(&driver);
495498
if (driver.minor < 0) {
496499
printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n");
@@ -1216,27 +1219,80 @@ static int init_lirc_sir(void)
12161219
return 0;
12171220
}
12181221

1222+
static int __devinit lirc_sir_probe(struct platform_device *dev)
1223+
{
1224+
return 0;
1225+
}
1226+
1227+
static int __devexit lirc_sir_remove(struct platform_device *dev)
1228+
{
1229+
return 0;
1230+
}
1231+
1232+
static struct platform_driver lirc_sir_driver = {
1233+
.probe = lirc_sir_probe,
1234+
.remove = __devexit_p(lirc_sir_remove),
1235+
.driver = {
1236+
.name = "lirc_sir",
1237+
.owner = THIS_MODULE,
1238+
},
1239+
};
12191240

12201241
static int __init lirc_sir_init(void)
12211242
{
12221243
int retval;
12231244

1245+
retval = platform_driver_register(&lirc_sir_driver);
1246+
if (retval) {
1247+
printk(KERN_ERR LIRC_DRIVER_NAME ": Platform driver register "
1248+
"failed!\n");
1249+
return -ENODEV;
1250+
}
1251+
1252+
lirc_sir_dev = platform_device_alloc("lirc_dev", 0);
1253+
if (!lirc_sir_dev) {
1254+
printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device alloc "
1255+
"failed!\n");
1256+
retval = -ENOMEM;
1257+
goto pdev_alloc_fail;
1258+
}
1259+
1260+
retval = platform_device_add(lirc_sir_dev);
1261+
if (retval) {
1262+
printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device add "
1263+
"failed!\n");
1264+
retval = -ENODEV;
1265+
goto pdev_add_fail;
1266+
}
1267+
12241268
retval = init_chrdev();
12251269
if (retval < 0)
1226-
return retval;
1270+
goto fail;
1271+
12271272
retval = init_lirc_sir();
12281273
if (retval) {
12291274
drop_chrdev();
1230-
return retval;
1275+
goto fail;
12311276
}
1277+
12321278
return 0;
1279+
1280+
fail:
1281+
platform_device_del(lirc_sir_dev);
1282+
pdev_add_fail:
1283+
platform_device_put(lirc_sir_dev);
1284+
pdev_alloc_fail:
1285+
platform_driver_unregister(&lirc_sir_driver);
1286+
return retval;
12331287
}
12341288

12351289
static void __exit lirc_sir_exit(void)
12361290
{
12371291
drop_hardware();
12381292
drop_chrdev();
12391293
drop_port();
1294+
platform_device_unregister(lirc_sir_dev);
1295+
platform_driver_unregister(&lirc_sir_driver);
12401296
printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n");
12411297
}
12421298

0 commit comments

Comments
 (0)