From patchwork Tue Jun 10 09:00:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 4327201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F01C9F3B4 for ; Tue, 10 Jun 2014 09:06:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 572D0202A1 for ; Tue, 10 Jun 2014 09:06:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4396F20274 for ; Tue, 10 Jun 2014 09:06:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WuHyb-0008Q1-E8; Tue, 10 Jun 2014 09:04:17 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WuHyS-0008Lz-To for linux-arm-kernel@lists.infradead.org; Tue, 10 Jun 2014 09:04:09 +0000 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6Y00DN73U7NED0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 10 Jun 2014 18:03:43 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id BF.D7.16580.EE9C6935; Tue, 10 Jun 2014 18:03:42 +0900 (KST) X-AuditID: cbfee691-b7f2f6d0000040c4-eb-5396c9ee6e75 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BB.36.08203.EE9C6935; Tue, 10 Jun 2014 18:03:42 +0900 (KST) Received: from chnaveen-ubuntu.sisodomain.com ([107.108.83.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N6Y001LS3TZFN20@mmp1.samsung.com>; Tue, 10 Jun 2014 18:03:42 +0900 (KST) From: Naveen Krishna Chatradhi To: linux-arm-kernel@lists.infradead.org, spi-devel-general@lists.sourceforge.net, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/3] spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio" Date: Tue, 10 Jun 2014 14:30:57 +0530 Message-id: <1402390859-28287-2-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1402390859-28287-1-git-send-email-ch.naveen@samsung.com> References: <1402390859-28287-1-git-send-email-ch.naveen@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRmVeSWpSXmKPExsWyRsSkVvfdyWnBBkdvWFtMffiEzeLlIU2L s8sOslm8OrORzWLypvuMFkd/F1j0LrjKZrHp8TVWixnn9zFZLNr2n9niyJRGdgduj9kNF1k8 /j6/zuKxc9Zddo9NqzrZPO5c28PmsXlJvcfuBZ+ZPPq2rGL0+PlSx+PzJrkArigum5TUnMyy 1CJ9uwSujP/HZzAWLJetOPTxM0sD4zqJLkZODgkBE4m/p1+yQNhiEhfurWfrYuTiEBJYyihx 4O1v1i5GDrCi7WszIeKLGCV6Ll+GKupnkji8+xQrSDebgJnEwUWr2UEaRATKJOZNqAOpYRb4 zShx9t4hNpC4sECYxIfHzCAmi4CqRPfZRJBOXgFXiVUdb5khVilIzJlkAxLmFHCT2HXtChOI LQRU0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NJFZSjQ5H5gs8kriDY1NzE2NTS1NLEzMLEkTVhLnPdBqHSgkkJ5YkpqdmlqQWgSzhYmDU6qB UWpNzxLT5lr3cL2fa1XLiht/pmlNOXA4uklAb8vre1vjWdZv+D+t6/8LrrVfj2c/+VhctW6K pUTITUlD62zLEwYuhT6CJ6rXTUmaqiq9uZrryKryS4pM1uoLC/89ca+Or/UvZtXueLPr7oeN GUs9WXZ+CnH7oha36dndcht91aMruf+fE2n5qsRSnJFoqMVcVJwIABlB3dUMAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140610_020409_128654_0207331E X-CRM114-Status: GOOD ( 13.92 ) X-Spam-Score: -5.7 (-----) Cc: kgene.kim@samsung.com, Doug Anderson , grant.likely@secretlab.ca, jaswinder.singh@linaro.org, broonie@kernel.org, cpgs@samsung.com, naveenkrishna.ch@gmail.com, Javier Martinez Canillas X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes the changes in spi-s3c64xx.c driver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node. Signed-off-by: Naveen Krishna Chatradhi Cc: Javier Martinez Canillas Cc: Doug Anderson --- drivers/spi/spi-s3c64xx.c | 56 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 75a5696..0c6013f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -750,47 +750,56 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, } static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( - struct spi_device *spi) + struct spi_device *spi, + struct s3c64xx_spi_csinfo *cs) { - struct s3c64xx_spi_csinfo *cs; - struct device_node *slave_np, *data_np = NULL; - struct s3c64xx_spi_driver_data *sdd; + struct device_node *data_np = NULL; u32 fb_delay = 0; - sdd = spi_master_get_devdata(spi->master); - slave_np = spi->dev.of_node; - if (!slave_np) { - dev_err(&spi->dev, "device node not found\n"); + data_np = of_get_child_by_name(spi->dev.of_node, "controller-data"); + if (!data_np) { + dev_err(&spi->dev, "child node 'controller-data' not found\n"); return ERR_PTR(-EINVAL); } - data_np = of_get_child_by_name(slave_np, "controller-data"); - if (!data_np) { - dev_err(&spi->dev, "child node 'controller-data' not found\n"); + of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); + cs->fb_delay = fb_delay; + of_node_put(data_np); + + return cs; +} + +static struct s3c64xx_spi_csinfo *s3c64xx_get_cs_gpios(struct spi_device *spi) +{ + struct device_node *parent_np = NULL; + struct s3c64xx_spi_driver_data *sdd; + struct s3c64xx_spi_csinfo *cs; + + parent_np = of_get_parent(spi->dev.of_node); + if (!parent_np) { + dev_err(&spi->dev, "Parent node not found\n"); return ERR_PTR(-EINVAL); } + sdd = spi_master_get_devdata(spi->master); + cs = kzalloc(sizeof(*cs), GFP_KERNEL); if (!cs) { - of_node_put(data_np); + of_node_put(parent_np); return ERR_PTR(-ENOMEM); } /* The CS line is asserted/deasserted by the gpio pin */ if (sdd->cs_gpio) - cs->line = of_get_named_gpio(data_np, "cs-gpio", 0); + cs->line = of_get_named_gpio(parent_np, "cs-gpios", 0); if (!gpio_is_valid(cs->line)) { dev_err(&spi->dev, "chip select gpio is not specified or invalid\n"); - kfree(cs); - of_node_put(data_np); + of_node_put(parent_np); return ERR_PTR(-EINVAL); } - of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); - cs->fb_delay = fb_delay; - of_node_put(data_np); - return cs; + return s3c64xx_get_slave_ctrldata(spi, cs); } /* @@ -806,9 +815,14 @@ static int s3c64xx_spi_setup(struct spi_device *spi) struct s3c64xx_spi_info *sci; int err; + if (!spi->dev.of_node) { + dev_err(&spi->dev, "device node not found\n"); + return ERR_PTR(-EINVAL); + } + sdd = spi_master_get_devdata(spi->master); if (!cs && spi->dev.of_node) { - cs = s3c64xx_get_slave_ctrldata(spi); + cs = s3c64xx_get_cs_gpios(spi); spi->controller_data = cs; } @@ -1077,7 +1091,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->sfr_start = mem_res->start; sdd->cs_gpio = true; if (pdev->dev.of_node) { - if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL)) + if (!of_find_property(pdev->dev.of_node, "cs-gpios", NULL)) sdd->cs_gpio = false; ret = of_alias_get_id(pdev->dev.of_node, "spi");