Skip to content

Commit 1701f68

Browse files
committed
Revert "ppdev: use new parport device model"
This reverts commit e7223f1. It causes problems when a ppdev tries to register before the parport driver has been registered with the device model. That will trigger the BUG_ON(!drv->bus->p); at drivers/base/driver.c:153. The call chain is kernel_init -> kernel_init_freeable -> do_one_initcall -> ppdev_init -> __parport_register_driver -> driver_register *BOOM* Reported-by: kernel test robot <fengguang.wu@intel.com> Reported-by: Ross Zwisler <zwisler@gmail.com> Reported-by: Petr Mladek <pmladek@suse.com> Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3b3b3bd commit 1701f68

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

drivers/char/ppdev.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int register_device(int minor, struct pp_struct *pp)
286286
struct parport *port;
287287
struct pardevice *pdev = NULL;
288288
char *name;
289-
struct pardev_cb ppdev_cb;
289+
int fl;
290290

291291
name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor);
292292
if (name == NULL)
@@ -299,11 +299,9 @@ static int register_device(int minor, struct pp_struct *pp)
299299
return -ENXIO;
300300
}
301301

302-
memset(&ppdev_cb, 0, sizeof(ppdev_cb));
303-
ppdev_cb.irq_func = pp_irq;
304-
ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
305-
ppdev_cb.private = pp;
306-
pdev = parport_register_dev_model(port, name, &ppdev_cb, minor);
302+
fl = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
303+
pdev = parport_register_device(port, name, NULL,
304+
NULL, pp_irq, fl, pp);
307305
parport_put_port(port);
308306

309307
if (!pdev) {
@@ -801,23 +799,10 @@ static void pp_detach(struct parport *port)
801799
device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
802800
}
803801

804-
static int pp_probe(struct pardevice *par_dev)
805-
{
806-
struct device_driver *drv = par_dev->dev.driver;
807-
int len = strlen(drv->name);
808-
809-
if (strncmp(par_dev->name, drv->name, len))
810-
return -ENODEV;
811-
812-
return 0;
813-
}
814-
815802
static struct parport_driver pp_driver = {
816803
.name = CHRDEV,
817-
.probe = pp_probe,
818-
.match_port = pp_attach,
804+
.attach = pp_attach,
819805
.detach = pp_detach,
820-
.devmodel = true,
821806
};
822807

823808
static int __init ppdev_init(void)

0 commit comments

Comments
 (0)