aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/build.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-26 06:46:46 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-26 12:15:17 -0500
commitb6b76ba466bbd47397efad0fdaeaa5ebf7d462c7 (patch)
tree06af1b32c201abdc87bb852c5ba10c8acccaf9bc /drivers/mtd/ubi/build.c
parentd1f3dd6cc00f5bf744118fb2820ecdf09a1f4b73 (diff)
UBI: add mtd_num sysfs attribute
Expose number or the underlying MTD device in sysfs. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r--drivers/mtd/ubi/build.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 0ed8105f9c11..5098e6d57092 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -122,6 +122,8 @@ static struct device_attribute dev_min_io_size =
122 __ATTR(min_io_size, S_IRUGO, dev_attribute_show, NULL); 122 __ATTR(min_io_size, S_IRUGO, dev_attribute_show, NULL);
123static struct device_attribute dev_bgt_enabled = 123static struct device_attribute dev_bgt_enabled =
124 __ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL); 124 __ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL);
125static struct device_attribute dev_mtd_num =
126 __ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL);
125 127
126/** 128/**
127 * ubi_get_device - get UBI device. 129 * ubi_get_device - get UBI device.
@@ -257,8 +259,10 @@ static ssize_t dev_attribute_show(struct device *dev,
257 ret = sprintf(buf, "%d\n", ubi->min_io_size); 259 ret = sprintf(buf, "%d\n", ubi->min_io_size);
258 else if (attr == &dev_bgt_enabled) 260 else if (attr == &dev_bgt_enabled)
259 ret = sprintf(buf, "%d\n", ubi->thread_enabled); 261 ret = sprintf(buf, "%d\n", ubi->thread_enabled);
262 else if (attr == &dev_mtd_num)
263 ret = sprintf(buf, "%d\n", ubi->mtd->index);
260 else 264 else
261 BUG(); 265 ret = -EINVAL;
262 266
263 ubi_put_device(ubi); 267 ubi_put_device(ubi);
264 return ret; 268 return ret;
@@ -314,6 +318,9 @@ static int ubi_sysfs_init(struct ubi_device *ubi)
314 if (err) 318 if (err)
315 return err; 319 return err;
316 err = device_create_file(&ubi->dev, &dev_bgt_enabled); 320 err = device_create_file(&ubi->dev, &dev_bgt_enabled);
321 if (err)
322 return err;
323 err = device_create_file(&ubi->dev, &dev_mtd_num);
317 return err; 324 return err;
318} 325}
319 326
@@ -323,6 +330,7 @@ static int ubi_sysfs_init(struct ubi_device *ubi)
323 */ 330 */
324static void ubi_sysfs_close(struct ubi_device *ubi) 331static void ubi_sysfs_close(struct ubi_device *ubi)
325{ 332{
333 device_remove_file(&ubi->dev, &dev_mtd_num);
326 device_remove_file(&ubi->dev, &dev_bgt_enabled); 334 device_remove_file(&ubi->dev, &dev_bgt_enabled);
327 device_remove_file(&ubi->dev, &dev_min_io_size); 335 device_remove_file(&ubi->dev, &dev_min_io_size);
328 device_remove_file(&ubi->dev, &dev_max_vol_count); 336 device_remove_file(&ubi->dev, &dev_max_vol_count);