diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 4 | ||||
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 24 | ||||
-rw-r--r-- | drivers/mtd/mtdchar.c | 10 |
3 files changed, 16 insertions, 22 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 91fbba767635..8c295f40d2ac 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -224,7 +224,7 @@ static void block2mtd_free_device(struct block2mtd_dev *dev) | |||
224 | if (dev->blkdev) { | 224 | if (dev->blkdev) { |
225 | invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping, | 225 | invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping, |
226 | 0, -1); | 226 | 0, -1); |
227 | close_bdev_excl(dev->blkdev); | 227 | close_bdev_exclusive(dev->blkdev, FMODE_READ|FMODE_WRITE); |
228 | } | 228 | } |
229 | 229 | ||
230 | kfree(dev); | 230 | kfree(dev); |
@@ -246,7 +246,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
246 | return NULL; | 246 | return NULL; |
247 | 247 | ||
248 | /* Get a handle on the device */ | 248 | /* Get a handle on the device */ |
249 | bdev = open_bdev_excl(devname, O_RDWR, NULL); | 249 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, NULL); |
250 | #ifndef MODULE | 250 | #ifndef MODULE |
251 | if (IS_ERR(bdev)) { | 251 | if (IS_ERR(bdev)) { |
252 | 252 | ||
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 681d5aca2af4..1409f01406f6 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -133,15 +133,12 @@ static void mtd_blktrans_request(struct request_queue *rq) | |||
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | static int blktrans_open(struct inode *i, struct file *f) | 136 | static int blktrans_open(struct block_device *bdev, fmode_t mode) |
137 | { | 137 | { |
138 | struct mtd_blktrans_dev *dev; | 138 | struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data; |
139 | struct mtd_blktrans_ops *tr; | 139 | struct mtd_blktrans_ops *tr = dev->tr; |
140 | int ret = -ENODEV; | 140 | int ret = -ENODEV; |
141 | 141 | ||
142 | dev = i->i_bdev->bd_disk->private_data; | ||
143 | tr = dev->tr; | ||
144 | |||
145 | if (!try_module_get(dev->mtd->owner)) | 142 | if (!try_module_get(dev->mtd->owner)) |
146 | goto out; | 143 | goto out; |
147 | 144 | ||
@@ -164,15 +161,12 @@ static int blktrans_open(struct inode *i, struct file *f) | |||
164 | return ret; | 161 | return ret; |
165 | } | 162 | } |
166 | 163 | ||
167 | static int blktrans_release(struct inode *i, struct file *f) | 164 | static int blktrans_release(struct gendisk *disk, fmode_t mode) |
168 | { | 165 | { |
169 | struct mtd_blktrans_dev *dev; | 166 | struct mtd_blktrans_dev *dev = disk->private_data; |
170 | struct mtd_blktrans_ops *tr; | 167 | struct mtd_blktrans_ops *tr = dev->tr; |
171 | int ret = 0; | 168 | int ret = 0; |
172 | 169 | ||
173 | dev = i->i_bdev->bd_disk->private_data; | ||
174 | tr = dev->tr; | ||
175 | |||
176 | if (tr->release) | 170 | if (tr->release) |
177 | ret = tr->release(dev); | 171 | ret = tr->release(dev); |
178 | 172 | ||
@@ -194,10 +188,10 @@ static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
194 | return -ENOTTY; | 188 | return -ENOTTY; |
195 | } | 189 | } |
196 | 190 | ||
197 | static int blktrans_ioctl(struct inode *inode, struct file *file, | 191 | static int blktrans_ioctl(struct block_device *bdev, fmode_t mode, |
198 | unsigned int cmd, unsigned long arg) | 192 | unsigned int cmd, unsigned long arg) |
199 | { | 193 | { |
200 | struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data; | 194 | struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data; |
201 | struct mtd_blktrans_ops *tr = dev->tr; | 195 | struct mtd_blktrans_ops *tr = dev->tr; |
202 | 196 | ||
203 | switch (cmd) { | 197 | switch (cmd) { |
@@ -215,7 +209,7 @@ static struct block_device_operations mtd_blktrans_ops = { | |||
215 | .owner = THIS_MODULE, | 209 | .owner = THIS_MODULE, |
216 | .open = blktrans_open, | 210 | .open = blktrans_open, |
217 | .release = blktrans_release, | 211 | .release = blktrans_release, |
218 | .ioctl = blktrans_ioctl, | 212 | .locked_ioctl = blktrans_ioctl, |
219 | .getgeo = blktrans_getgeo, | 213 | .getgeo = blktrans_getgeo, |
220 | }; | 214 | }; |
221 | 215 | ||
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 963840e9b5bf..bcffeda2df3d 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -96,7 +96,7 @@ static int mtd_open(struct inode *inode, struct file *file) | |||
96 | return -ENODEV; | 96 | return -ENODEV; |
97 | 97 | ||
98 | /* You can't open the RO devices RW */ | 98 | /* You can't open the RO devices RW */ |
99 | if ((file->f_mode & 2) && (minor & 1)) | 99 | if ((file->f_mode & FMODE_WRITE) && (minor & 1)) |
100 | return -EACCES; | 100 | return -EACCES; |
101 | 101 | ||
102 | lock_kernel(); | 102 | lock_kernel(); |
@@ -114,7 +114,7 @@ static int mtd_open(struct inode *inode, struct file *file) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /* You can't open it RW if it's not a writeable device */ | 116 | /* You can't open it RW if it's not a writeable device */ |
117 | if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { | 117 | if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { |
118 | put_mtd_device(mtd); | 118 | put_mtd_device(mtd); |
119 | ret = -EACCES; | 119 | ret = -EACCES; |
120 | goto out; | 120 | goto out; |
@@ -144,7 +144,7 @@ static int mtd_close(struct inode *inode, struct file *file) | |||
144 | DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); | 144 | DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); |
145 | 145 | ||
146 | /* Only sync if opened RW */ | 146 | /* Only sync if opened RW */ |
147 | if ((file->f_mode & 2) && mtd->sync) | 147 | if ((file->f_mode & FMODE_WRITE) && mtd->sync) |
148 | mtd->sync(mtd); | 148 | mtd->sync(mtd); |
149 | 149 | ||
150 | put_mtd_device(mtd); | 150 | put_mtd_device(mtd); |
@@ -443,7 +443,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
443 | { | 443 | { |
444 | struct erase_info *erase; | 444 | struct erase_info *erase; |
445 | 445 | ||
446 | if(!(file->f_mode & 2)) | 446 | if(!(file->f_mode & FMODE_WRITE)) |
447 | return -EPERM; | 447 | return -EPERM; |
448 | 448 | ||
449 | erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); | 449 | erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); |
@@ -497,7 +497,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
497 | struct mtd_oob_buf __user *user_buf = argp; | 497 | struct mtd_oob_buf __user *user_buf = argp; |
498 | uint32_t retlen; | 498 | uint32_t retlen; |
499 | 499 | ||
500 | if(!(file->f_mode & 2)) | 500 | if(!(file->f_mode & FMODE_WRITE)) |
501 | return -EPERM; | 501 | return -EPERM; |
502 | 502 | ||
503 | if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) | 503 | if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) |