forked from mirrors/linux
		
	ppdev: use new parport device model
Modify ppdev driver to use the new parallel port device model. Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									3c8db58432
								
							
						
					
					
						commit
						e7223f1860
					
				
					 1 changed files with 20 additions and 5 deletions
				
			
		| 
						 | 
					@ -286,7 +286,7 @@ static int register_device(int minor, struct pp_struct *pp)
 | 
				
			||||||
	struct parport *port;
 | 
						struct parport *port;
 | 
				
			||||||
	struct pardevice *pdev = NULL;
 | 
						struct pardevice *pdev = NULL;
 | 
				
			||||||
	char *name;
 | 
						char *name;
 | 
				
			||||||
	int fl;
 | 
						struct pardev_cb ppdev_cb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
 | 
						name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
 | 
				
			||||||
	if (name == NULL)
 | 
						if (name == NULL)
 | 
				
			||||||
| 
						 | 
					@ -299,9 +299,11 @@ static int register_device(int minor, struct pp_struct *pp)
 | 
				
			||||||
		return -ENXIO;
 | 
							return -ENXIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fl = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
 | 
						memset(&ppdev_cb, 0, sizeof(ppdev_cb));
 | 
				
			||||||
	pdev = parport_register_device(port, name, NULL,
 | 
						ppdev_cb.irq_func = pp_irq;
 | 
				
			||||||
				       NULL, pp_irq, fl, pp);
 | 
						ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
 | 
				
			||||||
 | 
						ppdev_cb.private = pp;
 | 
				
			||||||
 | 
						pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
 | 
				
			||||||
	parport_put_port(port);
 | 
						parport_put_port(port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!pdev) {
 | 
						if (!pdev) {
 | 
				
			||||||
| 
						 | 
					@ -799,10 +801,23 @@ static void pp_detach(struct parport *port)
 | 
				
			||||||
	device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
 | 
						device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int pp_probe(struct pardevice *par_dev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct device_driver *drv = par_dev->dev.driver;
 | 
				
			||||||
 | 
						int len = strlen(drv->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (strncmp(par_dev->name, drv->name, len))
 | 
				
			||||||
 | 
							return -ENODEV;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct parport_driver pp_driver = {
 | 
					static struct parport_driver pp_driver = {
 | 
				
			||||||
	.name		= CHRDEV,
 | 
						.name		= CHRDEV,
 | 
				
			||||||
	.attach		= pp_attach,
 | 
						.probe		= pp_probe,
 | 
				
			||||||
 | 
						.match_port	= pp_attach,
 | 
				
			||||||
	.detach		= pp_detach,
 | 
						.detach		= pp_detach,
 | 
				
			||||||
 | 
						.devmodel	= true,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __init ppdev_init(void)
 | 
					static int __init ppdev_init(void)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue