Received: by 10.223.164.221 with SMTP id h29csp3346032wrb; Mon, 30 Oct 2017 20:34:54 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Tg+09acNWyTnLIQpjlaNv66f7c6R3VxNaIljLNkwc3L69JxsriRc3xGAOEIhhIdIr6DnbL X-Received: by 10.98.248.5 with SMTP id d5mr604751pfh.118.1509420894364; Mon, 30 Oct 2017 20:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509420894; cv=none; d=google.com; s=arc-20160816; b=y5kmUyxKFnPNgv79NRi1sTshSw64oFWOGVDP3Ph47xynrkRYz+R0Ic5U8Mt/CYoClM KXgeHBQV7r/iuC/bAJ9vdUbKnx/uGySPW9IStJssEGmhgxZ8F34Rr01L8cCj5TTix5gF E09j6evsc9v/WjEfelQUDOFXk0G/8i6TTTvw79s5qUYTBoBC2obx26wvX/+YEs5rwqa2 sGuGE+pj+v8ougPk3q85s+dOoNyIhkYMF6e1Lzcu4nomkND+mYFcopmkk24PHdjOsz/5 LP/fn930EVScP06JooJ/JptG1863DHYgoOuP+2Uq/vpM5OjYyZq819Su1qEoiwx651TD /hKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=llKtYsUWQ6zzSxae8sPBqNFvw8lpcGgSx728IZuFfw0=; b=rQPCrslTEaGmVgwJXhhXJYaV7qK2TTkU+IX6QV2XDqAZ8xlILNlBnhYlkppBfctX1w tOxJGVY/JOxTcB1+RhRXM0mIDECejXKbVwc4t8n2adWMx6dVKPqf4PeqNyxPES/fGGhC d15Isa0aJoTLVjmoji80nB08ol7jG0yQSeje4IXV0CLn7rUXQtNdc/OS8AbgMCPGOWgF 5gDAMXKdf/veD+xwL+vf+4KPdYf8BR5LiM/hDN9n5hDXu3Q2aybBc5n55rZq3wtv/sbK LcHaCszocCpZRCtI4rRaQWZHxAc3IKW/y5agR7ubBmKcLaLqxbe+4dmP6oNKAYn1gHdq Xuag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AfcR2xmY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h128si482908pfb.121.2017.10.30.20.34.31; Mon, 30 Oct 2017 20:34:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AfcR2xmY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbdJaDdd (ORCPT + 99 others); Mon, 30 Oct 2017 23:33:33 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:44502 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbdJaDdb (ORCPT ); Mon, 30 Oct 2017 23:33:31 -0400 Received: by mail-io0-f194.google.com with SMTP id m16so32019582iod.1 for ; Mon, 30 Oct 2017 20:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=llKtYsUWQ6zzSxae8sPBqNFvw8lpcGgSx728IZuFfw0=; b=AfcR2xmYsXRRdgoh7EHac5HePNENmQsMrUuSxi/lwVUscDq1yhzfBQVuD8xsFbxmqZ cb047A+go5j5YA1nL1yE1sRLgMNTXB42mjYodGGnNrTu8CrGge2ZvnXIt/TIdHNSsPxI gr1uxCiOd+eEkfHmonAJsPfrIlUR4o8fC3v1xig7v37FRDma1uQ1u4/fhA/cKHtUuRCD a9fLNydAhuh0CUvg5U/Kw8rIneUAsXBbwz8Zo82Zub2PBBC5aC5WgYbX5xCpcZ4A7fQd ALWK5+/o3wQJsWNlhq5J2uelhQiFgABYxQ7Fahz3U2KLxLxOh5G++XYDyY6VxLWx0OFR 1YLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=llKtYsUWQ6zzSxae8sPBqNFvw8lpcGgSx728IZuFfw0=; b=mTS0yR1mYLBRimhXhPbLMNozFWC/DAwsDNhaqmrrDGyTM9VTazz2ds5mWMuUcoxL+m cv0uU6y1xrWVr2QfFkJ/vv9ztydbiVvGwP9nKApLzasHDNU0oNJt3YVm8cHyHa52b6aj 9PdIHWXTEWKUtjFSGqTFgL8csKtAZLHf+JgEgkdfBRLpJZmXoIMzV/ICt7p4zbs3BgNC PTKmu95ZNIyUyQD9GpRvca17rRJmLDMuT6CrQVpAOBEHUZDjE//c/Zs/lmppQ1DYIj35 dEydD+aim6qPHn2mG9WotZd04/af/irSwP2jaMLlv8t2F8+s0U9cQYY3AX6yDmQae9Oi QLYA== X-Gm-Message-State: AMCzsaVhktJH9HoTzkPMgfvwVbbeq9ItYtSdpRdgxXj35nDXC3+kyoIC m0feugGKJ2fiTDCqZvV2rdMNUo9S X-Received: by 10.107.104.12 with SMTP id d12mr688048ioc.296.1509420810982; Mon, 30 Oct 2017 20:33:30 -0700 (PDT) Received: from cartman.taylor.net (c-73-168-44-213.hsd1.il.comcast.net. [73.168.44.213]) by smtp.gmail.com with ESMTPSA id w6sm397014itc.43.2017.10.30.20.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Oct 2017 20:33:30 -0700 (PDT) From: motobud@gmail.com To: boris.brezillon@free-electrons.com Cc: Brent Taylor , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mtd: nand: Fix writing mtdoops to nand flash. Date: Mon, 30 Oct 2017 22:32:45 -0500 Message-Id: <20171031033246.8576-1-motobud@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030042343.24551-1-motobud@gmail.com> References: <20171030042343.24551-1-motobud@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brent Taylor When mtdoops calls mtd_panic_write, it eventually calls panic_nand_write in nand_base.c. In order to properly wait for the nand chip to be ready in panic_nand_wait, the chip must first be selected. When using the atmel nand flash controller, a panic would occur due to a NULL pointer exception. Signed-off-by: Brent Taylor --- Changes in v2: - drop deselecting the chip - move select_chip and panic_nand_wait after panic_nand_get_device drivers/mtd/nand/nand_base.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 12edaae17d81..2093667e2bcb 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2802,12 +2802,16 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, struct mtd_oob_ops ops; int ret; - /* Wait for the device to get ready */ - panic_nand_wait(mtd, chip, 400); + int chipnr = (int)(to >> chip->chip_shift); /* Grab the device */ panic_nand_get_device(chip, mtd, FL_WRITING); + chip->select_chip(mtd, chipnr); + + /* Wait for the device to get ready */ + panic_nand_wait(mtd, chip, 400); + memset(&ops, 0, sizeof(ops)); ops.len = len; ops.datbuf = (uint8_t *)buf; -- 2.14.2 From 1583015603969639319@xxx Fri Nov 03 03:55:23 +0000 2017 X-GM-THRID: 1583015603969639319 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread