RE: [PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-04 Thread Kyungmin Park
To make a modules, we have to export "get_mtd_blktrans_gendisk".

"get_mtd_blktrans_gendisk" is used at mtdswap.

>  
> +struct gendisk *get_mtd_blktrans_gendisk(struct 
> mtd_blktrans_dev *dev)
> +{
> + return dev->blkcore_priv;
> +}
> +

@@ -469,6 +480,7 @@ EXPORT_SYMBOL_GPL(register_mtd_blktrans);
 EXPORT_SYMBOL_GPL(deregister_mtd_blktrans);
 EXPORT_SYMBOL_GPL(add_mtd_blktrans_dev);
 EXPORT_SYMBOL_GPL(del_mtd_blktrans_dev);
+EXPORT_SYMBOL_GPL(get_mtd_blktrans_gendisk);

 MODULE_AUTHOR("David Woodhouse <[EMAIL PROTECTED]>");
 MODULE_LICENSE("GPL");

Thank you,
Kyungmin Park

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


Re: [PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-04 Thread Arnd Bergmann
On Friday 02 March 2007 16:55:02 Richard Purdie wrote:
> Allow mtd block drivers to customise their ioctl functions. Also
> allow the drivers to obtain the gendisk struct since ioctl
> functions can need this.

Are you sure that this is a good idea? I'd rather not open
up this method of letting the individual drivers to bad things.

> 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.

This part looks fine to me.

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


Re: [PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-04 Thread Arnd Bergmann
On Friday 02 March 2007 16:55:02 Richard Purdie wrote:
 Allow mtd block drivers to customise their ioctl functions. Also
 allow the drivers to obtain the gendisk struct since ioctl
 functions can need this.

Are you sure that this is a good idea? I'd rather not open
up this method of letting the individual drivers to bad things.

 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.

This part looks fine to me.

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


RE: [PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-04 Thread Kyungmin Park
To make a modules, we have to export get_mtd_blktrans_gendisk.

get_mtd_blktrans_gendisk is used at mtdswap.

  
 +struct gendisk *get_mtd_blktrans_gendisk(struct 
 mtd_blktrans_dev *dev)
 +{
 + return dev-blkcore_priv;
 +}
 +

@@ -469,6 +480,7 @@ EXPORT_SYMBOL_GPL(register_mtd_blktrans);
 EXPORT_SYMBOL_GPL(deregister_mtd_blktrans);
 EXPORT_SYMBOL_GPL(add_mtd_blktrans_dev);
 EXPORT_SYMBOL_GPL(del_mtd_blktrans_dev);
+EXPORT_SYMBOL_GPL(get_mtd_blktrans_gendisk);

 MODULE_AUTHOR(David Woodhouse [EMAIL PROTECTED]);
 MODULE_LICENSE(GPL);

Thank you,
Kyungmin Park

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


[PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-02 Thread Richard Purdie
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 <[EMAIL PROTECTED]>

---
 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.c2007-03-02 14:46:29.0 
+
+++ linux/drivers/mtd/mtd_blkdevs.c 2007-03-02 14:46:47.0 +
@@ -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(_table_mutex)) {
Index: linux/include/linux/mtd/blktrans.h
===
--- linux.orig/include/linux/mtd/blktrans.h 2007-02-28 18:16:52.0 
+
+++ linux/include/linux/mtd/blktrans.h  2007-03-02 14:46:47.0 +
@@ -11,6 +11,7 @@
 #define __MTD_TRANS_H__
 
 #include 
+#include 
 
 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 [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/9] mtd: Allow mtd block device drivers to have a custom ioctl function

2007-03-02 Thread Richard Purdie
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 [EMAIL PROTECTED]

---
 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.c2007-03-02 14:46:29.0 
+
+++ linux/drivers/mtd/mtd_blkdevs.c 2007-03-02 14:46:47.0 +
@@ -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.0 
+
+++ linux/include/linux/mtd/blktrans.h  2007-03-02 14:46:47.0 +
@@ -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 [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/