Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ata: pata_parport: switch to dynamic root device

Driver core expects devices to be dynamically allocated and will, for
example, complain loudly when no release function has been provided.

Use root_device_register() to allocate and register the root device
instead of open coding using a static device.

Note that this also fixes a reference leak in the unlikely event that
device_register() ever fails.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Niklas Cassel <cassel@kernel.org>

authored by

Johan Hovold and committed by
Niklas Cassel
163f6494 254f4963

+7 -14
+7 -14
drivers/ata/pata_parport/pata_parport.c
··· 459 459 kfree(pi); 460 460 } 461 461 462 - static void pata_parport_bus_release(struct device *dev) 463 - { 464 - /* nothing to do here but required to avoid warning on device removal */ 465 - } 466 - 467 462 static const struct bus_type pata_parport_bus_type = { 468 463 .name = DRV_NAME, 469 464 }; 470 465 471 - static struct device pata_parport_bus = { 472 - .init_name = DRV_NAME, 473 - .release = pata_parport_bus_release, 474 - }; 466 + static struct device *pata_parport_bus; 475 467 476 468 static const struct scsi_host_template pata_parport_sht = { 477 469 PATA_PARPORT_SHT("pata_parport") ··· 510 518 } 511 519 512 520 /* set up pi->dev before pi_probe_unit() so it can use dev_printk() */ 513 - pi->dev.parent = &pata_parport_bus; 521 + pi->dev.parent = pata_parport_bus; 514 522 pi->dev.bus = &pata_parport_bus_type; 515 523 pi->dev.driver = &pr->driver; 516 524 pi->dev.release = pata_parport_dev_release; ··· 772 780 return error; 773 781 } 774 782 775 - error = device_register(&pata_parport_bus); 776 - if (error) { 783 + pata_parport_bus = root_device_register(DRV_NAME); 784 + if (IS_ERR(pata_parport_bus)) { 785 + error = PTR_ERR(pata_parport_bus); 777 786 pr_err("failed to register pata_parport bus, error: %d\n", error); 778 787 goto out_unregister_bus; 779 788 } ··· 804 811 out_remove_new: 805 812 bus_remove_file(&pata_parport_bus_type, &bus_attr_new_device); 806 813 out_unregister_dev: 807 - device_unregister(&pata_parport_bus); 814 + root_device_unregister(pata_parport_bus); 808 815 out_unregister_bus: 809 816 bus_unregister(&pata_parport_bus_type); 810 817 return error; ··· 815 822 parport_unregister_driver(&pata_parport_driver); 816 823 bus_remove_file(&pata_parport_bus_type, &bus_attr_new_device); 817 824 bus_remove_file(&pata_parport_bus_type, &bus_attr_delete_device); 818 - device_unregister(&pata_parport_bus); 825 + root_device_unregister(pata_parport_bus); 819 826 bus_unregister(&pata_parport_bus_type); 820 827 } 821 828