Skip to content

Commit 7799f9a

Browse files
dedekindDavid Woodhouse
authored andcommitted
mtd: introduce mtd_lock interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 85f2f2a commit 7799f9a

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎drivers/mtd/maps/scb2_flash.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ scb2_flash_remove(struct pci_dev *dev)
205205

206206
/* disable flash writes */
207207
if (scb2_mtd->lock)
208-
scb2_mtd->lock(scb2_mtd, 0, scb2_mtd->size);
208+
mtd_lock(scb2_mtd, 0, scb2_mtd->size);
209209

210210
mtd_device_unregister(scb2_mtd);
211211
map_destroy(scb2_mtd);

‎drivers/mtd/mtdchar.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
824824
if (!mtd->lock)
825825
ret = -EOPNOTSUPP;
826826
else
827-
ret = mtd->lock(mtd, einfo.start, einfo.length);
827+
ret = mtd_lock(mtd, einfo.start, einfo.length);
828828
break;
829829
}
830830

‎drivers/mtd/mtdconcat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
556556
size = len;
557557

558558
if (subdev->lock) {
559-
err = subdev->lock(subdev, ofs, size);
559+
err = mtd_lock(subdev, ofs, size);
560560
if (err)
561561
break;
562562
} else

‎drivers/mtd/mtdpart.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
279279
struct mtd_part *part = PART(mtd);
280280
if ((len + ofs) > mtd->size)
281281
return -EINVAL;
282-
return part->master->lock(part->master, ofs + part->offset, len);
282+
return mtd_lock(part->master, ofs + part->offset, len);
283283
}
284284

285285
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)

‎include/linux/mtd/mtd.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,13 @@ struct mtd_info {
207207
int (*writev) (struct mtd_info *mtd, const struct kvec *vecs,
208208
unsigned long count, loff_t to, size_t *retlen);
209209
void (*sync) (struct mtd_info *mtd);
210+
int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
210211

211212
/* Backing device capabilities for this device
212213
* - provides mmap capabilities
213214
*/
214215
struct backing_dev_info *backing_dev_info;
215216

216-
/* Chip-supported device locking */
217-
int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
218217
int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
219218
int (*is_locked) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
220219

@@ -384,6 +383,12 @@ static inline void mtd_sync(struct mtd_info *mtd)
384383
mtd->sync(mtd);
385384
}
386385

386+
/* Chip-supported device locking */
387+
static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
388+
{
389+
return mtd->lock(mtd, ofs, len);
390+
}
391+
387392
static inline struct mtd_info *dev_to_mtd(struct device *dev)
388393
{
389394
return dev ? dev_get_drvdata(dev) : NULL;

0 commit comments

Comments
 (0)