Skip to contentSkip to conversation

remove the clock name from pdata

PATCH Superseded Chao Xie 5 participants 12 messages Mar 18, 2013 – Mar 21, 2013

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Xie

author
#0 lore raw

cover remove the clock name from pdata

The clock is defined by device, so the driver knows how many clocks needed by the device.
The orignal way that passing the clock name by pdata is not correct. The following patches fix it.

Chao Xie (6):
usb: gadget: mv_udc_core: remove unused clock
usb: otg: mv_otg: remove unused clock
usb: ehci: mv_ehci: remove unused clock
arm: mmp: remove clock from usb pdata for aspenite
arm: mmp: remove clock name from usb pdata for ttc
usb: mv_usb: remove clock name from pdata

 arch/arm/mach-mmp/aspenite.c         |    6 -----
 arch/arm/mach-mmp/ttc_dkb.c          |    6 -----
 drivers/usb/gadget/mv_udc.h          |    3 +-
 drivers/usb/gadget/mv_udc_core.c     |   27 ++++++-------------------
 drivers/usb/host/ehci-mv.c           |   35 +++++++++------------------------
 drivers/usb/otg/mv_otg.c             |   28 ++++++--------------------
 drivers/usb/otg/mv_otg.h             |    3 +-
 include/linux/platform_data/mv_usb.h |    2 -
 8 files changed, 26 insertions(+), 84 deletions(-)
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH 1/6 usb: gadget: mv_udc_core: remove unused clock

The origianl understanding of clock is wrong. The UDC controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

---
 drivers/usb/gadget/mv_udc.h      |    3 +--
 drivers/usb/gadget/mv_udc_core.c |   27 +++++++--------------------
 2 files changed, 8 insertions(+), 22 deletions(-)
drivers/usb/gadget/mv_udc.h +1 -2
index 9073436..be77f20 100644
@@ -222,8 +222,7 @@ struct mv_udc {
 	struct mv_usb_platform_data     *pdata;
 
 	/* some SOC has mutiple clock sources for USB*/
-	unsigned int    clknum;
-	struct clk      *clk[0];
+	struct clk      *clk;
 };
 
 /* endpoint data structure */
drivers/usb/gadget/mv_udc_core.c +7 -20
index c8cf959..988e94a 100644
@@ -1006,18 +1006,12 @@ static struct usb_ep_ops mv_ep_ops = {
 
 static void udc_clock_enable(struct mv_udc *udc)
 {
-	unsigned int i;
-
-	for (i = 0; i < udc->clknum; i++)
-		clk_prepare_enable(udc->clk[i]);
+	clk_prepare_enable(udc->clk);
 }
 
 static void udc_clock_disable(struct mv_udc *udc)
 {
-	unsigned int i;
-
-	for (i = 0; i < udc->clknum; i++)
-		clk_disable_unprepare(udc->clk[i]);
+	clk_disable_unprepare(udc->clk);
 }
 
 static void udc_stop(struct mv_udc *udc)
@@ -2151,7 +2145,6 @@ static int mv_udc_probe(struct platform_device *pdev)
 	struct mv_usb_platform_data *pdata = pdev->dev.platform_data;
 	struct mv_udc *udc;
 	int retval = 0;
-	int clk_i = 0;
 	struct resource *r;
 	size_t size;
 
@@ -2160,8 +2153,7 @@ static int mv_udc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	size = sizeof(*udc) + sizeof(struct clk *) * pdata->clknum;
-	udc = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+	udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL);
 	if (udc == NULL) {
 		dev_err(&pdev->dev, "failed to allocate memory for udc\n");
 		return -ENOMEM;
@@ -2184,15 +2176,10 @@ static int mv_udc_probe(struct platform_device *pdev)
 	}
 #endif
 
