From patchwork Wed Mar 6 05:54:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 15249 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DCD3623E64 for ; Wed, 6 Mar 2013 05:56:16 +0000 (UTC) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by fiordland.canonical.com (Postfix) with ESMTP id 83F0AA196CD for ; Wed, 6 Mar 2013 05:56:16 +0000 (UTC) Received: by mail-vc0-f179.google.com with SMTP id k1so4545170vck.24 for ; Tue, 05 Mar 2013 21:56:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=VrZXTnIHYZqU7S59RH7kfA07pypcuNtaVO19f9SqKlU=; b=U3UVBRWLQDF09JSVl3YwZGFfCunCfP58Tt+2OpY62Hd0T8UP69kBVn6NvzZBspK2iw nqz6elY99H2b7cC62ANeTTc7IomsAVOjjXTNZDj3hRH+OY5Y6gNMYbubfk/k757x4YaH uRqXKSbGA1yw1EfIb5u3pwa2YJMLyspKPTleVh1InT9WkSyraDqGLxHc0HbUyQJZl+IB 0ILV1neiSKBM+aUtLC6WFIOHswE31t01+x8cY9l/K6Yzf62SPMub5gvX7Y3vXrgF1k6v zIIXUUAu3WxSE3+9QYypfW0y9khBJoJo2lyM5lHxRaUgd5Ywqox7RHOz7clcHnzAmm11 tfsA== X-Received: by 10.58.188.48 with SMTP id fx16mr11111533vec.22.1362549375972; Tue, 05 Mar 2013 21:56:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp152159veb; Tue, 5 Mar 2013 21:56:15 -0800 (PST) X-Received: by 10.68.195.70 with SMTP id ic6mr42802642pbc.60.1362549374643; Tue, 05 Mar 2013 21:56:14 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id ak6si31373653pbd.314.2013.03.05.21.56.13; Tue, 05 Mar 2013 21:56:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=gautam.vivek@samsung.com Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJ8009275SZ3SM0@mailout3.samsung.com> for patches@linaro.org; Wed, 06 Mar 2013 14:56:13 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 75.5E.18793.C7AD6315; Wed, 06 Mar 2013 14:56:12 +0900 (KST) X-AuditID: cbfee68f-b7f6a6d000004969-8a-5136da7c8d3b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 6A.1B.03918.C7AD6315; Wed, 06 Mar 2013 14:56:12 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.214.169]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJ8005FX5TCUK20@mmp2.samsung.com>; Wed, 06 Mar 2013 14:56:12 +0900 (KST) From: Vivek Gautam To: u-boot@lists.denx.de Cc: patches@linaro.org, mk7.kang@samsung.com, marex@denx.de, sjg@chromium.org, rajeshwari.s@samsung.com Subject: [PATCH v3 1/2] usb: ehci: exynos: Fix multiple FDT decode Date: Wed, 06 Mar 2013 11:24:02 +0530 Message-id: <1362549243-20587-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1362549243-20587-1-git-send-email-gautam.vivek@samsung.com> References: <1362549243-20587-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrALMWRmVeSWpSXmKPExsWyRsSkWrfmllmgwY6z5hZv2hoZLTqOtDBa TDn8hcWiZe0BVotvW7YxWrzd28nuwOYxu+Eii8e8WSdYPO5c28PmcfbODkaPvi2rGANYo7hs UlJzMstSi/TtErgytj3hKTgjUfHw4ESmBsZekS5GTg4JAROJeQsbmSFsMYkL99azdTFycQgJ LGWU2Nn4gqmLkQOsaPJyZ4j4dEaJCc/uMYE0CAlMYZL4+VYAxGYT0JVoeruLEcQWEZCQ+NV/ FcxmFsiUeLf5EtgCYQEniYnr5oDFWQRUJR539LOD2LwCHhK7+heyQxyhIPHm9jOwek4BT4m5 uycxQ+zykFh/7wgzyBESApPZJW7Mes0EMUhA4tvkQywQh8pKbDoA9YykxMEVN1gmMAovYGRY xSiaWpBcUJyUXmSsV5yYW1yal66XnJ+7iREY2qf/PevfwXj3gPUhxmSgcROZpUST84GxkVcS b2hsYm5qbGpmZGlpaUqasJI4r/wlmUAhgfTEktTs1NSC1KL4otKc1OJDjEwcnFINjHy2D10f JZwOFwqTE3ZbdHT/5SPvZIWXR8w1y1X2dbTQfesavDVMdvb+ntQVS98IMWaq7Cm8sW92maxN y5/FZRyTzjAejL7z5OeUU25nrZ7bSs7U5e2Juf6mZQpfmVSWq+THYDXV1r3N4TdmPJS5vnWt Xquc7FGzF54JYWzZx5xZZt6YZGB9RImlOCPRUIu5qDgRALqxx9SDAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLIsWRmVeSWpSXmKPExsVy+t9jQd2aW2aBBm/b9SzetDUyWnQcaWG0 mHL4C4tFy9oDrBbftmxjtHi7t5Pdgc1jdsNFFo95s06weNy5tofN4+ydHYwefVtWMQawRjUw 2mSkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYA3aCkUJaY UwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzNj2hKfgjETFw4MTmRoYe0W6GDk4 JARMJCYvd+5i5AQyxSQu3FvP1sXIxSEkMJ1RYsKze0wgCSGBKUwSP98KgNhsAroSTW93MYLY IgISEr/6r4LZzAKZEu82X2IGsYUFnCQmrpsDFmcRUJV43NHPDmLzCnhI7OpfyA6xTEHize1n YPWcAp4Sc3dPYobY5SGx/t4R5gmMvAsYGVYxiqYWJBcUJ6XnGuoVJ+YWl+al6yXn525iBEfO M6kdjCsbLA4xCnAwKvHwWiiZBQqxJpYVV+YeYpTgYFYS4eU6AxTiTUmsrEotyo8vKs1JLT7E mAx01URmKdHkfGBU55XEGxqbmJsam1qaWJiYWZImrCTOy3jqSYCQQHpiSWp2ampBahHMFiYO TqkGRoYlrGc00rraJZK/Ldqv99SRd7X0/CcWH8T13oumPO/LWTgp++K5gH2PPLN3X2a6yFlT XJwyeYoL572XihqzTB5M6f0mwd6hPbu0udAsacOTdQFfO55VRH77t3SJ3uZG2bqvJZYu61Lb hb+ZiTcozt1f0Z19Yd7u0z297cHaEWkfyzofnNESV2Ipzkg01GIuKk4EAOcDRfHgAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmP1mQyLB5aVvTwRf6XgAHJxtGxefmXe0gwEUpCDs5diTD13phsH6VH/8g3AbHsXDhL9cg2 With current FDT support driver tries to parse device node twice in ehci_hcd_init() and ehci_hcd_stop(), which shouldn't happen ideally. Making provision to store data in a global structure and thereby passing its pointer when needed. Signed-off-by: Vivek Gautam --- drivers/usb/host/ehci-exynos.c | 43 +++++++++++++--------------------------- 1 files changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 3ca4c5c..c6b7a5e 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -42,11 +42,14 @@ DECLARE_GLOBAL_DATA_PTR; */ struct exynos_ehci { struct exynos_usb_phy *usb; - unsigned int *hcd; + struct ehci_hccr *hcd; }; +static struct exynos_ehci exynos; + static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) { + fdt_addr_t addr; unsigned int node; int depth; @@ -59,12 +62,14 @@ static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) /* * Get the base address for EHCI controller from the device node */ - exynos->hcd = (unsigned int *)fdtdec_get_addr(blob, node, "reg"); - if (exynos->hcd == NULL) { + addr = fdtdec_get_addr(blob, node, "reg"); + if (addr == FDT_ADDR_T_NONE) { debug("Can't get the EHCI register address\n"); return -ENXIO; } + exynos->hcd = (struct ehci_hccr *)addr; + depth = 0; node = fdtdec_next_compatible_subnode(blob, node, COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth); @@ -144,20 +149,13 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) */ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { - struct exynos_ehci *exynos = NULL; + struct exynos_ehci *ctx = &exynos; - exynos = (struct exynos_ehci *) - kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); - if (!exynos) { - debug("failed to allocate exynos ehci context\n"); - return -ENOMEM; - } + exynos_usb_parse_dt(gd->fdt_blob, ctx); - exynos_usb_parse_dt(gd->fdt_blob, exynos); + setup_usb_phy(ctx->usb); - setup_usb_phy(exynos->usb); - - *hccr = (struct ehci_hccr *)(exynos->hcd); + *hccr = (ctx->hcd); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); @@ -165,8 +163,6 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); - kfree(exynos); - return 0; } @@ -176,20 +172,9 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) */ int ehci_hcd_stop(int index) { - struct exynos_ehci *exynos = NULL; - - exynos = (struct exynos_ehci *) - kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); - if (!exynos) { - debug("failed to allocate exynos ehci context\n"); - return -ENOMEM; - } - - exynos_usb_parse_dt(gd->fdt_blob, exynos); - - reset_usb_phy(exynos->usb); + struct exynos_ehci *ctx = &exynos; - kfree(exynos); + reset_usb_phy(ctx->usb); return 0; }