diff options
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 468c4ac4181d..510254ab3c9b 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -623,7 +623,7 @@ static void hwif_release_dev (struct device *dev) | |||
623 | complete(&hwif->gendev_rel_comp); | 623 | complete(&hwif->gendev_rel_comp); |
624 | } | 624 | } |
625 | 625 | ||
626 | static void ide_register_port(ide_hwif_t *hwif) | 626 | static int ide_register_port(ide_hwif_t *hwif) |
627 | { | 627 | { |
628 | int ret; | 628 | int ret; |
629 | 629 | ||
@@ -639,9 +639,23 @@ static void ide_register_port(ide_hwif_t *hwif) | |||
639 | } | 639 | } |
640 | hwif->gendev.release = hwif_release_dev; | 640 | hwif->gendev.release = hwif_release_dev; |
641 | ret = device_register(&hwif->gendev); | 641 | ret = device_register(&hwif->gendev); |
642 | if (ret < 0) | 642 | if (ret < 0) { |
643 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", | 643 | printk(KERN_WARNING "IDE: %s: device_register error: %d\n", |
644 | __FUNCTION__, ret); | 644 | __FUNCTION__, ret); |
645 | goto out; | ||
646 | } | ||
647 | |||
648 | get_device(&hwif->gendev); | ||
649 | |||
650 | hwif->portdev = device_create(ide_port_class, &hwif->gendev, | ||
651 | MKDEV(0, 0), hwif->name); | ||
652 | if (IS_ERR(hwif->portdev)) { | ||
653 | ret = PTR_ERR(hwif->portdev); | ||
654 | device_unregister(&hwif->gendev); | ||
655 | } | ||
656 | dev_set_drvdata(hwif->portdev, hwif); | ||
657 | out: | ||
658 | return ret; | ||
645 | } | 659 | } |
646 | 660 | ||
647 | /** | 661 | /** |
@@ -1378,6 +1392,58 @@ static void ide_port_cable_detect(ide_hwif_t *hwif) | |||
1378 | } | 1392 | } |
1379 | } | 1393 | } |
1380 | 1394 | ||
1395 | static ssize_t store_delete_devices(struct device *portdev, | ||
1396 | struct device_attribute *attr, | ||
1397 | const char *buf, size_t n) | ||
1398 | { | ||
1399 | ide_hwif_t *hwif = dev_get_drvdata(portdev); | ||
1400 | |||
1401 | if (strncmp(buf, "1", n)) | ||
1402 | return -EINVAL; | ||
1403 | |||
1404 | ide_port_unregister_devices(hwif); | ||
1405 | |||
1406 | return n; | ||
1407 | }; | ||
1408 | |||
1409 | static DEVICE_ATTR(delete_devices, S_IWUSR, NULL, store_delete_devices); | ||
1410 | |||
1411 | static ssize_t store_scan(struct device *portdev, | ||
1412 | struct device_attribute *attr, | ||
1413 | const char *buf, size_t n) | ||
1414 | { | ||
1415 | ide_hwif_t *hwif = dev_get_drvdata(portdev); | ||
1416 | |||
1417 | if (strncmp(buf, "1", n)) | ||
1418 | return -EINVAL; | ||
1419 | |||
1420 | ide_port_unregister_devices(hwif); | ||
1421 | ide_port_scan(hwif); | ||
1422 | |||
1423 | return n; | ||
1424 | }; | ||
1425 | |||
1426 | static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); | ||
1427 | |||
1428 | static struct device_attribute *ide_port_attrs[] = { | ||
1429 | &dev_attr_delete_devices, | ||
1430 | &dev_attr_scan, | ||
1431 | NULL | ||
1432 | }; | ||
1433 | |||
1434 | static int ide_sysfs_register_port(ide_hwif_t *hwif) | ||
1435 | { | ||
1436 | int i, rc; | ||
1437 | |||
1438 | for (i = 0; ide_port_attrs[i]; i++) { | ||
1439 | rc = device_create_file(hwif->portdev, ide_port_attrs[i]); | ||
1440 | if (rc) | ||
1441 | break; | ||
1442 | } | ||
1443 | |||
1444 | return rc; | ||
1445 | } | ||
1446 | |||
1381 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | 1447 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) |
1382 | { | 1448 | { |
1383 | ide_hwif_t *hwif, *mate = NULL; | 1449 | ide_hwif_t *hwif, *mate = NULL; |
@@ -1474,6 +1540,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1474 | hwif = &ide_hwifs[idx[i]]; | 1540 | hwif = &ide_hwifs[idx[i]]; |
1475 | 1541 | ||
1476 | if (hwif->present) { | 1542 | if (hwif->present) { |
1543 | ide_sysfs_register_port(hwif); | ||
1477 | ide_proc_register_port(hwif); | 1544 | ide_proc_register_port(hwif); |
1478 | ide_proc_port_register_devices(hwif); | 1545 | ide_proc_port_register_devices(hwif); |
1479 | } | 1546 | } |