Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 282914
b: refs/heads/master
c: 3813456
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and David Woodhouse committed Jan 9, 2012
1 parent 0bdecad commit 712cb19
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 327cf2922b4edf0439b219469722d2a502e37349
refs/heads/master: 381345652fca688aeaa967c231e5075cf68d05b6
3 changes: 1 addition & 2 deletions trunk/drivers/mtd/maps/scb2_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ scb2_flash_remove(struct pci_dev *dev)
return;

/* disable flash writes */
if (scb2_mtd->lock)
mtd_lock(scb2_mtd, 0, scb2_mtd->size);
mtd_lock(scb2_mtd, 0, scb2_mtd->size);

mtd_device_unregister(scb2_mtd);
map_destroy(scb2_mtd);
Expand Down
15 changes: 3 additions & 12 deletions trunk/drivers/mtd/mtdchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT;

if (!mtd->lock)
ret = -EOPNOTSUPP;
else
ret = mtd_lock(mtd, einfo.start, einfo.length);
ret = mtd_lock(mtd, einfo.start, einfo.length);
break;
}

Expand All @@ -828,10 +825,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT;

if (!mtd->unlock)
ret = -EOPNOTSUPP;
else
ret = mtd_unlock(mtd, einfo.start, einfo.length);
ret = mtd_unlock(mtd, einfo.start, einfo.length);
break;
}

Expand All @@ -842,10 +836,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT;

if (!mtd->is_locked)
ret = -EOPNOTSUPP;
else
ret = mtd_is_locked(mtd, einfo.start, einfo.length);
ret = mtd_is_locked(mtd, einfo.start, einfo.length);
break;
}

Expand Down
18 changes: 6 additions & 12 deletions trunk/drivers/mtd/mtdconcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,9 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;

if (subdev->lock) {
err = mtd_lock(subdev, ofs, size);
if (err)
break;
} else
err = -EOPNOTSUPP;
err = mtd_lock(subdev, ofs, size);
if (err)
break;

len -= size;
if (len == 0)
Expand Down Expand Up @@ -595,12 +592,9 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;

if (subdev->unlock) {
err = mtd_unlock(subdev, ofs, size);
if (err)
break;
} else
err = -EOPNOTSUPP;
err = mtd_unlock(subdev, ofs, size);
if (err)
break;

len -= size;
if (len == 0)
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ int add_mtd_device(struct mtd_info *mtd)
mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;

/* Some chips always power up locked. Unlock them now */
if ((mtd->flags & MTD_WRITEABLE)
&& (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) {
if (mtd_unlock(mtd, 0, mtd->size))
if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
error = mtd_unlock(mtd, 0, mtd->size);
if (error && error != -EOPNOTSUPP)
printk(KERN_WARNING
"%s: unlock failed, writes may not work\n",
mtd->name);
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,22 @@ static inline void mtd_sync(struct mtd_info *mtd)
/* Chip-supported device locking */
static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->lock)
return -EOPNOTSUPP;
return mtd->lock(mtd, ofs, len);
}

static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->unlock)
return -EOPNOTSUPP;
return mtd->unlock(mtd, ofs, len);
}

static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
if (!mtd->is_locked)
return -EOPNOTSUPP;
return mtd->is_locked(mtd, ofs, len);
}

Expand Down

0 comments on commit 712cb19

Please sign in to comment.