From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938606AbcJ0UGD (ORCPT ); Thu, 27 Oct 2016 16:06:03 -0400 Received: from up.free-electrons.com ([163.172.77.33]:48282 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753838AbcJ0UF4 (ORCPT ); Thu, 27 Oct 2016 16:05:56 -0400 Date: Thu, 27 Oct 2016 22:05:24 +0200 From: Boris Brezillon To: Zach Brown Cc: , , , , , Subject: Re: [RESEND PATCH v2 3/3] mtd: ubi: use 'max_bad_blocks' to compute bad_peb_limit if available Message-ID: <20161027220524.61560d14@bbrezillon> In-Reply-To: <1477595642-11454-4-git-send-email-zach.brown@ni.com> References: <1477595642-11454-1-git-send-email-zach.brown@ni.com> <1477595642-11454-4-git-send-email-zach.brown@ni.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Oct 2016 14:14:02 -0500 Zach Brown wrote: > From: Jeff Westfahl > > Use the MTD function 'max_bad_blocks' to compute the UBI bad_peb_limit, > if the function is implemented for an MTD and doesn't return an error. > > Signed-off-by: Jeff Westfahl > Signed-off-by: Zach Brown > --- > drivers/mtd/ubi/build.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c > index 85d54f3..0648863 100644 > --- a/drivers/mtd/ubi/build.c > +++ b/drivers/mtd/ubi/build.c > @@ -584,6 +584,15 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) > int limit, device_pebs; > uint64_t device_size; > > + /* If the MTD provides a max_bad_blocks function, use that value. Fall > + * back to max_beb_per1024 if that function returns an error. > + */ > + if (ubi->mtd->_max_bad_blocks) { > + limit = ubi->mtd->_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size); > + if (limit > 0) > + return limit; > + } Please use the helper I was suggesting in patch 1. > + > if (!max_beb_per1024) > return 0; >