-	udc->clknum = pdata->clknum;
-	for (clk_i = 0; clk_i < udc->clknum; clk_i++) {
-		udc->clk[clk_i] = devm_clk_get(&pdev->dev,
-					pdata->clkname[clk_i]);
-		if (IS_ERR(udc->clk[clk_i])) {
-			retval = PTR_ERR(udc->clk[clk_i]);
-			return retval;
-		}
-	}
+	/* udc only have one sysclk. */
+	udc->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(udc->clk))
+		return PTR_ERR(udc->clk);
 
 	r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "capregs");
 	if (r == NULL) {
Signature · 1 line
1.7.4.1
author
#2 lore raw

PATCH 2/6 usb: otg: mv_otg: remove unused clock

In reply to Chao Xie

The origianl understanding of clock is wrong. The OTG controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

---
 drivers/usb/otg/mv_otg.c |   28 +++++++---------------------
 drivers/usb/otg/mv_otg.h |    3 +--
 2 files changed, 8 insertions(+), 23 deletions(-)
drivers/usb/otg/mv_otg.c +7 -21
index b6a9be3..ee66283 100644
@@ -237,18 +237,12 @@ static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
 
 static void otg_clock_enable(struct mv_otg *mvotg)
 {
-	unsigned int i;
-
-	for (i = 0; i < mvotg->clknum; i++)
-		clk_prepare_enable(mvotg->clk[i]);
+	clk_prepare_enable(mvotg->clk);
 }
 
 static void otg_clock_disable(struct mv_otg *mvotg)
 {
-	unsigned int i;
-
-	for (i = 0; i < mvotg->clknum; i++)
-		clk_disable_unprepare(mvotg->clk[i]);
+	clk_disable_unprepare(mvotg->clk);
 }
 
 static int mv_otg_enable_internal(struct mv_otg *mvotg)
@@ -684,16 +678,14 @@ static int mv_otg_probe(struct platform_device *pdev)
 	struct mv_otg *mvotg;
 	struct usb_otg *otg;
 	struct resource *r;
-	int retval = 0, clk_i, i;
-	size_t size;
+	int retval = 0, i;
 
 	if (pdata == NULL) {
 		dev_err(&pdev->dev, "failed to get platform data\n");
 		return -ENODEV;
 	}
 
-	size = sizeof(*mvotg) + sizeof(struct clk *) * pdata->clknum;
-	mvotg = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+	mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL);
 	if (!mvotg) {
 		dev_err(&pdev->dev, "failed to allocate memory!\n");
 		return -ENOMEM;
@@ -708,15 +700,9 @@ static int mv_otg_probe(struct platform_device *pdev)
 	mvotg->pdev = pdev;
 	mvotg->pdata = pdata;
 
-	mvotg->clknum = pdata->clknum;
-	for (clk_i = 0; clk_i < mvotg->clknum; clk_i++) {
-		mvotg->clk[clk_i] = devm_clk_get(&pdev->dev,
-						pdata->clkname[clk_i]);
-		if (IS_ERR(mvotg->clk[clk_i])) {
-			retval = PTR_ERR(mvotg->clk[clk_i]);
-			return retval;
-		}
-	}
+	mvotg->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(mvotg->clk))
+		return PTR_ERR(mvotg->clk);
 
 	mvotg->qwork = create_singlethread_workqueue("mv_otg_queue");
 	if (!mvotg->qwork) {
drivers/usb/otg/mv_otg.h +1 -2
index 8a9e351..551da6e 100644
@@ -158,8 +158,7 @@ struct mv_otg {
 
 	unsigned int active;
 	unsigned int clock_gating;
-	unsigned int clknum;
-	struct clk *clk[0];
+	struct clk *clk;
 };
 
 #endif
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 2/6 usb: otg: mv_otg: remove unused clock

Quoted 6 lines · Chao Xie

The origianl understanding of clock is wrong. The OTG controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

please rebase against my 'next' branch.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130320/d782bc71/attachment.sig>
#4 lore raw

PATCH 2/6 usb: otg: mv_otg: remove unused clock

Quoted 6 lines · Felipe Balbi
Quoted 5 lines · Chao Xie

The origianl understanding of clock is wrong. The OTG controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

Quoted 6 lines
Quoted 1 line

please rebase against my 'next' branch.

--
balbi

hi
Do you mean git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git - branch "usb-next"?
Or some other git?

#5 lore raw

PATCH 2/6 usb: otg: mv_otg: remove unused clock

Hi,

Quoted 9 lines · Chao Xie
Quoted 8 lines · Felipe Balbi
Quoted 6 lines · Chao Xie

The origianl understanding of clock is wrong. The OTG controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

Quoted 8 lines
Quoted 4 lines

please rebase against my 'next' branch.

--
balbi

hi
Do you mean git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git - branch "usb-next"?
Or some other git?

git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next

Thanks
Kishon

#6 lore raw

PATCH 2/6 usb: otg: mv_otg: remove unused clock

In reply to Chao Xie
Quoted 9 lines · Chao Xie
Quoted 8 lines · Felipe Balbi
Quoted 6 lines · Chao Xie

The origianl understanding of clock is wrong. The OTG controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

Quoted 8 lines
Quoted 4 lines

please rebase against my 'next' branch.

--
balbi

hi
Do you mean git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git - branch "usb-next"?
Or some other git?

from MAINTAINERS:

8293 USB GADGET/PERIPHERAL SUBSYSTEM

8294 M:      Felipe Balbi <[email protected]>
8295 L:      linux-usb at vger.kernel.org
8296 W:      http://www.linux-usb.org/gadget
8297 T:      git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
8298 S:      Maintained
8299 F:      drivers/usb/gadget/
8300 F:      include/linux/usb/gadget*
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130321/358ad0cc/attachment-0001.sig>
author
#7 lore raw

PATCH 3/6 usb: ehci: mv_ehci: remove unused clock

In reply to Chao Xie

The origianl understanding of clock is wrong. The EHCI controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

---
 drivers/usb/host/ehci-mv.c |   35 ++++++++++-------------------------
 1 files changed, 10 insertions(+), 25 deletions(-)
drivers/usb/host/ehci-mv.c +10 -25
index 3065809..c390827 100644
@@ -33,25 +33,17 @@ struct ehci_hcd_mv {
 
 	struct mv_usb_platform_data *pdata;
 
-	/* clock source and total clock number */
-	unsigned int clknum;
-	struct clk *clk[0];
+	struct clk *clk;
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
 {
-	unsigned int i;
-
-	for (i = 0; i < ehci_mv->clknum; i++)
-		clk_prepare_enable(ehci_mv->clk[i]);
+	clk_prepare_enable(ehci_mv->clk);
 }
 
 static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv)
 {
-	unsigned int i;
-
-	for (i = 0; i < ehci_mv->clknum; i++)
-		clk_disable_unprepare(ehci_mv->clk[i]);
+	clk_disable_unprepare(ehci_mv->clk);
 }
 
 static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
@@ -144,9 +136,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	struct ehci_hcd *ehci;
 	struct ehci_hcd_mv *ehci_mv;
 	struct resource *r;
-	int clk_i, retval = -ENODEV;
+	int retval = -ENODEV;
 	u32 offset;
-	size_t size;
 
 	if (!pdata) {
 		dev_err(&pdev->dev, "missing platform_data\n");
@@ -160,8 +151,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	if (!hcd)
 		return -ENOMEM;
 
-	size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum;
-	ehci_mv = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+	ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL);
 	if (ehci_mv == NULL) {
 		dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n");
 		retval = -ENOMEM;
@@ -172,16 +162,11 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv->pdata = pdata;
 	ehci_mv->hcd = hcd;
 
-	ehci_mv->clknum = pdata->clknum;
-	for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) {
-		ehci_mv->clk[clk_i] =
-		    devm_clk_get(&pdev->dev, pdata->clkname[clk_i]);
-		if (IS_ERR(ehci_mv->clk[clk_i])) {
-			dev_err(&pdev->dev, "error get clck \"%s\"\n",
-				pdata->clkname[clk_i]);
-			retval = PTR_ERR(ehci_mv->clk[clk_i]);
-			goto err_clear_drvdata;
-		}
+	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(ehci_mv->clk)) {
+		dev_err(&pdev->dev, "error get clock\n");
+		retval = PTR_ERR(ehci_mv->clk);
+		goto err_clear_drvdata;
 	}
 
 	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
Signature · 1 line
1.7.4.1
#8 lore raw

PATCH 3/6 usb: ehci: mv_ehci: remove unused clock

Hello.

Quoted 14 lines · Chao Xie

The origianl understanding of clock is wrong. The EHCI controller only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device iteself.

---
  drivers/usb/host/ehci-mv.c |   35 ++++++++++-------------------------
  1 files changed, 10 insertions(+), 25 deletions(-)
drivers/usb/host/ehci-mv.c +0 -0
index 3065809..c390827 100644

[...]

Quoted 1 line
drivers/usb/host/ehci-mv.c +0 -0
@@ -172,16 +162,11 @@ static int mv_ehci_probe(struct platform_device *pdev)

[...]

drivers/usb/host/ehci-mv.c static int mv_ehci_probe(struct platform_device *pdev) · line 167

Quoted 3 lines
drivers/usb/host/ehci-mv.c +3 -0
+	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(ehci_mv->clk)) {
+		dev_err(&pdev->dev, "error get clock\n");

s/get/getting/

WBR, Sergei

author
#9 lore raw

PATCH 4/6 arm: mmp: remove clock from usb pdata for aspenite

In reply to Chao Xie

The clock name will directly get by driver. Removing the name from pdata.

---
 arch/arm/mach-mmp/aspenite.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
arch/arm/mach-mmp/aspenite.c +0 -6
index 9f64d56..76901f4 100644
@@ -223,13 +223,7 @@ static struct pxa27x_keypad_platform_data aspenite_keypad_info __initdata = {
 };
 
 #if defined(CONFIG_USB_EHCI_MV)
-static char *pxa168_sph_clock_name[] = {
-	[0] = "PXA168-USBCLK",
-};
-
 static struct mv_usb_platform_data pxa168_sph_pdata = {
-	.clknum         = 1,
-	.clkname        = pxa168_sph_clock_name,
 	.mode           = MV_USB_MODE_HOST,
 	.phy_init	= pxa_usb_phy_init,
 	.phy_deinit	= pxa_usb_phy_deinit,
Signature · 1 line
1.7.4.1
author
#10 lore raw

PATCH 5/6 arm: mmp: remove clock name from usb pdata for ttc

In reply to Chao Xie

The clock name will directly get by driver. Removing the name from pdata.

---
 arch/arm/mach-mmp/ttc_dkb.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
arch/arm/mach-mmp/ttc_dkb.c +0 -6
index 22a9058..6528a5f 100644
@@ -162,13 +162,7 @@ static struct i2c_board_info ttc_dkb_i2c_info[] = {
 #ifdef CONFIG_USB_SUPPORT
 #if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
 
-static char *pxa910_usb_clock_name[] = {
-	[0] = "U2OCLK",
-};
-
 static struct mv_usb_platform_data ttc_usb_pdata = {
-	.clknum		= 1,
-	.clkname	= pxa910_usb_clock_name,
 	.vbus		= NULL,
 	.mode		= MV_USB_MODE_OTG,
 	.otg_force_a_bus_req = 1,
Signature · 1 line
1.7.4.1
author
#11 lore raw

PATCH 6/6 usb: mv_usb: remove clock name from pdata

In reply to Chao Xie

Using pdata to pass clock name is not correct.
Directly get clock from usb drivers.

---
 include/linux/platform_data/mv_usb.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
include/linux/platform_data/mv_usb.h +0 -2
index 944b01d..98b7925 100644
@@ -34,8 +34,6 @@ struct mv_usb_addon_irq {
 };
 
 struct mv_usb_platform_data {
-	unsigned int		clknum;
-	char			**clkname;
 	struct mv_usb_addon_irq	*id;	/* Only valid for OTG. ID pin change*/
 	struct mv_usb_addon_irq	*vbus;	/* valid for OTG/UDC. VBUS change*/
 
Signature · 1 line
1.7.4.1