From patchwork Fri Jan 26 21:23:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 866589 X-Patchwork-Delegate: cyrille.pitchen@atmel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G7AsghAc"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PuzXDVtJ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zSsNQ5512z9sNr for ; Sat, 27 Jan 2018 08:24:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=xY4AmdXNL24nXu+p0aLYZvHeXC2pZ27zUjJqAhCLKC4=; b=G7A sghAc5HK0Vq3G5AzWiUqkoAoHVV4lR2wtTTD1f6DzeuFoz9TrEuuAsIsO3/Op5K+LlQkaSr/YVcRa FRjdEaHqvlOFIlBR2bln0TKCScr5sO8HN/gfR7JhNXAcz21I0e6xwzdG5418Eqx4efXUdbaMV4AVk TXaZM0w/iYn6mtAKkvUVV2TRM19cLSUsHp5fau1l1W/5RGH0zwndh/FBUGzjHrsayoXJaiM+hSIHt aH6nmFEqzLNgCXufndRlf/zmZhxht8TtGiFuzU870Dq1iyUqDTQFK9oOpePth9tuSAOZ/Slod9z61 uxOinpSrj1buHAzUGfiQWswAlCHjXqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1efBTb-0007pd-0q; Fri, 26 Jan 2018 21:23:59 +0000 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1efBTP-0007dy-NL for linux-mtd@lists.infradead.org; Fri, 26 Jan 2018 21:23:49 +0000 Received: by mail-qt0-x243.google.com with SMTP id s39so4754923qth.7 for ; Fri, 26 Jan 2018 13:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rmkdGaIhJ1qoR+Ntuhk5M2Voh1JqTArX5B61Y8LZSlE=; b=PuzXDVtJBk1aONK2+lsMMAWL6v89s2lMICLnTCWBMZlFc/CTDnDGDkfygbcT03/Tq2 xtZQ3TKu61Raws2Of2xwxCqcRMJkzwByFbcxTx8ZoLejrw3M1WpHgmESxHh410H2mZC3 f5Vjd5Bbd0SbC8txNvjChPewfGaMBLE0Qw1GwkvmF5EaxfnCwUZeoe+KVX8QssCgiEWc NIxqUYHOjj6NYTBA3YUDpgb0aSWTBl3t3xVOOSUZM01B1/6wFuqgadQY3uzudZDHCdCq KLyjKZY0wjvF9JZFIoHmPdin/8z2LyuF6r809x2JGuvRJ6kvNYqUz5PojcsXkINkqL7Q CTtA== 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; bh=rmkdGaIhJ1qoR+Ntuhk5M2Voh1JqTArX5B61Y8LZSlE=; b=P18yNnDz0uQUJks5ljAhVYLQM8DT6QUO1SaRae2d+FEbmN/MEJnW2VEhMZpFFErAGm ZT/J4JDFNKMuorwNN8bexYIpvQPTbKwgte5ogmp/ayv2dgvddOdjSEHGtM4LfIUFivq3 iDOAyJxfq2TJ0Ktx1P03diVwYjQcpugJvFrgQ9YbUK1mzadzKSvaBzMTJQMFgWENz0BY u1ub9q9TDYUVdt+o/wCwrKR2IBF09Iwrx8vSsfFxiiGJfo8e0WQnQmw3nUCtE8qgQ1Dc X5fNnpfW245kNz9n1r021wLORVt9aR2G68NMK+D50wt44Mf8IvW4Kj+sLYPV6wHNj5h/ knPg== X-Gm-Message-State: AKwxytcABBvYSVX6sWaInOhOM+uhx/FIS0bzDUkwRHl3IFtal5XsNC/l owfQXqQ43Ph8mO8mrCf26Xk= X-Google-Smtp-Source: AH8x225GonLLRPmMw6fzMsvDNd84MLUFkFAX7ZFIy+DKJ1xPL4Mkqpl5mg+5fL7AaWMRGc4qNEY3Lg== X-Received: by 10.55.195.219 with SMTP id r88mr21977112qkl.219.1517001813288; Fri, 26 Jan 2018 13:23:33 -0800 (PST) Received: from localhost.localdomain ([187.180.182.112]) by smtp.gmail.com with ESMTPSA id l24sm6287080qtb.65.2018.01.26.13.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 13:23:32 -0800 (PST) From: Fabio Estevam To: cyrille.pitchen@wedev4u.fr Subject: [PATCH RESEND v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Date: Fri, 26 Jan 2018 19:23:24 -0200 Message-Id: <1517001805-7646-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400d:c0d:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david.wolfe@nxp.com, boris.brezillon@free-electrons.com, linux-mtd@lists.infradead.org, Fabio Estevam , han.xu@nxp.com MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Fabio Estevam Currently on a imx6sx-sdb board, which has two SPI NOR chips connected to QSPI2 the following output from /proc/mtd is seen: # cat /proc/mtd dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi" mtd1: 01000000 00010000 "21e4000.qspi" Attempts to partition them on the kernel command line result in both chips with identical (and identically named) partitions, which is an inconvenient behavior. Assign a different mtd->name for each mtd device to avoid this problem. After this change the output from /proc/mtd becomes: # cat /proc/mtd dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi-0" mtd1: 01000000 00010000 "21e4000.qspi-1" In order to keep mtdparts compatibility keep the mtd->name unchanged when a single SPI NOR is present. Reported-by: David Wolfe Signed-off-by: Fabio Estevam Reviewed-by: Boris Brezillon Acked-by: Han Xu --- Resending it as I missed to send it to Cyrille Changes since v5: - Preserve the label value, if any. (Boris) drivers/mtd/spi-nor/fsl-quadspi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 2901c7b..1038842 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -1051,6 +1051,24 @@ static int fsl_qspi_probe(struct platform_device *pdev) spi_nor_set_flash_node(nor, np); nor->priv = q; + if (q->nor_num > 1 && !mtd->name) { + int spiflash_idx; + + ret = of_property_read_u32(np, "reg", &spiflash_idx); + if (!ret) { + mtd->name = devm_kasprintf(dev, GFP_KERNEL, + "%s-%d", + dev_name(dev), + spiflash_idx); + if (!mtd->name) { + ret = -ENOMEM; + goto mutex_failed; + } + } else { + dev_warn(dev, "reg property is missing\n"); + } + } + /* fill the hooks */ nor->read_reg = fsl_qspi_read_reg; nor->write_reg = fsl_qspi_write_reg;