Commit 4b71ca6bce8fab3d08c61bf330e781f957934ae1

Authored by Jarod Wilson
Committed by Mauro Carvalho Chehab
1 parent fdaaee6c4a

[media] lirc_sir: make device registration work

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>

Showing 1 changed file with 58 additions and 2 deletions Side-by-side Diff

drivers/staging/media/lirc/lirc_sir.c
... ... @@ -52,6 +52,7 @@
52 52 #include <linux/io.h>
53 53 #include <asm/irq.h>
54 54 #include <linux/fcntl.h>
  55 +#include <linux/platform_device.h>
55 56 #ifdef LIRC_ON_SA1100
56 57 #include <asm/hardware.h>
57 58 #ifdef CONFIG_SA1100_COLLIE
58 59  
... ... @@ -487,9 +488,11 @@
487 488 .owner = THIS_MODULE,
488 489 };
489 490  
  491 +static struct platform_device *lirc_sir_dev;
490 492  
491 493 static int init_chrdev(void)
492 494 {
  495 + driver.dev = &lirc_sir_dev->dev;
493 496 driver.minor = lirc_register_driver(&driver);
494 497 if (driver.minor < 0) {
495 498 printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n");
496 499  
497 500  
498 501  
499 502  
500 503  
501 504  
... ... @@ -1215,20 +1218,71 @@
1215 1218 return 0;
1216 1219 }
1217 1220  
  1221 +static int __devinit lirc_sir_probe(struct platform_device *dev)
  1222 +{
  1223 + return 0;
  1224 +}
1218 1225  
  1226 +static int __devexit lirc_sir_remove(struct platform_device *dev)
  1227 +{
  1228 + return 0;
  1229 +}
  1230 +
  1231 +static struct platform_driver lirc_sir_driver = {
  1232 + .probe = lirc_sir_probe,
  1233 + .remove = __devexit_p(lirc_sir_remove),
  1234 + .driver = {
  1235 + .name = "lirc_sir",
  1236 + .owner = THIS_MODULE,
  1237 + },
  1238 +};
  1239 +
1219 1240 static int __init lirc_sir_init(void)
1220 1241 {
1221 1242 int retval;
1222 1243  
  1244 + retval = platform_driver_register(&lirc_sir_driver);
  1245 + if (retval) {
  1246 + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform driver register "
  1247 + "failed!\n");
  1248 + return -ENODEV;
  1249 + }
  1250 +
  1251 + lirc_sir_dev = platform_device_alloc("lirc_dev", 0);
  1252 + if (!lirc_sir_dev) {
  1253 + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device alloc "
  1254 + "failed!\n");
  1255 + retval = -ENOMEM;
  1256 + goto pdev_alloc_fail;
  1257 + }
  1258 +
  1259 + retval = platform_device_add(lirc_sir_dev);
  1260 + if (retval) {
  1261 + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device add "
  1262 + "failed!\n");
  1263 + retval = -ENODEV;
  1264 + goto pdev_add_fail;
  1265 + }
  1266 +
1223 1267 retval = init_chrdev();
1224 1268 if (retval < 0)
1225   - return retval;
  1269 + goto fail;
  1270 +
1226 1271 retval = init_lirc_sir();
1227 1272 if (retval) {
1228 1273 drop_chrdev();
1229   - return retval;
  1274 + goto fail;
1230 1275 }
  1276 +
1231 1277 return 0;
  1278 +
  1279 +fail:
  1280 + platform_device_del(lirc_sir_dev);
  1281 +pdev_add_fail:
  1282 + platform_device_put(lirc_sir_dev);
  1283 +pdev_alloc_fail:
  1284 + platform_driver_unregister(&lirc_sir_driver);
  1285 + return retval;
1232 1286 }
1233 1287  
1234 1288 static void __exit lirc_sir_exit(void)
... ... @@ -1236,6 +1290,8 @@
1236 1290 drop_hardware();
1237 1291 drop_chrdev();
1238 1292 drop_port();
  1293 + platform_device_unregister(lirc_sir_dev);
  1294 + platform_driver_unregister(&lirc_sir_driver);
1239 1295 printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n");
1240 1296 }
1241 1297