From patchwork Sat Jul 9 17:16:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 959962 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p69H6cQc008318 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 9 Jul 2011 17:06:59 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QfazG-0003im-JF; Sat, 09 Jul 2011 17:06:38 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QfazE-0003ig-UM for spi-devel-general@lists.sourceforge.net; Sat, 09 Jul 2011 17:06:36 +0000 X-ACL-Warn: Received: from mail-iw0-f175.google.com ([209.85.214.175]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1QfazE-0006z6-4w for spi-devel-general@lists.sourceforge.net; Sat, 09 Jul 2011 17:06:36 +0000 Received: by mail-iw0-f175.google.com with SMTP id 4so3551799iwn.34 for ; Sat, 09 Jul 2011 10:06:36 -0700 (PDT) Received: by 10.231.161.148 with SMTP id r20mr1219273ibx.146.1310231195976; Sat, 09 Jul 2011 10:06:35 -0700 (PDT) Received: from localhost.localdomain ([114.216.146.213]) by mx.google.com with ESMTPS id y3sm1839319iba.4.2011.07.09.10.06.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 09 Jul 2011 10:06:35 -0700 (PDT) From: Shawn Guo To: spi-devel-general@lists.sourceforge.net Subject: [PATCH v2 6/7] spi/imx: copy gpio number passed by platform data into driver private data Date: Sun, 10 Jul 2011 01:16:40 +0800 Message-Id: <1310231801-18761-7-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310231801-18761-1-git-send-email-shawn.guo@linaro.org> References: <1310231801-18761-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1QfazE-0006z6-4w Cc: patches@linaro.org, devicetree-discuss@lists.ozlabs.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Shawn Guo , Sascha Hauer , linux-arm-kernel@lists.infradead.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 09 Jul 2011 17:06:59 +0000 (UTC) X-MIME-Autoconverted: from base64 to 8bit by demeter1.kernel.org id p69H6cQc008318 It copies gpio number passed via platform data embedded pointer into driver private data, so that we do not need to refer to this embedded pointer passed by platform data after probe function exits. Signed-off-by: Shawn Guo Cc: Uwe Kleine-König Cc: Sascha Hauer Cc: Grant Likely --- drivers/spi/spi-imx.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 2ed9c32..ad61828 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -84,7 +84,6 @@ struct spi_imx_data { int irq; struct clk *clk; unsigned long spi_clk; - int *chipselect; unsigned int count; void (*tx)(struct spi_imx_data *); @@ -94,6 +93,7 @@ struct spi_imx_data { unsigned int txfifo; /* number of words pushed in tx FIFO */ struct spi_imx_devtype_data *devtype_data; + int chipselect[0]; }; static inline int is_imx27_cspi(struct spi_imx_data *d) @@ -743,7 +743,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev) struct spi_master *master; struct spi_imx_data *spi_imx; struct resource *res; - int i, ret; + int i, ret, num_cs; mxc_platform_info = dev_get_platdata(&pdev->dev); if (!mxc_platform_info) { @@ -751,20 +751,22 @@ static int __devinit spi_imx_probe(struct platform_device *pdev) return -EINVAL; } - master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data)); + num_cs = mxc_platform_info->num_chipselect; + master = spi_alloc_master(&pdev->dev, + sizeof(struct spi_imx_data) + sizeof(int) * num_cs); if (!master) return -ENOMEM; platform_set_drvdata(pdev, master); master->bus_num = pdev->id; - master->num_chipselect = mxc_platform_info->num_chipselect; + master->num_chipselect = num_cs; spi_imx = spi_master_get_devdata(master); spi_imx->bitbang.master = spi_master_get(master); - spi_imx->chipselect = mxc_platform_info->chipselect; for (i = 0; i < master->num_chipselect; i++) { + spi_imx->chipselect[i] = mxc_platform_info->chipselect[i]; if (spi_imx->chipselect[i] < 0) continue; ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);