aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-17 18:46:23 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-17 18:46:23 -0400
commitf74c91413ec6140ee0553180c5f56fdd27c22a2e (patch)
tree75ba3f7000ba290dc19b1523b12ab95dc5c7b1ea /drivers/ide/ide.c
parent50672e5d7486c9ab312432cbe180ac071f1de8e0 (diff)
ide: add warm-plug support for IDE devices (take 2)
* Add 'struct class ide_port_class' ('ide_port' class) and a 'struct device *portdev' ('ide_port' class device) in ide_hwif_t. * Register 'ide_port' class in ide_init() and unregister it in cleanup_module(). * Create ->portdev in ide_register_port () and unregister it in ide_unregister(). * Add "delete_devices" class device attribute for unregistering IDE devices on a port and "scan" one for probing+registering IDE devices on a port. * Add ide_sysfs_register_port() helper for registering "delete_devices" and "scan" attributes with ->portdev. Call it in ide_device_add_all(). * Document IDE warm-plug support in Documentation/ide/warm-plug-howto.txt. v2: * Convert patch from using 'struct class_device' to use 'struct device'. (thanks to Kay Sievers for doing it) Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index cb18ba8de22d..d791b1ffb586 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -78,6 +78,8 @@
78/* default maximum number of failures */ 78/* default maximum number of failures */
79#define IDE_DEFAULT_MAX_FAILURES 1 79#define IDE_DEFAULT_MAX_FAILURES 1
80 80
81struct class *ide_port_class;
82
81static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, 83static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR,
82 IDE2_MAJOR, IDE3_MAJOR, 84 IDE2_MAJOR, IDE3_MAJOR,
83 IDE4_MAJOR, IDE5_MAJOR, 85 IDE4_MAJOR, IDE5_MAJOR,
@@ -591,6 +593,7 @@ void ide_unregister(unsigned int index, int init_default, int restore)
591 593
592 ide_remove_port_from_hwgroup(hwif); 594 ide_remove_port_from_hwgroup(hwif);
593 595
596 device_unregister(hwif->portdev);
594 device_unregister(&hwif->gendev); 597 device_unregister(&hwif->gendev);
595 wait_for_completion(&hwif->gendev_rel_comp); 598 wait_for_completion(&hwif->gendev_rel_comp);
596 599
@@ -1590,6 +1593,13 @@ struct bus_type ide_bus_type = {
1590 1593
1591EXPORT_SYMBOL_GPL(ide_bus_type); 1594EXPORT_SYMBOL_GPL(ide_bus_type);
1592 1595
1596static void ide_port_class_release(struct device *portdev)
1597{
1598 ide_hwif_t *hwif = dev_get_drvdata(portdev);
1599
1600 put_device(&hwif->gendev);
1601}
1602
1593/* 1603/*
1594 * This is gets invoked once during initialization, to set *everything* up 1604 * This is gets invoked once during initialization, to set *everything* up
1595 */ 1605 */
@@ -1610,11 +1620,23 @@ static int __init ide_init(void)
1610 return ret; 1620 return ret;
1611 } 1621 }
1612 1622
1623 ide_port_class = class_create(THIS_MODULE, "ide_port");
1624 if (IS_ERR(ide_port_class)) {
1625 ret = PTR_ERR(ide_port_class);
1626 goto out_port_class;
1627 }
1628 ide_port_class->dev_release = ide_port_class_release;
1629
1613 init_ide_data(); 1630 init_ide_data();
1614 1631
1615 proc_ide_create(); 1632 proc_ide_create();
1616 1633
1617 return 0; 1634 return 0;
1635
1636out_port_class:
1637 bus_unregister(&ide_bus_type);
1638
1639 return ret;
1618} 1640}
1619 1641
1620#ifdef MODULE 1642#ifdef MODULE
@@ -1651,6 +1673,8 @@ void __exit cleanup_module (void)
1651 1673
1652 proc_ide_destroy(); 1674 proc_ide_destroy();
1653 1675
1676 class_destroy(ide_port_class);
1677
1654 bus_unregister(&ide_bus_type); 1678 bus_unregister(&ide_bus_type);
1655} 1679}
1656 1680