diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-tape.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index ee38e6b143a4..95abe981530d 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1013,6 +1013,8 @@ typedef struct ide_tape_obj { | |||
1013 | 1013 | ||
1014 | static DECLARE_MUTEX(idetape_ref_sem); | 1014 | static DECLARE_MUTEX(idetape_ref_sem); |
1015 | 1015 | ||
1016 | static struct class *idetape_sysfs_class; | ||
1017 | |||
1016 | #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) | 1018 | #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) |
1017 | 1019 | ||
1018 | #define ide_tape_g(disk) \ | 1020 | #define ide_tape_g(disk) \ |
@@ -4704,6 +4706,10 @@ static void ide_tape_release(struct kref *kref) | |||
4704 | 4706 | ||
4705 | drive->dsc_overlap = 0; | 4707 | drive->dsc_overlap = 0; |
4706 | drive->driver_data = NULL; | 4708 | drive->driver_data = NULL; |
4709 | class_device_destroy(idetape_sysfs_class, | ||
4710 | MKDEV(IDETAPE_MAJOR, tape->minor)); | ||
4711 | class_device_destroy(idetape_sysfs_class, | ||
4712 | MKDEV(IDETAPE_MAJOR, tape->minor + 128)); | ||
4707 | devfs_remove("%s/mt", drive->devfs_name); | 4713 | devfs_remove("%s/mt", drive->devfs_name); |
4708 | devfs_remove("%s/mtn", drive->devfs_name); | 4714 | devfs_remove("%s/mtn", drive->devfs_name); |
4709 | devfs_unregister_tape(g->number); | 4715 | devfs_unregister_tape(g->number); |
@@ -4878,6 +4884,11 @@ static int ide_tape_probe(struct device *dev) | |||
4878 | 4884 | ||
4879 | idetape_setup(drive, tape, minor); | 4885 | idetape_setup(drive, tape, minor); |
4880 | 4886 | ||
4887 | class_device_create(idetape_sysfs_class, | ||
4888 | MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); | ||
4889 | class_device_create(idetape_sysfs_class, | ||
4890 | MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); | ||
4891 | |||
4881 | devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), | 4892 | devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), |
4882 | S_IFCHR | S_IRUGO | S_IWUGO, | 4893 | S_IFCHR | S_IRUGO | S_IWUGO, |
4883 | "%s/mt", drive->devfs_name); | 4894 | "%s/mt", drive->devfs_name); |
@@ -4903,6 +4914,7 @@ MODULE_LICENSE("GPL"); | |||
4903 | static void __exit idetape_exit (void) | 4914 | static void __exit idetape_exit (void) |
4904 | { | 4915 | { |
4905 | driver_unregister(&idetape_driver.gen_driver); | 4916 | driver_unregister(&idetape_driver.gen_driver); |
4917 | class_destroy(idetape_sysfs_class); | ||
4906 | unregister_chrdev(IDETAPE_MAJOR, "ht"); | 4918 | unregister_chrdev(IDETAPE_MAJOR, "ht"); |
4907 | } | 4919 | } |
4908 | 4920 | ||
@@ -4911,11 +4923,33 @@ static void __exit idetape_exit (void) | |||
4911 | */ | 4923 | */ |
4912 | static int idetape_init (void) | 4924 | static int idetape_init (void) |
4913 | { | 4925 | { |
4926 | int error = 1; | ||
4927 | idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); | ||
4928 | if (IS_ERR(idetape_sysfs_class)) { | ||
4929 | idetape_sysfs_class = NULL; | ||
4930 | printk(KERN_ERR "Unable to create sysfs class for ide tapes\n"); | ||
4931 | error = -EBUSY; | ||
4932 | goto out; | ||
4933 | } | ||
4934 | |||
4914 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { | 4935 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { |
4915 | printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); | 4936 | printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); |
4916 | return -EBUSY; | 4937 | error = -EBUSY; |
4938 | goto out_free_class; | ||
4917 | } | 4939 | } |
4918 | return driver_register(&idetape_driver.gen_driver); | 4940 | |
4941 | error = driver_register(&idetape_driver.gen_driver); | ||
4942 | if (error) | ||
4943 | goto out_free_driver; | ||
4944 | |||
4945 | return 0; | ||
4946 | |||
4947 | out_free_driver: | ||
4948 | driver_unregister(&idetape_driver.gen_driver); | ||
4949 | out_free_class: | ||
4950 | class_destroy(idetape_sysfs_class); | ||
4951 | out: | ||
4952 | return error; | ||
4919 | } | 4953 | } |
4920 | 4954 | ||
4921 | module_init(idetape_init); | 4955 | module_init(idetape_init); |