From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1da0pF-0002mU-L0 for linux-mtd@lists.infradead.org; Tue, 25 Jul 2017 14:28:43 +0000 Received: by mail-wm0-x241.google.com with SMTP id 184so16468279wmo.3 for ; Tue, 25 Jul 2017 07:28:20 -0700 (PDT) Date: Tue, 25 Jul 2017 16:28:16 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Richard Weinberger Cc: Joern Engel , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , Artem Bityutskiy , "linux-mtd@lists.infradead.org" , LKML Subject: Re: [PATCH 3/5] mtd: block2mtd: Fallback to read-only mode Message-ID: <20170725142816.GM30901@pali> References: <1496418222-23483-1-git-send-email-pali.rohar@gmail.com> <1496418222-23483-4-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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