diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2016-11-12 16:22:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-29 14:25:34 -0500 |
commit | dd5c472a60e43549d789a17a8444513eec64bd7e (patch) | |
tree | 0c4e511c74fdded742c37f07246d460fc6828446 | |
parent | 826a4c6574efafdcfc292cdaf4dd2ccd6133d5f0 (diff) |
ppdev: check before attaching port
After parport starts using the device model, all pardevice drivers
should decide in their match_port callback function if they want to
attach with that particulatr port. ppdev has been converted to use the
new parport device-model code but pp_attach() tried to attach with all
the ports.
Create a new array of pointer and use that to remember the ports we
have attached. And use that information to skip attaching ports which
we have already attached.
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/char/ppdev.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 85c63e49df7f..02819e0703c8 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c | |||
@@ -86,6 +86,9 @@ struct pp_struct { | |||
86 | long default_inactivity; | 86 | long default_inactivity; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | /* should we use PARDEVICE_MAX here? */ | ||
90 | static struct device *devices[PARPORT_MAX]; | ||
91 | |||
89 | /* pp_struct.flags bitfields */ | 92 | /* pp_struct.flags bitfields */ |
90 | #define PP_CLAIMED (1<<0) | 93 | #define PP_CLAIMED (1<<0) |
91 | #define PP_EXCL (1<<1) | 94 | #define PP_EXCL (1<<1) |
@@ -789,13 +792,29 @@ static const struct file_operations pp_fops = { | |||
789 | 792 | ||
790 | static void pp_attach(struct parport *port) | 793 | static void pp_attach(struct parport *port) |
791 | { | 794 | { |
792 | device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), | 795 | struct device *ret; |
793 | NULL, "parport%d", port->number); | 796 | |
797 | if (devices[port->number]) | ||
798 | return; | ||
799 | |||
800 | ret = device_create(ppdev_class, port->dev, | ||
801 | MKDEV(PP_MAJOR, port->number), NULL, | ||
802 | "parport%d", port->number); | ||
803 | if (IS_ERR(ret)) { | ||
804 | pr_err("Failed to create device parport%d\n", | ||
805 | port->number); | ||
806 | return; | ||
807 | } | ||
808 | devices[port->number] = ret; | ||
794 | } | 809 | } |
795 | 810 | ||
796 | static void pp_detach(struct parport *port) | 811 | static void pp_detach(struct parport *port) |
797 | { | 812 | { |
813 | if (!devices[port->number]) | ||
814 | return; | ||
815 | |||
798 | device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); | 816 | device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); |
817 | devices[port->number] = NULL; | ||
799 | } | 818 | } |
800 | 819 | ||
801 | static int pp_probe(struct pardevice *par_dev) | 820 | static int pp_probe(struct pardevice *par_dev) |