+static DEFINE_MUTEX(idetape_ref_mutex);
+
+static struct class *idetape_sysfs_class;
+
+#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)
+
+#define ide_tape_g(disk) \
+ container_of((disk)->private_data, struct ide_tape_obj, driver)
+
+static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
+{
+ struct ide_tape_obj *tape = NULL;
+
+ mutex_lock(&idetape_ref_mutex);
+ tape = ide_tape_g(disk);
+ if (tape)
+ kref_get(&tape->kref);
+ mutex_unlock(&idetape_ref_mutex);
+ return tape;
+}
+
+static void ide_tape_release(struct kref *);
+
+static void ide_tape_put(struct ide_tape_obj *tape)
+{
+ mutex_lock(&idetape_ref_mutex);
+ kref_put(&tape->kref, ide_tape_release);
+ mutex_unlock(&idetape_ref_mutex);
+}
+