lkml.org 
[lkml]   [2007]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function
From
Date
Allow mtd block drivers to customise their ioctl functions. Also
allow the drivers to obtain the gendisk struct since ioctl
functions can need this.

This also moves the mtd ioctl functions from locked to unlocked.
As far as I can see, nothing in the mtd code has locking problems.

Signed-off-by: Richard Purdie <rpurdie@openedhand.com>

---
drivers/mtd/mtd_blkdevs.c | 14 +++++++++++---
include/linux/mtd/blktrans.h | 5 +++++
2 files changed, 16 insertions(+), 3 deletions(-)

Index: linux/drivers/mtd/mtd_blkdevs.c
===================================================================
--- linux.orig/drivers/mtd/mtd_blkdevs.c 2007-03-02 14:46:29.000000000 +0000
+++ linux/drivers/mtd/mtd_blkdevs.c 2007-03-02 14:46:47.000000000 +0000
@@ -204,9 +204,10 @@ static int blktrans_getgeo(struct block_
return -ENOTTY;
}

-static int blktrans_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long blktrans_unlocked_ioctl(struct file *file, unsigned cmd,
+ unsigned long arg)
{
+ struct inode *inode = file->f_dentry->d_inode;
struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data;
struct mtd_blktrans_ops *tr = dev->tr;

@@ -217,6 +218,8 @@ static int blktrans_ioctl(struct inode *
/* The core code did the work, we had nothing to do. */
return 0;
default:
+ if (tr->ioctl)
+ return tr->ioctl(dev, cmd, arg);
return -ENOTTY;
}
}
@@ -225,7 +228,7 @@ struct block_device_operations mtd_blktr
.owner = THIS_MODULE,
.open = blktrans_open,
.release = blktrans_release,
- .ioctl = blktrans_ioctl,
+ .unlocked_ioctl = blktrans_unlocked_ioctl,
.getgeo = blktrans_getgeo,
};

@@ -312,6 +315,11 @@ int add_mtd_blktrans_dev(struct mtd_blkt
return 0;
}

+struct gendisk *get_mtd_blktrans_gendisk(struct mtd_blktrans_dev *dev)
+{
+ return dev->blkcore_priv;
+}
+
int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
{
if (!!mutex_trylock(&mtd_table_mutex)) {
Index: linux/include/linux/mtd/blktrans.h
===================================================================
--- linux.orig/include/linux/mtd/blktrans.h 2007-02-28 18:16:52.000000000 +0000
+++ linux/include/linux/mtd/blktrans.h 2007-03-02 14:46:47.000000000 +0000
@@ -11,6 +11,7 @@
#define __MTD_TRANS_H__

#include <linux/mutex.h>
+#include <linux/genhd.h>

struct hd_geometry;
struct mtd_info;
@@ -48,6 +49,9 @@ struct mtd_blktrans_ops {
int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
int (*flush)(struct mtd_blktrans_dev *dev);

+ /* Optional ioctl passthrough */
+ int (*ioctl)(struct mtd_blktrans_dev *dev, unsigned int cmd, unsigned long arg);
+
/* Called with mtd_table_mutex held; no race with add/remove */
int (*open)(struct mtd_blktrans_dev *dev);
int (*release)(struct mtd_blktrans_dev *dev);
@@ -68,6 +72,7 @@ extern int register_mtd_blktrans(struct
extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
+extern struct gendisk *get_mtd_blktrans_gendisk(struct mtd_blktrans_dev *dev);


#endif /* __MTD_TRANS_H__ */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-03-02 16:59    [W:1.143 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site