+static DEFINE_MUTEX(idefloppy_ref_mutex);
+
+#define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)
+
+#define ide_floppy_g(disk) \
+ container_of((disk)->private_data, struct ide_floppy_obj, driver)
+
+static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
+{
+ struct ide_floppy_obj *floppy = NULL;
+
+ mutex_lock(&idefloppy_ref_mutex);
+ floppy = ide_floppy_g(disk);
+ if (floppy)
+ kref_get(&floppy->kref);
+ mutex_unlock(&idefloppy_ref_mutex);
+ return floppy;
+}
+
+static void ide_floppy_release(struct kref *);
+
+static void ide_floppy_put(struct ide_floppy_obj *floppy)
+{
+ mutex_lock(&idefloppy_ref_mutex);
+ kref_put(&floppy->kref, ide_floppy_release);
+ mutex_unlock(&idefloppy_ref_mutex);
+}
+