staging: lirc: fix for "lirc_dev: lirc_register_driver: driver pointer must be not NULL!"
Unable to load the module lirc_parallel without the attached patch. Signed-off-by: Thomas Viehweger <patchesThomas.Vie@web.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8590a03125
commit
5d884b97c5
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <linux/poll.h>
|
#include <linux/poll.h>
|
||||||
#include <linux/parport.h>
|
#include <linux/parport.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
#include <media/lirc.h>
|
#include <media/lirc.h>
|
||||||
#include <media/lirc_dev.h>
|
#include <media/lirc_dev.h>
|
||||||
@@ -580,6 +581,40 @@ static struct lirc_driver driver = {
|
|||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct platform_device *lirc_parallel_dev;
|
||||||
|
|
||||||
|
static int __devinit lirc_parallel_probe(struct platform_device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __devexit lirc_parallel_remove(struct platform_device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lirc_parallel_suspend(struct platform_device *dev,
|
||||||
|
pm_message_t state)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lirc_parallel_resume(struct platform_device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct platform_driver lirc_parallel_driver = {
|
||||||
|
.probe = lirc_parallel_probe,
|
||||||
|
.remove = __devexit_p(lirc_parallel_remove),
|
||||||
|
.suspend = lirc_parallel_suspend,
|
||||||
|
.resume = lirc_parallel_resume,
|
||||||
|
.driver = {
|
||||||
|
.name = LIRC_DRIVER_NAME,
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static int pf(void *handle);
|
static int pf(void *handle);
|
||||||
static void kf(void *handle);
|
static void kf(void *handle);
|
||||||
|
|
||||||
@@ -608,11 +643,30 @@ static void kf(void *handle)
|
|||||||
|
|
||||||
static int __init lirc_parallel_init(void)
|
static int __init lirc_parallel_init(void)
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
result = platform_driver_register(&lirc_parallel_driver);
|
||||||
|
if (result) {
|
||||||
|
printk("platform_driver_register returned %d\n", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0);
|
||||||
|
if (!lirc_parallel_dev) {
|
||||||
|
result = -ENOMEM;
|
||||||
|
goto exit_driver_unregister;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = platform_device_add(lirc_parallel_dev);
|
||||||
|
if (result)
|
||||||
|
goto exit_device_put;
|
||||||
|
|
||||||
pport = parport_find_base(io);
|
pport = parport_find_base(io);
|
||||||
if (pport == NULL) {
|
if (pport == NULL) {
|
||||||
printk(KERN_NOTICE "%s: no port at %x found\n",
|
printk(KERN_NOTICE "%s: no port at %x found\n",
|
||||||
LIRC_DRIVER_NAME, io);
|
LIRC_DRIVER_NAME, io);
|
||||||
return -ENXIO;
|
result = -ENXIO;
|
||||||
|
goto exit_device_put;
|
||||||
}
|
}
|
||||||
ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME,
|
ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME,
|
||||||
pf, kf, irq_handler, 0, NULL);
|
pf, kf, irq_handler, 0, NULL);
|
||||||
@@ -620,7 +674,8 @@ static int __init lirc_parallel_init(void)
|
|||||||
if (ppdevice == NULL) {
|
if (ppdevice == NULL) {
|
||||||
printk(KERN_NOTICE "%s: parport_register_device() failed\n",
|
printk(KERN_NOTICE "%s: parport_register_device() failed\n",
|
||||||
LIRC_DRIVER_NAME);
|
LIRC_DRIVER_NAME);
|
||||||
return -ENXIO;
|
result = -ENXIO;
|
||||||
|
goto exit_device_put;
|
||||||
}
|
}
|
||||||
if (parport_claim(ppdevice) != 0)
|
if (parport_claim(ppdevice) != 0)
|
||||||
goto skip_init;
|
goto skip_init;
|
||||||
@@ -638,7 +693,8 @@ static int __init lirc_parallel_init(void)
|
|||||||
is_claimed = 0;
|
is_claimed = 0;
|
||||||
parport_release(pport);
|
parport_release(pport);
|
||||||
parport_unregister_device(ppdevice);
|
parport_unregister_device(ppdevice);
|
||||||
return -EIO;
|
result = -EIO;
|
||||||
|
goto exit_device_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -649,16 +705,24 @@ static int __init lirc_parallel_init(void)
|
|||||||
is_claimed = 0;
|
is_claimed = 0;
|
||||||
parport_release(ppdevice);
|
parport_release(ppdevice);
|
||||||
skip_init:
|
skip_init:
|
||||||
|
driver.dev = &lirc_parallel_dev->dev;
|
||||||
driver.minor = lirc_register_driver(&driver);
|
driver.minor = lirc_register_driver(&driver);
|
||||||
if (driver.minor < 0) {
|
if (driver.minor < 0) {
|
||||||
printk(KERN_NOTICE "%s: register_chrdev() failed\n",
|
printk(KERN_NOTICE "%s: register_chrdev() failed\n",
|
||||||
LIRC_DRIVER_NAME);
|
LIRC_DRIVER_NAME);
|
||||||
parport_unregister_device(ppdevice);
|
parport_unregister_device(ppdevice);
|
||||||
return -EIO;
|
result = -EIO;
|
||||||
|
goto exit_device_put;
|
||||||
}
|
}
|
||||||
printk(KERN_INFO "%s: installed using port 0x%04x irq %d\n",
|
printk(KERN_INFO "%s: installed using port 0x%04x irq %d\n",
|
||||||
LIRC_DRIVER_NAME, io, irq);
|
LIRC_DRIVER_NAME, io, irq);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_device_put:
|
||||||
|
platform_device_put(lirc_parallel_dev);
|
||||||
|
exit_driver_unregister:
|
||||||
|
platform_driver_unregister(&lirc_parallel_driver);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit lirc_parallel_exit(void)
|
static void __exit lirc_parallel_exit(void)
|
||||||
|
Reference in New Issue
Block a user