From patchwork Thu May 1 09:56:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29480 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E3283203F3 for ; Thu, 1 May 2014 09:58:23 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ij19sf9590917vcb.9 for ; Thu, 01 May 2014 02:58:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=2X9OxF4SifugcQj+DIGi39unG86/MyqGUBsKe4jEflk=; b=N9lzQ5R9nkTGH/VLy7J9bSjieEr/A5VySz3Qydka+LVWZA7Q7H4+PrJb206WplqWJs jO8Ta6yngaffHdOcBdspKu3kHOoTDwYbEuuLFvE6Znu/RZV+rt6+kxkDVqSQo53CGJ5R VBGsn1LqXJTMBa/MOdRwzZIuK+lHhonhtbmU85TuozpTPCd0sXEICHYVBr7PnO2RPPdW lzSZoD6obQG5xvDMXUCJn5yMjPWomuiwLji18rqbDpeAazTECncwVd4gZS5YFheNmOoP 73LFfVwZfBk8C1lPPwtDI/TkHeIbUPDdCNXyXFsn450CI3f1l/56Oa5Syvzle90uPwni 1Nvw== X-Gm-Message-State: ALoCoQlid2fyt4QUeoE0c7XP15vzzxcBPhcywaCGGquQ9GLkw9S5x1dPUl8Xq7Es0DRsks1on0vB X-Received: by 10.58.161.175 with SMTP id xt15mr5292623veb.19.1398938303738; Thu, 01 May 2014 02:58:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.20 with SMTP id b20ls998205qga.5.gmail; Thu, 01 May 2014 02:58:23 -0700 (PDT) X-Received: by 10.58.116.175 with SMTP id jx15mr2100688veb.9.1398938303613; Thu, 01 May 2014 02:58:23 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id fn10si5951910vdc.117.2014.05.01.02.58.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:23 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id id10so3666739vcb.17 for ; Thu, 01 May 2014 02:58:23 -0700 (PDT) X-Received: by 10.58.1.97 with SMTP id 1mr8406356vel.23.1398938303547; Thu, 01 May 2014 02:58:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp12968vcb; Thu, 1 May 2014 02:58:22 -0700 (PDT) X-Received: by 10.180.80.3 with SMTP id n3mr1506175wix.36.1398938302609; Thu, 01 May 2014 02:58:22 -0700 (PDT) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by mx.google.com with ESMTPS id k12si10544664wjw.96.2014.05.01.02.58.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:22 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=74.125.82.181; Received: by mail-we0-f181.google.com with SMTP id q58so2909714wes.12 for ; Thu, 01 May 2014 02:58:22 -0700 (PDT) X-Received: by 10.180.101.166 with SMTP id fh6mr1577259wib.2.1398938302068; Thu, 01 May 2014 02:58:22 -0700 (PDT) Received: from lee--X1.home (host109-148-238-223.range109-148.btcentralplus.com. [109.148.238.223]) by mx.google.com with ESMTPSA id bj5sm2696494wib.3.2014.05.01.02.58.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:20 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, linux-mtd@lists.infradead.org, kernel@stlinux.com, Lee Jones Subject: [PATCH 37/47] mtd: nand: stm_nand_bch: load flash-resident BBT Date: Thu, 1 May 2014 10:56:44 +0100 Message-Id: <1398938214-17847-38-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398938214-17847-1-git-send-email-lee.jones@linaro.org> References: <1398938214-17847-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If load of existing BBT fails (first run), scan device for factory-set BBMs (Bad-Block Markers) and create a new flash-resident. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 2df452b..a06dca8 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -1235,6 +1235,30 @@ static int bch_load_bbt(struct nandi_controller *nandi, return 0; } +static int bch_scan_bbt(struct mtd_info *mtd) +{ + struct nand_chip *chip = mtd->priv; + struct nandi_controller *nandi = chip->priv; + struct nandi_bbt_info *bbt_info = &nandi->info.bbt_info; + int err; + /* Load Flash-resident BBT */ + err = bch_load_bbt(nandi, bbt_info); + if (err) { + dev_warn(nandi->dev, + "failed to find BBTs:" + " scanning device for bad-block markers\n"); + + /* Scan, build, and write BBT */ + nandi_scan_build_bbt(nandi, bbt_info); + err = bch_update_bbts(nandi, bbt_info, NAND_IBBT_UPDATE_BOTH, + bbt_info->bbt_vers[0] + 1); + if (err) + return err; + } + + return 0; +} + /* * Initialisation */ @@ -1318,6 +1342,8 @@ static void nandi_set_mtd_defaults(struct nandi_controller *nandi, chip->ecc.read_page = bch_read; chip->write_page = bch_write; + + chip->scan_bbt = bch_scan_bbt; } /*