summaryrefslogtreecommitdiff
path: root/drivers/mmc/card/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/card/block.c')
-rw-r--r--drivers/mmc/card/block.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index d5b90ca4bc3..dc783c0ac22 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -192,7 +192,7 @@ static ssize_t boot_partition_ro_lock_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int ret;
- struct mmc_blk_data *md;
+ struct mmc_blk_data *md, *part_md;
struct mmc_card *card;
u8 set = 0;
@@ -214,14 +214,22 @@ static ssize_t boot_partition_ro_lock_store(struct device *dev,
set,
card->ext_csd.part_time);
if (ret)
- pr_err("Boot Partition Lock failed: %d\n", ret);
+ pr_err("Boot Partition Lock failed: %d", ret);
else
card->ext_csd.boot_locked = set;
mmc_release_host(card->host);
if (!ret)
- set_disk_ro(md->disk, 1);
+ list_for_each_entry(part_md, &md->part, part)
+ if (part_md->area_type ==
+ MMC_BLK_DATA_AREA_BOOT) {
+ pr_info("%s: Locking boot partition "
+ "%s",
+ part_md->disk->disk_name,
+ buf);
+ set_disk_ro(part_md->disk, 1);
+ }
}
ret = count;
@@ -1418,11 +1426,11 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
if (!subname) {
md->name_idx = find_first_zero_bit(name_use, max_devices);
__set_bit(md->name_idx, name_use);
- } else {
+ } else
md->name_idx = ((struct mmc_blk_data *)
dev_to_disk(parent)->private_data)->name_idx;
- md->area_type = area_type;
- }
+
+ md->area_type = area_type;
/*
* Set the read-only status based on the supported commands
@@ -1518,7 +1526,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
size = card->csd.capacity << (card->csd.read_blkbits - 9);
}
- md = mmc_blk_alloc_req(card, &card->dev, size, false, NULL, false);
+ md = mmc_blk_alloc_req(card, &card->dev, size, false, NULL,
+ MMC_BLK_DATA_AREA_MAIN);
return md;
}
@@ -1600,7 +1609,8 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)
if (md) {
if (md->disk->flags & GENHD_FL_UP) {
device_remove_file(disk_to_dev(md->disk), &md->force_ro);
- if (md->area_type == MMC_BLK_DATA_AREA_BOOT)
+ if (md->area_type == MMC_BLK_DATA_AREA_MAIN ||
+ md->area_type == MMC_BLK_DATA_AREA_BOOT)
device_remove_file(disk_to_dev(md->disk),
&md->boot_partition_ro_lock);
@@ -1642,11 +1652,17 @@ static int mmc_add_disk(struct mmc_blk_data *md)
if (ret)
goto force_ro_fail;
- if (md->area_type == MMC_BLK_DATA_AREA_BOOT) {
+ if (md->area_type == MMC_BLK_DATA_AREA_MAIN ||
+ md->area_type == MMC_BLK_DATA_AREA_BOOT) {
md->boot_partition_ro_lock.show = boot_partition_ro_lock_show;
md->boot_partition_ro_lock.store = boot_partition_ro_lock_store;
- md->boot_partition_ro_lock.attr.name = "boot_partition_ro_lock";
md->boot_partition_ro_lock.attr.mode = S_IRUGO | S_IWUSR;
+ if (md->area_type == MMC_BLK_DATA_AREA_MAIN)
+ md->boot_partition_ro_lock.attr.name =
+ "boot_partition_ro_lock";
+ else
+ md->boot_partition_ro_lock.attr.name =
+ "ro_lock";
ret = device_create_file(disk_to_dev(md->disk),
&md->boot_partition_ro_lock);
if (ret)