From patchwork Fri Sep 21 14:22:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 1491781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 62E44DF28C for ; Fri, 21 Sep 2012 14:27:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TF4AW-0002pE-S4; Fri, 21 Sep 2012 14:25:25 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TF49E-0002Gp-GV for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2012 14:24:06 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAP006QLEMV2O50@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2012 23:23:34 +0900 (KST) X-AuditID: cbfee61b-b7f2b6d000000f14-fd-505c7862c5b3 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id DF.CB.03860.2687C505; Fri, 21 Sep 2012 23:23:30 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MAP0020KEMM3N30@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2012 23:23:30 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/6] pinctrl: samsung: Hold pointer to driver data in bank struct Date: Fri, 21 Sep 2012 16:22:53 +0200 Message-id: <1348237377-21299-3-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1348237377-21299-1-git-send-email-t.figa@samsung.com> References: <1348237377-21299-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd2kipgAg+7NFhabHl9jdWD02Lyk PoAxissmJTUnsyy1SN8ugSvj4eqjTAUP5Cs+zlnJ3sD4XbKLkZNDQsBE4vid34wQtpjEhXvr 2boYuTiEBBYxStzu3sEI4Wxmknh6fzczSBWbgJrE54ZHbCC2iICGxJSux+wgNrPAZCaJYwvS QWxhgXCJ469XMYHYLAKqEsd2TAGr4RVwkvj85ScTxDZ5oJl9YHM4BZwlbu7qAKsRAqr5vrCD eQIj7wJGhlWMoqkFyQXFSem5RnrFibnFpXnpesn5uZsYwT5/Jr2DcVWDxSFGAQ5GJR7eFd+i A4RYE8uKK3MPMUpwMCuJ8D6KAQrxpiRWVqUW5ccXleakFh9ilOZgURLnFf4UGCAkkJ5Ykpqd mlqQWgSTZeLglGpg3HqNOVScP+KIXeZfXUGrWlGxj8LntlYf0XfrkZfeosx4eGFv8Qb5m6eY w49d147b6/j1XO7HnSF/LWu3HVn2acLdmwGFuve/n7mbpPM8VVp+RZPgNAtthit7+ZWXKWxt 2NutHPhFhS9g/UyJH3OEGMT0alwXPk2edOptc/3CufdlNRZLCTmKKbEUZyQaajEXFScCAKN9 jif1AQAA X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.4 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.24 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, swarren@wwwdotorg.org, devicetree-discuss@lists.ozlabs.org, tomasz.figa@gmail.com, t.figa@samsung.com, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, thomas.abraham@linaro.org, linus.walleij@linaro.org, m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The pointer will be used by further extensions added to the driver. Signed-off-by: Tomasz Figa --- drivers/pinctrl/pinctrl-samsung.c | 33 +++++++++++++++++---------------- drivers/pinctrl/pinctrl-samsung.h | 2 ++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c index 846b277..3f48d3f 100644 --- a/drivers/pinctrl/pinctrl-samsung.c +++ b/drivers/pinctrl/pinctrl-samsung.c @@ -844,11 +844,11 @@ static int samsung_pinctrl_parse_dt_bank(struct samsung_pin_bank *bank, /* retrieve the soc specific data */ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( - struct platform_device *pdev) + struct samsung_pinctrl_drv_data *d) { int id; const struct of_device_id *match; - const struct device_node *node = pdev->dev.of_node; + struct device_node *node = d->dev->of_node; struct device_node *bank_np; struct samsung_pin_ctrl *ctrl; struct samsung_pin_bank *banks, *b; @@ -858,9 +858,9 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( u32 val; int ret; - id = of_alias_get_id(pdev->dev.of_node, "pinctrl"); + id = of_alias_get_id(node, "pinctrl"); if (id < 0) { - dev_err(&pdev->dev, "failed to get alias id\n"); + dev_err(d->dev, "failed to get alias id\n"); return NULL; } match = of_match_node(samsung_pinctrl_dt_match, node); @@ -873,20 +873,20 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( } if (!bank_cnt) { - dev_err(&pdev->dev, "no pin banks specified\n"); + dev_err(d->dev, "no pin banks specified\n"); return NULL; } - ctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL); + ctrl = devm_kzalloc(d->dev, sizeof(*ctrl), GFP_KERNEL); if (!ctrl) { - dev_err(&pdev->dev, "failed to allocate soc data\n"); + dev_err(d->dev, "failed to allocate soc data\n"); return NULL; } - banks = devm_kzalloc(&pdev->dev, + banks = devm_kzalloc(d->dev, bank_cnt * sizeof(*ctrl->pin_banks), GFP_KERNEL); if (!banks) { - dev_err(&pdev->dev, "failed to allocate pin banks\n"); + dev_err(d->dev, "failed to allocate pin banks\n"); return NULL; } @@ -896,6 +896,7 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( continue; if (samsung_pinctrl_parse_dt_bank(b, bank_np)) return NULL; + b->drvdata = d; b->pin_base = ctrl->nr_pins; ctrl->nr_pins += b->nr_pins; if (of_find_property(bank_np, "interrupt-controller", NULL)) { @@ -956,21 +957,21 @@ static int __devinit samsung_pinctrl_probe(struct platform_device *pdev) return -ENODEV; } - ctrl = samsung_pinctrl_get_soc_data(pdev); - if (!ctrl) { - dev_err(&pdev->dev, "driver data not available\n"); - return -EINVAL; - } - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { dev_err(dev, "failed to allocate memory for driver's " "private data\n"); return -ENOMEM; } - drvdata->ctrl = ctrl; drvdata->dev = dev; + ctrl = samsung_pinctrl_get_soc_data(drvdata); + if (!ctrl) { + dev_err(&pdev->dev, "driver data not available\n"); + return -EINVAL; + } + drvdata->ctrl = ctrl; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "cannot find IO resource\n"); diff --git a/drivers/pinctrl/pinctrl-samsung.h b/drivers/pinctrl/pinctrl-samsung.h index b7b74cc..9e30081 100644 --- a/drivers/pinctrl/pinctrl-samsung.h +++ b/drivers/pinctrl/pinctrl-samsung.h @@ -112,6 +112,7 @@ struct samsung_pinctrl_drv_data; * @irq_base: starting controller local irq number of the bank. * @name: name to be prefixed for each pin in this pin bank. * @of_node: node of pin bank in device tree + * @drvdata: link to controller driver data */ struct samsung_pin_bank { u32 pctl_offset; @@ -128,6 +129,7 @@ struct samsung_pin_bank { const char *name; struct device_node *of_node; + struct samsung_pinctrl_drv_data *drvdata; }; /**