Re: [PATCH 3/5] mtd: block2mtd: Fallback to read-only mode

Pali Rohár
2017-07-25T14:28:21Z

On Friday 21 July 2017 21:53:26 Richard Weinberger wrote:
> > @@ -240,6 +244,13 @@ static struct block2mtd_dev *add_device(char *devname, uint32_t erase_size,
> > /* Get a handle on the device */
> > bdev = blkdev_get_by_path(devname, mode, dev);
> >
> > + /* Try fallback to read only mode */
> > + if (IS_ERR(bdev)) {
> > + bdev = blkdev_get_by_path(devname, FMODE_READ, dev);
> > + if (!IS_ERR(bdev))
> > + dev->ro_mode = true;
> > + }
> > +
>
> Please use bdev_read_only() instead of blindly trying again with another mode.
>
> > #ifndef MODULE
> > /*
> > * We might not have the root device mounted at this point.
> > @@ -261,6 +272,13 @@ static struct block2mtd_dev *add_device(char *devname, uint32_t erase_size,
> > if (!devt)
> > continue;
> > bdev = blkdev_get_by_dev(devt, mode, dev);
> > +
> > + /* Try fallback to read only mode */
> > + if (IS_ERR(bdev)) {
> > + bdev = blkdev_get_by_path(devname, FMODE_READ, dev);
> > + if (!IS_ERR(bdev))
> > + dev->ro_mode = true;
> > + }
>
> Same here.

Ok, I will change it.

--
Pali Rohár
pali.rohar@gmail.com