mtd: blktrans: allow FTL drivers to export sysfs attributes
authorMaxim Levitsky <maximlevitsky@gmail.com>
Mon, 22 Feb 2010 18:39:33 +0000 (20:39 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 26 Feb 2010 17:37:40 +0000 (17:37 +0000)
This patch adds an ability to export sysfs attributes below
the block disk device.

This can be used to pass the udev an information about the FTL
and could include the vendor, serial, version, etc...

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtd_blkdevs.c
include/linux/mtd/blktrans.h

index 646cc84ae69211259be4c4c2437d3dc121be72bd..9dd23d6acbb6c9b452a74a77514bed8379874946 100644 (file)
@@ -379,6 +379,10 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
                set_disk_ro(gd, 1);
 
        add_disk(gd);
+
+       if (new->disk_attributes)
+               sysfs_create_group(&disk_to_dev(gd)->kobj,
+                                       new->disk_attributes);
        return 0;
 error4:
        module_put(tr->owner);
@@ -405,6 +409,10 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
        /* Stop new requests to arrive */
        del_gendisk(old->disk);
 
+       if (old->disk_attributes)
+               sysfs_remove_group(&disk_to_dev(old->disk)->kobj,
+                                               old->disk_attributes);
+
        /* Stop the thread */
        kthread_stop(old->thread);
 
index d89b8fbba4c9988d9c082766c7ea41bf095b5aaf..b481ccd7ff3c30330046f6b24311f5fcc6e0ef0f 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/mutex.h>
 #include <linux/kref.h>
+#include <linux/sysfs.h>
 
 struct hd_geometry;
 struct mtd_info;
@@ -28,6 +29,7 @@ struct mtd_blktrans_dev {
        int open;
        struct kref ref;
        struct gendisk *disk;
+       struct attribute_group *disk_attributes;
        struct task_struct *thread;
        struct request_queue *rq;
        spinlock_t queue_lock;