@@ -394,6 +394,16 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
goto out_free_info;
pdev->devt = devt;
+ if (!p->policy) {
+ if (disk->fops->check_disk_range_wp) {
+ err = disk->fops->check_disk_range_wp(disk, start, len);
+ if (err > 0)
+ p->policy = 1;
+ else if (err != 0)
+ goto out_free_info;
+ }
+ }
+
/* delay uevent until 'holders' subdir is created */
dev_set_uevent_suppress(pdev, 1);
err = device_add(pdev);
@@ -1047,6 +1047,7 @@ static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode,
#ifdef CONFIG_COMPAT
.compat_ioctl = mmc_blk_compat_ioctl,
#endif
+ .check_disk_range_wp = mmc_blk_check_disk_range_wp,
};
static int mmc_blk_part_switch_pre(struct mmc_card *card,
@@ -1707,6 +1707,7 @@ struct block_device_operations {
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
int (*report_zones)(struct gendisk *, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data);
+ int (*check_disk_range_wp)(struct gendisk *d, sector_t s, sector_t l);
struct module *owner;
const struct pr_ops *pr_ops;
};