]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.27/0004-lirc_sir-make-device-registration-work.patch
linux-ti33x-psp 3.2: update to 3.2.28 and add motorcape support
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.27 / 0004-lirc_sir-make-device-registration-work.patch
1 From 03d61a0ca7ab54f6fb1524f4313afd1811fde803 Mon Sep 17 00:00:00 2001
2 From: Jarod Wilson <jarod@redhat.com>
3 Date: Mon, 4 Jun 2012 13:05:24 -0300
4 Subject: [PATCH 04/70] lirc_sir: make device registration work
6 commit 4b71ca6bce8fab3d08c61bf330e781f957934ae1 upstream.
8 For one, the driver device pointer needs to be filled in, or the lirc core
9 will refuse to load the driver. And we really need to wire up all the
10 platform_device bits. This has been tested via the lirc sourceforge tree
11 and verified to work, been sitting there for months, finally getting
12 around to sending it. :\
14 CC: Josh Boyer <jwboyer@redhat.com>
15 Signed-off-by: Jarod Wilson <jarod@redhat.com>
16 Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
17 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
18 ---
19  drivers/staging/media/lirc/lirc_sir.c |   60 +++++++++++++++++++++++++++++++-
20  1 files changed, 58 insertions(+), 2 deletions(-)
22 diff --git a/drivers/staging/media/lirc/lirc_sir.c b/drivers/staging/media/lirc/lirc_sir.c
23 index 6903d39..90e9e32 100644
24 --- a/drivers/staging/media/lirc/lirc_sir.c
25 +++ b/drivers/staging/media/lirc/lirc_sir.c
26 @@ -53,6 +53,7 @@
27  #include <linux/io.h>
28  #include <asm/irq.h>
29  #include <linux/fcntl.h>
30 +#include <linux/platform_device.h>
31  #ifdef LIRC_ON_SA1100
32  #include <asm/hardware.h>
33  #ifdef CONFIG_SA1100_COLLIE
34 @@ -488,9 +489,11 @@ static struct lirc_driver driver = {
35         .owner          = THIS_MODULE,
36  };
37  
38 +static struct platform_device *lirc_sir_dev;
39  
40  static int init_chrdev(void)
41  {
42 +       driver.dev = &lirc_sir_dev->dev;
43         driver.minor = lirc_register_driver(&driver);
44         if (driver.minor < 0) {
45                 printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n");
46 @@ -1216,20 +1219,71 @@ static int init_lirc_sir(void)
47         return 0;
48  }
49  
50 +static int __devinit lirc_sir_probe(struct platform_device *dev)
51 +{
52 +       return 0;
53 +}
54 +
55 +static int __devexit lirc_sir_remove(struct platform_device *dev)
56 +{
57 +       return 0;
58 +}
59 +
60 +static struct platform_driver lirc_sir_driver = {
61 +       .probe          = lirc_sir_probe,
62 +       .remove         = __devexit_p(lirc_sir_remove),
63 +       .driver         = {
64 +               .name   = "lirc_sir",
65 +               .owner  = THIS_MODULE,
66 +       },
67 +};
68  
69  static int __init lirc_sir_init(void)
70  {
71         int retval;
72  
73 +       retval = platform_driver_register(&lirc_sir_driver);
74 +       if (retval) {
75 +               printk(KERN_ERR LIRC_DRIVER_NAME ": Platform driver register "
76 +                      "failed!\n");
77 +               return -ENODEV;
78 +       }
79 +
80 +       lirc_sir_dev = platform_device_alloc("lirc_dev", 0);
81 +       if (!lirc_sir_dev) {
82 +               printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device alloc "
83 +                      "failed!\n");
84 +               retval = -ENOMEM;
85 +               goto pdev_alloc_fail;
86 +       }
87 +
88 +       retval = platform_device_add(lirc_sir_dev);
89 +       if (retval) {
90 +               printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device add "
91 +                      "failed!\n");
92 +               retval = -ENODEV;
93 +               goto pdev_add_fail;
94 +       }
95 +
96         retval = init_chrdev();
97         if (retval < 0)
98 -               return retval;
99 +               goto fail;
101         retval = init_lirc_sir();
102         if (retval) {
103                 drop_chrdev();
104 -               return retval;
105 +               goto fail;
106         }
108         return 0;
110 +fail:
111 +       platform_device_del(lirc_sir_dev);
112 +pdev_add_fail:
113 +       platform_device_put(lirc_sir_dev);
114 +pdev_alloc_fail:
115 +       platform_driver_unregister(&lirc_sir_driver);
116 +       return retval;
117  }
118  
119  static void __exit lirc_sir_exit(void)
120 @@ -1237,6 +1291,8 @@ static void __exit lirc_sir_exit(void)
121         drop_hardware();
122         drop_chrdev();
123         drop_port();
124 +       platform_device_unregister(lirc_sir_dev);
125 +       platform_driver_unregister(&lirc_sir_driver);
126         printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n");
127  }
128  
129 -- 
130 1.7.7.6