Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 231687
b: refs/heads/master
c: a7e93dc
h: refs/heads/master
i:
  231685: e2eee57
  231683: 706d067
  231679: 3390df4
v: v3
  • Loading branch information
Roman Tereshonkov authored and David Woodhouse committed Dec 3, 2010
1 parent 68e00ca commit f573303
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 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: e14feafbe0d5c6d64bb6fe4eba928cb57ac9a4c8
refs/heads/master: a7e93dcd9aacb3ef4acfcc4310577f3ae0741821
8 changes: 4 additions & 4 deletions trunk/drivers/mtd/mtdchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,6 @@ static int mtd_blkpg_ioctl(struct mtd_info *mtd,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;

/* Only master mtd device must be used to control partitions */
if (!mtd_is_master(mtd))
return -EINVAL;

if (copy_from_user(&a, arg, sizeof(struct blkpg_ioctl_arg)))
return -EFAULT;

Expand All @@ -535,6 +531,10 @@ static int mtd_blkpg_ioctl(struct mtd_info *mtd,
switch (a.op) {
case BLKPG_ADD_PARTITION:

/* Only master mtd device must be used to add partitions */
if (mtd_is_partition(mtd))
return -EINVAL;

return mtd_add_partition(mtd, p.devname, p.start, p.length);

case BLKPG_DEL_PARTITION:
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,19 +720,19 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
}
EXPORT_SYMBOL_GPL(parse_mtd_partitions);

int mtd_is_master(struct mtd_info *mtd)
int mtd_is_partition(struct mtd_info *mtd)
{
struct mtd_part *part;
int nopart = 0;
int ispart = 0;

mutex_lock(&mtd_partitions_mutex);
list_for_each_entry(part, &mtd_partitions, list)
if (&part->mtd == mtd) {
nopart = 1;
ispart = 1;
break;
}
mutex_unlock(&mtd_partitions_mutex);

return nopart;
return ispart;
}
EXPORT_SYMBOL_GPL(mtd_is_master);
EXPORT_SYMBOL_GPL(mtd_is_partition);
2 changes: 1 addition & 1 deletion trunk/include/linux/mtd/partitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static inline int mtd_has_cmdlinepart(void) { return 1; }
static inline int mtd_has_cmdlinepart(void) { return 0; }
#endif

int mtd_is_master(struct mtd_info *mtd);
int mtd_is_partition(struct mtd_info *mtd);
int mtd_add_partition(struct mtd_info *master, char *name,
long long offset, long long length);
int mtd_del_partition(struct mtd_info *master, int partno);
Expand Down

0 comments on commit f573303

Please sign in to comment.