From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030298AbcJ1U2p (ORCPT ); Fri, 28 Oct 2016 16:28:45 -0400 Received: from skprod2.natinst.com ([130.164.80.23]:36135 "EHLO ni.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756739AbcJ1U2j (ORCPT ); Fri, 28 Oct 2016 16:28:39 -0400 From: Zach Brown To: CC: , , , , , Subject: [PATCH v3 2/5] mtd: ubi: use 'max_bad_blocks' to compute bad_peb_limit if available Date: Fri, 28 Oct 2016 15:27:41 -0500 Message-ID: <1477686464-7437-3-git-send-email-zach.brown@ni.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477686464-7437-1-git-send-email-zach.brown@ni.com> References: <1477686464-7437-1-git-send-email-zach.brown@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 10/28/2016 03:27:38 PM, Serialize by Router on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 10/28/2016 03:27:38 PM, Serialize complete at 10/28/2016 03:27:38 PM MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-28_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610280347 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 85d54f3..e9940a9 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -584,6 +584,10 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024) int limit, device_pebs; uint64_t device_size; + limit = mtd_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size); + if (limit > 0) + return limit; + if (!max_beb_per1024) return 0; -- 2.7.4