From patchwork Wed Feb 13 06:26:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 14765 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 E0F804C1772 for ; Wed, 13 Feb 2013 06:19:57 +0000 (UTC) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by fiordland.canonical.com (Postfix) with ESMTP id 85667A18ED4 for ; Wed, 13 Feb 2013 06:19:57 +0000 (UTC) Received: by mail-ve0-f179.google.com with SMTP id da11so797694veb.10 for ; Tue, 12 Feb 2013 22:19:57 -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=anY+srmVsCJFos8cWdGHX5rRwuBjJzNYaaiNyaWaW64=; b=IofU+5J+aFiZgwxg+IdrHEgqPxUaqEiGZPViN9j7qnTlH6RI6OMhCaF6ov4YyxZN1f wPdtotmSctR/QV6yk5yS3hyT9MGE3vXUZt6wMWVZPEkvjzkgs0O4jVXEzJ2vb6LeU0xn Muqdogd1mOUNm33xfq8IpkaRDu42GcViHqhFdNnRSVYUaD/RcVnnlv4kqOsWRBlgb7lr 0qLB4H6Lt2sb+dezZVLIpJtj6jg7+yn19/dDJPpLsIBERawmz/izrRArseWZGTRLialX qXdn4qAZj7kz2aAM3mMujXmDlFfTo5MHboS4MJdnuzatFNgrroZViz7qbBkIjKkPNuuA rb5g== X-Received: by 10.58.213.37 with SMTP id np5mr9806209vec.54.1360736396841; Tue, 12 Feb 2013 22:19:56 -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.221.4.5 with SMTP id oa5csp177553vcb; Tue, 12 Feb 2013 22:19:56 -0800 (PST) X-Received: by 10.50.12.133 with SMTP id y5mr8920360igb.108.1360736396134; Tue, 12 Feb 2013 22:19:56 -0800 (PST) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id b2si1996985pav.56.2013.02.12.22.19.55; Tue, 12 Feb 2013 22:19:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.34 as permitted sender) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of gautam.vivek@samsung.com designates 203.254.224.34 as permitted sender) smtp.mail=gautam.vivek@samsung.com Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MI500C9VAX69FK0@mailout4.samsung.com> for patches@linaro.org; Wed, 13 Feb 2013 15:19:54 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 55.20.03880.A803B115; Wed, 13 Feb 2013 15:19:54 +0900 (KST) X-AuditID: cbfee61b-b7fb06d000000f28-c9-511b308a1c71 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C4.20.03880.A803B115; Wed, 13 Feb 2013 15:19:54 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.73.134]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MI500929AW4VY80@mmp2.samsung.com> for patches@linaro.org; Wed, 13 Feb 2013 15:19:54 +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, kmpark@infradead.org, rajeshwari.s@samsung.com Subject: [PATCH v2 1/2] usb: ehci: exynos: Fix multiple FDT decode Date: Wed, 13 Feb 2013 11:56:47 +0530 Message-id: <1360736808-27209-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1360736808-27209-1-git-send-email-gautam.vivek@samsung.com> References: <1360736808-27209-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsWyRsSkWrfLQDrQYNk1E4sph7+wODB63Lm2 hy2AMYrLJiU1J7MstUjfLoErY8nsFvaCdomKptdPWRsYbwp3MXJySAiYSEzfvJUdwhaTuHBv PVsXIxeHkMBSRon9s/exwBTNWL6QGSIxnVHi05dtYAkhgVVMEhcWVIHYbAK6Ek1vdzGC2CIC EhK/+q+C2cwC9RK3bq4DqxcWcJK4t/0Z2DYWAVWJh+9msILYvAIeEtOOH2aEWKYg8eb2M2YQ m1PAU+L2pE6oXR4SR+Z8ATtCQuAym8SizfOZIQYJSHybfAioiAMoISux6QAzxBxJiYMrbrBM YBRewMiwilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyMwCE//eya9g3FVg8UhRgEORiUeXocQ qUAh1sSy4srcQ4wSHMxKIrwTOKQDhXhTEiurUovy44tKc1KLDzEmAy2fyCwlmpwPjJC8knhD YxNzU2NTSyMjM1NT0oSVxHkZTz0JEBJITyxJzU5NLUgtgtnCxMEp1cDoNEPft/7k9tOHVyRz ZpWr3ndp7RSac6NRalVybJ/SGRcR7cx408R9txPLn2ZOV1z7i5PT6/kNY/bGCBUbNg3LNr6p zzaFL980h/lKeK/3l/7d5nrrm0pvWxjN/WZwuKquc71vfCjbrbBXzzRVQo9k3XnWoLitIHPC tHuiKoKu6hut/+jK7VdiKc5INNRiLipOBADHpy0ChgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRmVeSWpSXmKPExsVy+t9jQd0uA+lAg8XdyhZTDn9hcWD0uHNt D1sAY1QDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO 0FglhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4hQXA9RgZoIGENY8aS2S3sBe0SFU2vn7I2 MN4U7mLk5JAQMJGYsXwhM4QtJnHh3nq2LkYuDiGB6YwSn75sYwFJCAmsYpK4sKAKxGYT0JVo eruLEcQWEZCQ+NV/FcxmFqiXuHVzHVi9sICTxL3tz9hBbBYBVYmH72awgti8Ah4S044fZoRY piDx5vYzsMWcAp4Styd1Qu3ykDgy5wvzBEbeBYwMqxhFUwuSC4qT0nON9IoTc4tL89L1kvNz NzGCQ/yZ9A7GVQ0WhxgFOBiVeHgdQqQChVgTy4orcw8xSnAwK4nwTuCQDhTiTUmsrEotyo8v Ks1JLT7EmAx01URmKdHkfGD85ZXEGxqbmJsam1qaWJiYWZImrCTOy3jqSYCQQHpiSWp2ampB ahHMFiYOTqkGRvsbd5I9DZXuFVfZhrIqL2Wac/VBt6qJlX9X2+VdRsIbZR62N2+dM3NDVKKY hleUVezP6rk21zMn/oxVfD75o+hl7QUWtsuqf2/sm8uQ3G1pm16tvYvB78fPuxvjJtfdOyp2 tf6FU+X+i+WC+vYvKgLLLYNbeLfMeefF/H5TVNSKwtk7U/04lViKMxINtZiLihMBTEhIF7UC AAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnqJ6GuuiJx6oQVaprLEbAPWj5/5ArEx+baTxmsHvdtGj49OTyBuV/q95MQ+VipQ2wmLFC0 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 --- This patch comes up as a fix for earlier problem of multiple FDT decode. Actually no 'v1' present for this patch. drivers/usb/host/ehci-exynos.c | 40 +++++++++++----------------------------- 1 files changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 3ca4c5c..68f12fc 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -42,9 +42,11 @@ DECLARE_GLOBAL_DATA_PTR; */ struct exynos_ehci { struct exynos_usb_phy *usb; - unsigned int *hcd; + unsigned int hcd; }; +static struct exynos_ehci exynos; + static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos) { unsigned int node; @@ -59,8 +61,8 @@ 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) { + exynos->hcd = fdtdec_get_addr(blob, node, "reg"); + if (exynos->hcd < 0) { debug("Can't get the EHCI register address\n"); return -ENXIO; } @@ -144,20 +146,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; - - exynos = (struct exynos_ehci *) - kzalloc(sizeof(struct exynos_ehci), GFP_KERNEL); - if (!exynos) { - debug("failed to allocate exynos ehci context\n"); - return -ENOMEM; - } + struct exynos_ehci *ctx = &exynos; - exynos_usb_parse_dt(gd->fdt_blob, exynos); + exynos_usb_parse_dt(gd->fdt_blob, ctx); - setup_usb_phy(exynos->usb); + setup_usb_phy(ctx->usb); - *hccr = (struct ehci_hccr *)(exynos->hcd); + *hccr = (struct ehci_hccr *)(ctx->hcd); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); @@ -165,8 +160,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 +169,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; }