public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: will.dyson@gmail.com
Subject: [PATCH] add sysfs support for ide tape
Date: Thu, 27 Oct 2005 23:30:22 -0700	[thread overview]
Message-ID: <11304810222258@kroah.com> (raw)
In-Reply-To: <1130481022955@kroah.com>

[PATCH] add sysfs support for ide tape

I was recently given an old Travan tape drive and asked to do something
useful with it.  The ide-scsi + st (+serverworks ide controller) combo
results in a hard lockup of the machine which I have not had the energy to
debug, so I turned to ide-tape (which seems to work).  The system in
question debian stable, using udev to manage /dev.

The following patch to ide-tape.c allows udev to create the cdev nodes for
my drive.

Cc: Gadi Oxman <gadio@netvision.net.il>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit e801e49d1ca90da1ab0286a3688f2465cb1e45e4
tree e7983a7c7dce4213431a1b951d3d803167ed41f9
parent 271c0df6e700b3f208b1802a1e96bb9eeeaa880c
author Will Dyson <will.dyson@gmail.com> Fri, 16 Sep 2005 02:55:07 -0700
committer Greg Kroah-Hartman <gregkh@suse.de> Thu, 27 Oct 2005 22:47:59 -0700

 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 ee38e6b..95abe98 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1013,6 +1013,8 @@ typedef struct ide_tape_obj {
 
 static DECLARE_MUTEX(idetape_ref_sem);
 
+static struct class *idetape_sysfs_class;
+
 #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)
 
 #define ide_tape_g(disk) \
@@ -4704,6 +4706,10 @@ static void ide_tape_release(struct kref
 
 	drive->dsc_overlap = 0;
 	drive->driver_data = NULL;
+	class_device_destroy(idetape_sysfs_class,
+			MKDEV(IDETAPE_MAJOR, tape->minor));
+	class_device_destroy(idetape_sysfs_class,
+			MKDEV(IDETAPE_MAJOR, tape->minor + 128));
 	devfs_remove("%s/mt", drive->devfs_name);
 	devfs_remove("%s/mtn", drive->devfs_name);
 	devfs_unregister_tape(g->number);
@@ -4878,6 +4884,11 @@ static int ide_tape_probe(struct device 
 
 	idetape_setup(drive, tape, minor);
 
+	class_device_create(idetape_sysfs_class,
+			MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name);
+	class_device_create(idetape_sysfs_class,
+			MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name);
+
 	devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
 			S_IFCHR | S_IRUGO | S_IWUGO,
 			"%s/mt", drive->devfs_name);
@@ -4903,6 +4914,7 @@ MODULE_LICENSE("GPL");
 static void __exit idetape_exit (void)
 {
 	driver_unregister(&idetape_driver.gen_driver);
+	class_destroy(idetape_sysfs_class);
 	unregister_chrdev(IDETAPE_MAJOR, "ht");
 }
 
@@ -4911,11 +4923,33 @@ static void __exit idetape_exit (void)
  */
 static int idetape_init (void)
 {
+	int error = 1;
+	idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape");
+	if (IS_ERR(idetape_sysfs_class)) {
+		idetape_sysfs_class = NULL;
+		printk(KERN_ERR "Unable to create sysfs class for ide tapes\n");
+		error = -EBUSY;
+		goto out;
+	}
+
 	if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) {
 		printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
-		return -EBUSY;
+		error = -EBUSY;
+		goto out_free_class;
 	}
-	return driver_register(&idetape_driver.gen_driver);
+
+	error = driver_register(&idetape_driver.gen_driver);
+	if (error)
+		goto out_free_driver;
+
+	return 0;
+
+out_free_driver:
+	driver_unregister(&idetape_driver.gen_driver);
+out_free_class:
+	class_destroy(idetape_sysfs_class);
+out:
+	return error;
 }
 
 module_init(idetape_init);


  reply	other threads:[~2005-10-28  6:44 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28  6:29 [GIT PATCH] Driver Core patches for 2.6.14 Greg KH
2005-10-28  6:30 ` [PATCH] aoe: update to version 14 Greg KH
2005-10-28  6:30   ` [PATCH] aoe: use get_unaligned for accesses in ATA id buffer Greg KH
2005-10-28  6:30     ` [PATCH] kobject_uevent.c has a typo in a comment Greg KH
2005-10-28  6:30       ` [PATCH] changes device to driver in porting.txt Greg KH
2005-10-28  6:30         ` [PATCH] kobject: fix gfp flags type Greg KH
2005-10-28  6:30           ` [PATCH] pci device wakeup flags Greg KH
2005-10-28  6:30             ` [PATCH] driver model " Greg KH
2005-10-28  6:30               ` Greg KH [this message]
2005-10-28  6:30                 ` [PATCH] usb device " Greg KH
2005-10-28  6:30                   ` [PATCH] I2O: Clean up some pretty bad driver model abuses in the i2o code Greg KH
2005-10-28  6:30                     ` [PATCH] Driver core: pass interface to class interface methods Greg KH
2005-10-28  6:30                       ` [PATCH] Driver core: send hotplug event before adding class interfaces Greg KH
2005-10-28  6:30                         ` [PATCH] I2O: remove i2o_device_class Greg KH
2005-10-28  6:30                           ` [PATCH] add sysfs attr to re-emit device hotplug event Greg KH
2005-10-28  6:30                             ` [PATCH] I2O: remove class interface Greg KH
2005-10-28  6:30                               ` [PATCH] Driver Core: add the ability for class_device structures to be nested Greg KH
2005-10-28  6:30                                 ` [PATCH] Driver Core: fix up all callers of class_device_create() Greg KH
2005-10-28  6:30                                   ` [PATCH] Input: prepare to sysfs integration Greg KH
2005-10-28  6:30                                     ` [PATCH] Driver Core: document struct class_device properly Greg KH
2005-10-28  6:30                                       ` [PATCH] drivers/input/mouse: convert to dynamic input_dev allocation Greg KH
2005-10-28  6:30                                         ` [PATCH] Input: kill devfs references Greg KH
2005-10-28  6:30                                           ` [PATCH] Input: convert sonypi to dynamic input_dev allocation Greg KH
2005-10-28  6:30                                             ` [PATCH] Input: convert ucb1x00-ts " Greg KH
2005-10-28  6:30                                               ` [PATCH] drivers/input/keyboard: convert " Greg KH
2005-10-28  6:30                                                 ` [PATCH] Input: convert onetouch " Greg KH
2005-10-28  6:30                                                   ` [PATCH] drivers/input/touchscreen: convert " Greg KH
2005-10-28  6:55                                                 ` [PATCH] drivers/input/keyboard: " Jan-Benedict Glaw
2005-10-28  7:05                                                   ` Dmitry Torokhov
2005-10-29  5:59                                                     ` Dmitry Torokhov
2005-10-29 14:37                                                       ` Jan-Benedict Glaw
2005-10-29 15:04                                                       ` Jan-Benedict Glaw
2005-10-29 16:28                                                         ` Dmitry Torokhov
2005-10-29 18:53                                                           ` Jan-Benedict Glaw
2005-10-31  7:02                                                             ` Dmitry Torokhov
2005-10-31  7:20                                                               ` [PATCH] input/lkkbd: misc fixes Jan-Benedict Glaw
2005-10-28  6:54                                       ` [PATCH] Driver Core: document struct class_device properly Dmitry Torokhov
2005-10-28 19:09                                         ` Greg KH
2005-10-28 19:18                                           ` Dmitry Torokhov
2005-11-07  8:00                                           ` Miles Bader
2005-11-07 17:00                                             ` Greg KH
2005-10-29  7:55               ` [PATCH] driver model wakeup flags Pavel Machek
2005-11-02 21:59                 ` Greg KH
2005-11-04 17:43                   ` David Brownell
2005-10-28 10:51             ` [PATCH] pci device " Andrew Morton
2005-10-28 14:31               ` Linus Torvalds
2005-10-28 23:03                 ` Benjamin Herrenschmidt
2005-10-28 15:50               ` Greg KH
2005-10-28 19:34                 ` Andrew Morton
2005-10-28 19:45                   ` Greg KH
2005-10-28 19:47                   ` Linus Torvalds
2005-10-28 19:56                     ` Russell King
2005-10-28 20:08                       ` Greg KH
2005-10-28 20:01                     ` Greg KH
2005-10-28  9:21           ` [PATCH] kobject: fix gfp flags type Al Viro
2005-10-28 17:48 ` [GIT PATCH] Driver Core patches for 2.6.14 Greg KH
2005-10-28 18:55   ` Jan-Benedict Glaw
2005-10-28 19:11     ` Greg KH
2005-10-28 19:16       ` Jan-Benedict Glaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11304810222258@kroah.com \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.dyson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox