From patchwork Fri Mar 21 11:16:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiqiang Hou X-Patchwork-Id: 332577 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id D78192C0110 for ; Fri, 21 Mar 2014 22:18:51 +1100 (EST) Received: by ozlabs.org (Postfix) id 889D32C00B3; Fri, 21 Mar 2014 22:18:15 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe006.messaging.microsoft.com [216.32.180.16]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D64E52C00BA for ; Fri, 21 Mar 2014 22:18:14 +1100 (EST) Received: from mail223-va3-R.bigfish.com (10.7.14.241) by VA3EHSOBE007.bigfish.com (10.7.40.11) with Microsoft SMTP Server id 14.1.225.22; Fri, 21 Mar 2014 11:18:11 +0000 Received: from mail223-va3 (localhost [127.0.0.1]) by mail223-va3-R.bigfish.com (Postfix) with ESMTP id 3C97DB0029C; Fri, 21 Mar 2014 11:18:11 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzd2iz1de098h8275bh1de097h84d07hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch25f6h2605h1155h) Received: from mail223-va3 (localhost.localdomain [127.0.0.1]) by mail223-va3 (MessageSwitch) id 1395400689699941_31384; Fri, 21 Mar 2014 11:18:09 +0000 (UTC) Received: from VA3EHSMHS028.bigfish.com (unknown [10.7.14.254]) by mail223-va3.bigfish.com (Postfix) with ESMTP id 9CF9D340067; Fri, 21 Mar 2014 11:18:09 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS028.bigfish.com (10.7.99.38) with Microsoft SMTP Server (TLS) id 14.16.227.3; Fri, 21 Mar 2014 11:18:09 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-005.039d.mgd.msft.net (10.84.1.17) with Microsoft SMTP Server (TLS) id 14.3.158.2; Fri, 21 Mar 2014 11:18:08 +0000 Received: from titan.am.freescale.net (b45104-01-010192208233.ap.freescale.net [10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s2LBI2YO021919; Fri, 21 Mar 2014 04:18:03 -0700 From: Hou Zhiqiang To: , Subject: [PATCH] mtd: m25p80: Modify the name of mtd_info Date: Fri, 21 Mar 2014 19:16:18 +0800 Message-ID: <1395400578-5637-1-git-send-email-B48286@freescale.com> X-Mailer: git-send-email 1.8.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Cc: scottwood@freescale.com, mingkai.hu@freescale.com, Hou Zhiqiang , dwmw2@infradead.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" To specify spi flash layouts by "mtdparts=..." in cmdline, we must give mtd_info a fixed name,because the cmdlinepart's parser will match the name of mtd_info given in cmdline. Now, if use DT, the mtd_info's name will be spi->dev->name. It consists of spi_master->bus_num, and the spi_master->bus_num maybe dynamically fetched. So, in this case, replace the component bus_num with thei physical address of spi master. Signed-off-by: Hou Zhiqiang --- drivers/mtd/devices/m25p80.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 7eda71d..64450a2 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -934,9 +935,11 @@ static int m25p_probe(struct spi_device *spi) struct flash_platform_data *data; struct m25p *flash; struct flash_info *info; - unsigned i; + unsigned i, ret; struct mtd_part_parser_data ppdata; struct device_node *np = spi->dev.of_node; + struct resource res; + struct device_node *mnp = spi->master->dev.of_node; /* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have @@ -1009,8 +1012,17 @@ static int m25p_probe(struct spi_device *spi) if (data && data->name) flash->mtd.name = data->name; - else - flash->mtd.name = dev_name(&spi->dev); + else{ + ret = of_address_to_resource(mnp, 0, &res); + if (ret) { + dev_err(&spi->dev, "failed to get spi master resource\n"); + return ret; + } + flash->mtd.name = kasprintf(GFP_KERNEL, "spi%x.%d", + (unsigned)res.start, spi->chip_select); + if (!flash->mtd.name) + return -ENOMEM; + } flash->mtd.type = MTD_NORFLASH; flash->mtd.writesize = 1;