linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] usb: renesas_usbhs: refactor this driver
@ 2019-06-25  5:38 Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 01/13] usb: renesas_usbhs: revise the irq_vbus comments Yoshihiro Shimoda
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch series is based on Greg's usb.git / usb-next branch.

The previous code had redundant memory allocations so that
the code readability was not good. I believe this patch series
makes it better.

Yoshihiro Shimoda (13):
  usb: renesas_usbhs: revise the irq_vbus comments
  usb: renesas_usbhs: remove notify_hotplug callback
  usb: renesas_usbhs: move macros from mod.c to the mod.h
  usb: renesas_usbhs: Avoid to write platform_data's value
  usb: renesas_usbhs: Use a specific flag instead of type for multi_clks
  usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param
  usb: renesas_usbhs: Use dev_of_node macro instead of open coded
  usb: renesas_usbhs: Add has_new_pipe_configs flag
  usb: renesas_usbhs: Add struct device * declaration in usbhs_probe()
  usb: renesas_usbhs: move device tree properties parsing
  usb: renesas_usbhs: Add a common function for the .get_id
  usb: renesas_usbhs: Use renesas_usbhs_platform_info on
    of_device_id.data
  usb: renesas_usbhs: Use struct platform_callback pointer

 drivers/usb/renesas_usbhs/common.c     | 197 +++++++++++----------------------
 drivers/usb/renesas_usbhs/common.h     |  11 +-
 drivers/usb/renesas_usbhs/fifo.c       |   3 +-
 drivers/usb/renesas_usbhs/mod.c        |  23 ++--
 drivers/usb/renesas_usbhs/mod.h        |  26 ++++-
 drivers/usb/renesas_usbhs/mod_gadget.c |   7 +-
 drivers/usb/renesas_usbhs/rcar2.c      |  22 ++--
 drivers/usb/renesas_usbhs/rcar2.h      |   3 +-
 drivers/usb/renesas_usbhs/rcar3.c      |  33 ++++--
 drivers/usb/renesas_usbhs/rcar3.h      |   5 +-
 drivers/usb/renesas_usbhs/rza.c        |  18 +--
 drivers/usb/renesas_usbhs/rza.h        |   4 +-
 drivers/usb/renesas_usbhs/rza2.c       |  22 ++--
 include/linux/usb/renesas_usbhs.h      |  35 +-----
 14 files changed, 168 insertions(+), 241 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/13] usb: renesas_usbhs: revise the irq_vbus comments
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 02/13] usb: renesas_usbhs: remove notify_hotplug callback Yoshihiro Shimoda
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

Since the irq_vbus comments doesn't match with the current
implementation, this patch revises it. This patch also changes
new lines to reduce the source code lines.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/mod.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h
index a4a61d6..7117729 100644
--- a/drivers/usb/renesas_usbhs/mod.h
+++ b/drivers/usb/renesas_usbhs/mod.h
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #ifndef RENESAS_USB_MOD_H
@@ -84,12 +85,11 @@ struct usbhs_mod_info {
 	/*
 	 * INTSTS0 :: VBINT
 	 *
-	 * This function will be used as autonomy mode
-	 * when platform cannot call notify_hotplug.
+	 * This function will be used as autonomy mode (runtime_pwctrl == 0)
+	 * when the platform doesn't have own get_vbus function.
 	 *
-	 * This callback cannot be member of "struct usbhs_mod"
-	 * because it will be used even though
-	 * host/gadget has not been selected.
+	 * This callback cannot be member of "struct usbhs_mod" because it
+	 * will be used even though host/gadget has not been selected.
 	 */
 	int (*irq_vbus)(struct usbhs_priv *priv,
 			struct usbhs_irq_state *irq_state);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/13] usb: renesas_usbhs: remove notify_hotplug callback
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 01/13] usb: renesas_usbhs: revise the irq_vbus comments Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 03/13] usb: renesas_usbhs: move macros from mod.c to the mod.h Yoshihiro Shimoda
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

The notify_hotplug callback was supported in v3.10, but the last user
(armadillo800eva) was removed by the commit 1fa59bda21c7 ("ARM: shmobile:
Remove legacy board code for Armadillo-800 EVA"). So, this patch
removes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c     | 16 ++++------------
 drivers/usb/renesas_usbhs/common.h     |  2 ++
 drivers/usb/renesas_usbhs/mod.c        |  3 ++-
 drivers/usb/renesas_usbhs/mod_gadget.c |  3 ++-
 include/linux/usb/renesas_usbhs.h      | 26 +-------------------------
 5 files changed, 11 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index ebbe322..f6b136a 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #include <linux/clk.h>
@@ -513,7 +514,7 @@ static void usbhsc_notify_hotplug(struct work_struct *work)
 	usbhsc_hotplug(priv);
 }
 
-static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
+int usbhsc_schedule_notify_hotplug(struct platform_device *pdev)
 {
 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
 	int delay = usbhs_get_dparam(priv, detection_delay);
@@ -667,7 +668,6 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 static int usbhs_probe(struct platform_device *pdev)
 {
 	struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
-	struct renesas_usbhs_driver_callback *dfunc;
 	struct usbhs_priv *priv;
 	struct resource *res, *irq_res;
 	int ret;
@@ -721,10 +721,6 @@ static int usbhs_probe(struct platform_device *pdev)
 	}
 	priv->pfunc = info->platform_callback;
 
-	/* set driver callback functions for platform */
-	dfunc			= &info->driver_callback;
-	dfunc->notify_hotplug	= usbhsc_drvcllbck_notify_hotplug;
-
 	/* set default param if platform doesn't have */
 	if (!priv->dparam.pipe_configs) {
 		priv->dparam.pipe_configs = usbhsc_default_pipe;
@@ -818,7 +814,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	/*
 	 * manual call notify_hotplug for cold plug
 	 */
-	usbhsc_drvcllbck_notify_hotplug(pdev);
+	usbhsc_schedule_notify_hotplug(pdev);
 
 	dev_info(&pdev->dev, "probed\n");
 
@@ -843,13 +839,9 @@ static int usbhs_probe(struct platform_device *pdev)
 static int usbhs_remove(struct platform_device *pdev)
 {
 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
-	struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
-	struct renesas_usbhs_driver_callback *dfunc = &info->driver_callback;
 
 	dev_dbg(&pdev->dev, "usb remove\n");
 
-	dfunc->notify_hotplug = NULL;
-
 	/* power off */
 	if (!usbhs_get_dparam(priv, runtime_pwctrl))
 		usbhsc_power_ctrl(priv, 0);
@@ -894,7 +886,7 @@ static __maybe_unused int usbhsc_resume(struct device *dev)
 
 	usbhs_platform_call(priv, phy_reset, pdev);
 
-	usbhsc_drvcllbck_notify_hotplug(pdev);
+	usbhsc_schedule_notify_hotplug(pdev);
 
 	return 0;
 }
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index de74ebd1..b2b21fb 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #ifndef RENESAS_USB_DRIVER_H
@@ -317,6 +318,7 @@ void usbhs_bus_send_sof_enable(struct usbhs_priv *priv);
 void usbhs_bus_send_reset(struct usbhs_priv *priv);
 int usbhs_bus_get_speed(struct usbhs_priv *priv);
 int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
+int usbhsc_schedule_notify_hotplug(struct platform_device *pdev);
 
 /*
  * frame
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 7475c4f..540472a 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #include <linux/interrupt.h>
@@ -41,7 +42,7 @@ static int usbhsm_autonomy_irq_vbus(struct usbhs_priv *priv,
 {
 	struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-	renesas_usbhs_call_notify_hotplug(pdev);
+	usbhsc_schedule_notify_hotplug(pdev);
 
 	return 0;
 }
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 59cac40..0c1e8fa 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #include <linux/delay.h>
@@ -1023,7 +1024,7 @@ static int usbhsg_vbus_session(struct usb_gadget *gadget, int is_active)
 
 	gpriv->vbus_active = !!is_active;
 
-	renesas_usbhs_call_notify_hotplug(pdev);
+	usbhsc_schedule_notify_hotplug(pdev);
 
 	return 0;
 }
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index b2cba7c..ac601be 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -3,6 +3,7 @@
  * Renesas USB
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  *
  * This program is distributed in the hope that it will be useful,
@@ -33,17 +34,6 @@ enum {
 };
 
 /*
- * callback functions table for driver
- *
- * These functions are called from platform for driver.
- * Callback function's pointer will be set before
- * renesas_usbhs_platform_callback :: hardware_init was called
- */
-struct renesas_usbhs_driver_callback {
-	int (*notify_hotplug)(struct platform_device *pdev);
-};
-
-/*
  * callback functions for platform
  *
  * These functions are called from driver for platform
@@ -214,12 +204,6 @@ struct renesas_usbhs_platform_info {
 	struct renesas_usbhs_platform_callback	platform_callback;
 
 	/*
-	 * driver set these callback functions pointer.
-	 * platform can use it on callback functions
-	 */
-	struct renesas_usbhs_driver_callback	driver_callback;
-
-	/*
 	 * option:
 	 *
 	 * driver use these param for some register
@@ -232,12 +216,4 @@ struct renesas_usbhs_platform_info {
  */
 #define renesas_usbhs_get_info(pdev)\
 	((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
-
-#define renesas_usbhs_call_notify_hotplug(pdev)				\
-	({								\
-		struct renesas_usbhs_driver_callback *dc;		\
-		dc = &(renesas_usbhs_get_info(pdev)->driver_callback);	\
-		if (dc && dc->notify_hotplug)				\
-			dc->notify_hotplug(pdev);			\
-	})
 #endif /* RENESAS_USB_H */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/13] usb: renesas_usbhs: move macros from mod.c to the mod.h
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 01/13] usb: renesas_usbhs: revise the irq_vbus comments Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 02/13] usb: renesas_usbhs: remove notify_hotplug callback Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 04/13] usb: renesas_usbhs: Avoid to write platform_data's value Yoshihiro Shimoda
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

In the future, since other source code of this driver will use these
macros, this patch moves it to the header file.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/mod.c | 9 ---------
 drivers/usb/renesas_usbhs/mod.h | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 540472a..984bb2f 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -11,15 +11,6 @@
 #include "common.h"
 #include "mod.h"
 
-#define usbhs_priv_to_modinfo(priv) (&priv->mod_info)
-#define usbhs_mod_info_call(priv, func, param...)	\
-({						\
-	struct usbhs_mod_info *info;		\
-	info = usbhs_priv_to_modinfo(priv);	\
-	!info->func ? 0 :			\
-	 info->func(param);			\
-})
-
 /*
  *		autonomy
  *
diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h
index 7117729..6678e81 100644
--- a/drivers/usb/renesas_usbhs/mod.h
+++ b/drivers/usb/renesas_usbhs/mod.h
@@ -129,6 +129,15 @@ void usbhs_irq_callback_update(struct usbhs_priv *priv, struct usbhs_mod *mod);
 		 mod->func(param);			\
 	})
 
+#define usbhs_priv_to_modinfo(priv) (&priv->mod_info)
+#define usbhs_mod_info_call(priv, func, param...)	\
+({							\
+	struct usbhs_mod_info *info;			\
+	info = usbhs_priv_to_modinfo(priv);		\
+	!info->func ? 0 :				\
+	 info->func(param);				\
+})
+
 /*
  * host / gadget control
  */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/13] usb: renesas_usbhs: Avoid to write platform_data's value
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 03/13] usb: renesas_usbhs: move macros from mod.c to the mod.h Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 05/13] usb: renesas_usbhs: Use a specific flag instead of type for multi_clks Yoshihiro Shimoda
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

The very old commit 482982062f1b ("usb: gadget: renesas_usbhs:
bugfix: don't modify platform data") changed to use copied whole
structures values to fix the "hung-up" issue. However, we also
can fix the issue if the driver copies the get_vbus function
pointer to the driver's value.

So, this patch adds get_vbus member into struct usbhs_mod_info and
use the pointer instead of struct renesas_usbhs_platform_callback.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c     |  4 +++-
 drivers/usb/renesas_usbhs/mod.c        | 11 +++++++++--
 drivers/usb/renesas_usbhs/mod.h        |  7 +++++++
 drivers/usb/renesas_usbhs/mod_gadget.c |  4 ++--
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index f6b136a..739fe4b 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -448,7 +448,7 @@ static void usbhsc_hotplug(struct usbhs_priv *priv)
 	/*
 	 * get vbus status from platform
 	 */
-	enable = usbhs_platform_call(priv, get_vbus, pdev);
+	enable = usbhs_mod_info_call(priv, get_vbus, pdev);
 
 	/*
 	 * get id from platform
@@ -809,6 +809,8 @@ static int usbhs_probe(struct platform_device *pdev)
 	if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
 		usbhsc_power_ctrl(priv, 1);
 		usbhs_mod_autonomy_mode(priv);
+	} else {
+		usbhs_mod_non_autonomy_mode(priv);
 	}
 
 	/*
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 984bb2f..ddf0153 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -42,12 +42,19 @@ void usbhs_mod_autonomy_mode(struct usbhs_priv *priv)
 {
 	struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv);
 
-	info->irq_vbus		= usbhsm_autonomy_irq_vbus;
-	priv->pfunc.get_vbus	= usbhsm_autonomy_get_vbus;
+	info->irq_vbus = usbhsm_autonomy_irq_vbus;
+	info->get_vbus = usbhsm_autonomy_get_vbus;
 
 	usbhs_irq_callback_update(priv, NULL);
 }
 
+void usbhs_mod_non_autonomy_mode(struct usbhs_priv *priv)
+{
+	struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv);
+
+	info->get_vbus = priv->pfunc.get_vbus;
+}
+
 /*
  *		host / gadget functions
  *
diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h
index 6678e81..65dc19c 100644
--- a/drivers/usb/renesas_usbhs/mod.h
+++ b/drivers/usb/renesas_usbhs/mod.h
@@ -93,6 +93,12 @@ struct usbhs_mod_info {
 	 */
 	int (*irq_vbus)(struct usbhs_priv *priv,
 			struct usbhs_irq_state *irq_state);
+
+	/*
+	 * This function will be used on any gadget mode. To simplify the code,
+	 * this member is in here.
+	 */
+	int (*get_vbus)(struct platform_device *pdev);
 };
 
 /*
@@ -107,6 +113,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv);
 void usbhs_mod_remove(struct usbhs_priv *priv);
 
 void usbhs_mod_autonomy_mode(struct usbhs_priv *priv);
+void usbhs_mod_non_autonomy_mode(struct usbhs_priv *priv);
 
 /*
  *		status functions
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 0c1e8fa..4d571a5 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -915,8 +915,8 @@ static void usbhs_mod_phy_mode(struct usbhs_priv *priv)
 {
 	struct usbhs_mod_info *info = &priv->mod_info;
 
-	info->irq_vbus		= NULL;
-	priv->pfunc.get_vbus	= usbhsm_phy_get_vbus;
+	info->irq_vbus = NULL;
+	info->get_vbus = usbhsm_phy_get_vbus;
 
 	usbhs_irq_callback_update(priv, NULL);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/13] usb: renesas_usbhs: Use a specific flag instead of type for multi_clks
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (3 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 04/13] usb: renesas_usbhs: Avoid to write platform_data's value Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 06/13] usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param Yoshihiro Shimoda
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

To remove the type of renesas_usbhs_driver_param in the future, this
patch uses a specific flag "multi_clks".

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 8 +++-----
 include/linux/usb/renesas_usbhs.h  | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 739fe4b..530e2eb7 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -288,11 +288,7 @@ static void usbhsc_set_buswait(struct usbhs_priv *priv)
 
 static bool usbhsc_is_multi_clks(struct usbhs_priv *priv)
 {
-	if (priv->dparam.type == USBHS_TYPE_RCAR_GEN3 ||
-	    priv->dparam.type == USBHS_TYPE_RCAR_GEN3_WITH_PLL)
-		return true;
-
-	return false;
+	return priv->dparam.multi_clks;
 }
 
 static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv)
@@ -544,6 +540,7 @@ static const struct usbhs_of_data rcar_gen3_data = {
 	.param = {
 		.type = USBHS_TYPE_RCAR_GEN3,
 		.has_usb_dmac = 1,
+		.multi_clks = 1,
 		.pipe_configs = usbhsc_new_pipe,
 		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
 	}
@@ -554,6 +551,7 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = {
 	.param = {
 		.type = USBHS_TYPE_RCAR_GEN3_WITH_PLL,
 		.has_usb_dmac = 1,
+		.multi_clks = 1,
 		.pipe_configs = usbhsc_new_pipe,
 		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
 	}
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index ac601be..e249c21 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -181,6 +181,7 @@ struct renesas_usbhs_driver_param {
 	u32 has_cnen:1;
 	u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
 #define USBHS_USB_DMAC_XFER_SIZE	32	/* hardcode the xfer size */
+	u32 multi_clks:1;
 };
 
 #define USBHS_TYPE_RCAR_GEN2		1
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/13] usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (4 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 05/13] usb: renesas_usbhs: Use a specific flag instead of type for multi_clks Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 07/13] usb: renesas_usbhs: Use dev_of_node macro instead of open coded Yoshihiro Shimoda
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

Now no one uses the type member so that this patch removes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 5 -----
 include/linux/usb/renesas_usbhs.h  | 7 -------
 2 files changed, 12 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 530e2eb7..1872756 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -528,7 +528,6 @@ int usbhsc_schedule_notify_hotplug(struct platform_device *pdev)
 static const struct usbhs_of_data rcar_gen2_data = {
 	.platform_callback = &usbhs_rcar2_ops,
 	.param = {
-		.type = USBHS_TYPE_RCAR_GEN2,
 		.has_usb_dmac = 1,
 		.pipe_configs = usbhsc_new_pipe,
 		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
@@ -538,7 +537,6 @@ static const struct usbhs_of_data rcar_gen2_data = {
 static const struct usbhs_of_data rcar_gen3_data = {
 	.platform_callback = &usbhs_rcar3_ops,
 	.param = {
-		.type = USBHS_TYPE_RCAR_GEN3,
 		.has_usb_dmac = 1,
 		.multi_clks = 1,
 		.pipe_configs = usbhsc_new_pipe,
@@ -549,7 +547,6 @@ static const struct usbhs_of_data rcar_gen3_data = {
 static const struct usbhs_of_data rcar_gen3_with_pll_data = {
 	.platform_callback = &usbhs_rcar3_with_pll_ops,
 	.param = {
-		.type = USBHS_TYPE_RCAR_GEN3_WITH_PLL,
 		.has_usb_dmac = 1,
 		.multi_clks = 1,
 		.pipe_configs = usbhsc_new_pipe,
@@ -560,7 +557,6 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = {
 static const struct usbhs_of_data rza1_data = {
 	.platform_callback = &usbhs_rza1_ops,
 	.param = {
-		.type = USBHS_TYPE_RZA1,
 		.pipe_configs = usbhsc_new_pipe,
 		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
 	}
@@ -569,7 +565,6 @@ static const struct usbhs_of_data rza1_data = {
 static const struct usbhs_of_data rza2_data = {
 	.platform_callback = &usbhs_rza2_ops,
 	.param = {
-		.type = USBHS_TYPE_RZA2,
 		.has_cnen = 1,
 		.cfifo_byte_addr = 1,
 		.pipe_configs = usbhsc_new_pipe,
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index e249c21..fee84b7 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -170,7 +170,6 @@ struct renesas_usbhs_driver_param {
 	 */
 	int pio_dma_border; /* default is 64byte */
 
-	uintptr_t type;
 	u32 enable_gpio;
 
 	/*
@@ -184,12 +183,6 @@ struct renesas_usbhs_driver_param {
 	u32 multi_clks:1;
 };
 
-#define USBHS_TYPE_RCAR_GEN2		1
-#define USBHS_TYPE_RCAR_GEN3		2
-#define USBHS_TYPE_RCAR_GEN3_WITH_PLL	3
-#define USBHS_TYPE_RZA1			4
-#define USBHS_TYPE_RZA2			5
-
 /*
  * option:
  *
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/13] usb: renesas_usbhs: Use dev_of_node macro instead of open coded
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (5 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 06/13] usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 08/13] usb: renesas_usbhs: Add has_new_pipe_configs flag Yoshihiro Shimoda
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

This patch uses the dev_of_node macro instead of open coded
to be better.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 14 +++++++-------
 drivers/usb/renesas_usbhs/fifo.c   |  3 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 1872756..35b06e7 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -297,7 +297,7 @@ static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv)
 		return 0;
 
 	/* The first clock should exist */
-	priv->clks[0] = of_clk_get(dev->of_node, 0);
+	priv->clks[0] = of_clk_get(dev_of_node(dev), 0);
 	if (IS_ERR(priv->clks[0]))
 		return PTR_ERR(priv->clks[0]);
 
@@ -305,7 +305,7 @@ static int usbhsc_clk_get(struct device *dev, struct usbhs_priv *priv)
 	 * To backward compatibility with old DT, this driver checks the return
 	 * value if it's -ENOENT or not.
 	 */
-	priv->clks[1] = of_clk_get(dev->of_node, 1);
+	priv->clks[1] = of_clk_get(dev_of_node(dev), 1);
 	if (PTR_ERR(priv->clks[1]) == -ENOENT)
 		priv->clks[1] = NULL;
 	else if (IS_ERR(priv->clks[1]))
@@ -648,10 +648,10 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 	*dparam = data->param;
 	info->platform_callback = *data->platform_callback;
 
-	if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+	if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
 		dparam->buswait_bwait = tmp;
-	gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
-				       NULL);
+	gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio",
+				       0, NULL);
 	if (gpio > 0)
 		dparam->enable_gpio = gpio;
 
@@ -666,7 +666,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	int ret;
 
 	/* check device node */
-	if (pdev->dev.of_node)
+	if (dev_of_node(&pdev->dev))
 		info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
 
 	/* check platform information */
@@ -692,7 +692,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
-	if (of_property_read_bool(pdev->dev.of_node, "extcon")) {
+	if (of_property_read_bool(dev_of_node(&pdev->dev), "extcon")) {
 		priv->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
 		if (IS_ERR(priv->edev))
 			return PTR_ERR(priv->edev);
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index e84d2ac2..a345b2e 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -3,6 +3,7 @@
  * Renesas USB driver
  *
  * Copyright (C) 2011 Renesas Solutions Corp.
+ * Copyright (C) 2019 Renesas Electronics Corporation
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #include <linux/delay.h>
@@ -1277,7 +1278,7 @@ static void usbhsf_dma_init(struct usbhs_priv *priv, struct usbhs_fifo *fifo,
 {
 	struct device *dev = usbhs_priv_to_dev(priv);
 
-	if (dev->of_node)
+	if (dev_of_node(dev))
 		usbhsf_dma_init_dt(dev, fifo, channel);
 	else
 		usbhsf_dma_init_pdev(fifo);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/13] usb: renesas_usbhs: Add has_new_pipe_configs flag
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (6 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 07/13] usb: renesas_usbhs: Use dev_of_node macro instead of open coded Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 09/13] usb: renesas_usbhs: Add struct device * declaration in usbhs_probe() Yoshihiro Shimoda
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

In the future, each struct renesas_usbhs_driver_param is stored on
the each platform related source code (e.g. rcar3.c). So, to simplify
the source code, this patch adds a new flag has_new_pipe_configs.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 20 +++++++++-----------
 include/linux/usb/renesas_usbhs.h  |  1 +
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 35b06e7..f9476a07 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -529,8 +529,7 @@ static const struct usbhs_of_data rcar_gen2_data = {
 	.platform_callback = &usbhs_rcar2_ops,
 	.param = {
 		.has_usb_dmac = 1,
-		.pipe_configs = usbhsc_new_pipe,
-		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+		.has_new_pipe_configs = 1,
 	}
 };
 
@@ -539,8 +538,7 @@ static const struct usbhs_of_data rcar_gen3_data = {
 	.param = {
 		.has_usb_dmac = 1,
 		.multi_clks = 1,
-		.pipe_configs = usbhsc_new_pipe,
-		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+		.has_new_pipe_configs = 1,
 	}
 };
 
@@ -549,16 +547,14 @@ static const struct usbhs_of_data rcar_gen3_with_pll_data = {
 	.param = {
 		.has_usb_dmac = 1,
 		.multi_clks = 1,
-		.pipe_configs = usbhsc_new_pipe,
-		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+		.has_new_pipe_configs = 1,
 	}
 };
 
 static const struct usbhs_of_data rza1_data = {
 	.platform_callback = &usbhs_rza1_ops,
 	.param = {
-		.pipe_configs = usbhsc_new_pipe,
-		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+		.has_new_pipe_configs = 1,
 	}
 };
 
@@ -567,8 +563,7 @@ static const struct usbhs_of_data rza2_data = {
 	.param = {
 		.has_cnen = 1,
 		.cfifo_byte_addr = 1,
-		.pipe_configs = usbhsc_new_pipe,
-		.pipe_size = ARRAY_SIZE(usbhsc_new_pipe),
+		.has_new_pipe_configs = 1,
 	}
 };
 
@@ -715,7 +710,10 @@ static int usbhs_probe(struct platform_device *pdev)
 	priv->pfunc = info->platform_callback;
 
 	/* set default param if platform doesn't have */
-	if (!priv->dparam.pipe_configs) {
+	if (usbhs_get_dparam(priv, has_new_pipe_configs)) {
+		priv->dparam.pipe_configs = usbhsc_new_pipe;
+		priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
+	} else if (!priv->dparam.pipe_configs) {
 		priv->dparam.pipe_configs = usbhsc_default_pipe;
 		priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe);
 	}
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
index fee84b7..6914475 100644
--- a/include/linux/usb/renesas_usbhs.h
+++ b/include/linux/usb/renesas_usbhs.h
@@ -181,6 +181,7 @@ struct renesas_usbhs_driver_param {
 	u32 cfifo_byte_addr:1; /* CFIFO is byte addressable */
 #define USBHS_USB_DMAC_XFER_SIZE	32	/* hardcode the xfer size */
 	u32 multi_clks:1;
+	u32 has_new_pipe_configs:1;
 };
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/13] usb: renesas_usbhs: Add struct device * declaration in usbhs_probe()
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (7 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 08/13] usb: renesas_usbhs: Add has_new_pipe_configs flag Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 10/13] usb: renesas_usbhs: move device tree properties parsing Yoshihiro Shimoda
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

Since this can remove over 80 charactors in a line, this patch adds
struct device * declaration in usbhs_probe().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index f9476a07..379b4a0e 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -658,27 +658,28 @@ static int usbhs_probe(struct platform_device *pdev)
 	struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
 	struct usbhs_priv *priv;
 	struct resource *res, *irq_res;
+	struct device *dev = &pdev->dev;
 	int ret;
 
 	/* check device node */
-	if (dev_of_node(&pdev->dev))
+	if (dev_of_node(dev))
 		info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
 
 	/* check platform information */
 	if (!info) {
-		dev_err(&pdev->dev, "no platform information\n");
+		dev_err(dev, "no platform information\n");
 		return -EINVAL;
 	}
 
 	/* platform data */
 	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!irq_res) {
-		dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n");
+		dev_err(dev, "Not enough Renesas USB platform resources.\n");
 		return -ENODEV;
 	}
 
 	/* usb private data */
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
@@ -687,13 +688,13 @@ static int usbhs_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
-	if (of_property_read_bool(dev_of_node(&pdev->dev), "extcon")) {
-		priv->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
+	if (of_property_read_bool(dev_of_node(dev), "extcon")) {
+		priv->edev = extcon_get_edev_by_phandle(dev, 0);
 		if (IS_ERR(priv->edev))
 			return PTR_ERR(priv->edev);
 	}
 
-	priv->rsts = devm_reset_control_array_get_optional_shared(&pdev->dev);
+	priv->rsts = devm_reset_control_array_get_optional_shared(dev);
 	if (IS_ERR(priv->rsts))
 		return PTR_ERR(priv->rsts);
 
@@ -704,7 +705,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	priv->dparam = info->driver_param;
 
 	if (!info->platform_callback.get_id) {
-		dev_err(&pdev->dev, "no platform callbacks");
+		dev_err(dev, "no platform callbacks\n");
 		return -EINVAL;
 	}
 	priv->pfunc = info->platform_callback;
@@ -755,7 +756,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	if (ret)
 		goto probe_fail_rst;
 
-	ret = usbhsc_clk_get(&pdev->dev, priv);
+	ret = usbhsc_clk_get(dev, priv);
 	if (ret)
 		goto probe_fail_clks;
 
@@ -771,8 +772,7 @@ static int usbhs_probe(struct platform_device *pdev)
 		ret = !gpio_get_value(priv->dparam.enable_gpio);
 		gpio_free(priv->dparam.enable_gpio);
 		if (ret) {
-			dev_warn(&pdev->dev,
-				 "USB function not selected (GPIO %d)\n",
+			dev_warn(dev, "USB function not selected (GPIO %d)\n",
 				 priv->dparam.enable_gpio);
 			ret = -ENOTSUPP;
 			goto probe_end_mod_exit;
@@ -788,7 +788,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	 */
 	ret = usbhs_platform_call(priv, hardware_init, pdev);
 	if (ret < 0) {
-		dev_err(&pdev->dev, "platform init failed.\n");
+		dev_err(dev, "platform init failed.\n");
 		goto probe_end_mod_exit;
 	}
 
@@ -796,7 +796,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	usbhs_platform_call(priv, phy_reset, pdev);
 
 	/* power control */
-	pm_runtime_enable(&pdev->dev);
+	pm_runtime_enable(dev);
 	if (!usbhs_get_dparam(priv, runtime_pwctrl)) {
 		usbhsc_power_ctrl(priv, 1);
 		usbhs_mod_autonomy_mode(priv);
@@ -809,7 +809,7 @@ static int usbhs_probe(struct platform_device *pdev)
 	 */
 	usbhsc_schedule_notify_hotplug(pdev);
 
-	dev_info(&pdev->dev, "probed\n");
+	dev_info(dev, "probed\n");
 
 	return ret;
 
@@ -824,7 +824,7 @@ static int usbhs_probe(struct platform_device *pdev)
 probe_end_pipe_exit:
 	usbhs_pipe_remove(priv);
 
-	dev_info(&pdev->dev, "probe failed (%d)\n", ret);
+	dev_info(dev, "probe failed (%d)\n", ret);
 
 	return ret;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/13] usb: renesas_usbhs: move device tree properties parsing
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (8 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 09/13] usb: renesas_usbhs: Add struct device * declaration in usbhs_probe() Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 11/13] usb: renesas_usbhs: Add a common function for the .get_id Yoshihiro Shimoda
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

In the future, each struct renesas_usbhs_driver_param is stored on
the each platform related source code (e.g. rcar3.c) to remove
usbhs_parse_dt(). So, this patch moves device tree properties
parsing to usbhs_probe().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 379b4a0e..dc5e80d 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -628,8 +628,6 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 	struct renesas_usbhs_platform_info *info;
 	struct renesas_usbhs_driver_param *dparam;
 	const struct usbhs_of_data *data;
-	u32 tmp;
-	int gpio;
 
 	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
@@ -643,13 +641,6 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 	*dparam = data->param;
 	info->platform_callback = *data->platform_callback;
 
-	if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
-		dparam->buswait_bwait = tmp;
-	gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio",
-				       0, NULL);
-	if (gpio > 0)
-		dparam->enable_gpio = gpio;
-
 	return info;
 }
 
@@ -659,7 +650,8 @@ static int usbhs_probe(struct platform_device *pdev)
 	struct usbhs_priv *priv;
 	struct resource *res, *irq_res;
 	struct device *dev = &pdev->dev;
-	int ret;
+	int ret, gpio;
+	u32 tmp;
 
 	/* check device node */
 	if (dev_of_node(dev))
@@ -720,6 +712,12 @@ static int usbhs_probe(struct platform_device *pdev)
 	}
 	if (!priv->dparam.pio_dma_border)
 		priv->dparam.pio_dma_border = 64; /* 64byte */
+	if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp))
+		priv->dparam.buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio",
+				       0, NULL);
+	if (gpio > 0)
+		priv->dparam.enable_gpio = gpio;
 
 	/* FIXME */
 	/* runtime power control ? */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 11/13] usb: renesas_usbhs: Add a common function for the .get_id
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (9 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 10/13] usb: renesas_usbhs: move device tree properties parsing Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 12/13] usb: renesas_usbhs: Use renesas_usbhs_platform_info on of_device_id.data Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

All platform related codes (rcar[23].c and rza{2}.c) has its own
.get_id function as "USBHS_GADGET". So, we can use a common
function for it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c |  5 +++++
 drivers/usb/renesas_usbhs/common.h |  2 ++
 drivers/usb/renesas_usbhs/rcar2.c  |  8 ++------
 drivers/usb/renesas_usbhs/rcar3.c  | 11 +++--------
 drivers/usb/renesas_usbhs/rza.c    |  9 ++-------
 drivers/usb/renesas_usbhs/rza2.c   |  7 +------
 6 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index dc5e80d..656f976 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -84,6 +84,11 @@ struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev)
 	return dev_get_drvdata(&pdev->dev);
 }
 
+int usbhs_get_id_as_gadget(struct platform_device *pdev)
+{
+	return USBHS_GADGET;
+}
+
 /*
  *		syscfg functions
  */
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index b2b21fb..65e9abc 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -297,6 +297,8 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data);
 #define usbhs_lock(p, f) spin_lock_irqsave(usbhs_priv_to_lock(p), f)
 #define usbhs_unlock(p, f) spin_unlock_irqrestore(usbhs_priv_to_lock(p), f)
 
+int usbhs_get_id_as_gadget(struct platform_device *pdev);
+
 /*
  * sysconfig
  */
diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c
index 0027092..741bd81 100644
--- a/drivers/usb/renesas_usbhs/rcar2.c
+++ b/drivers/usb/renesas_usbhs/rcar2.c
@@ -3,6 +3,7 @@
  * Renesas USB driver R-Car Gen. 2 initialization and power control
  *
  * Copyright (C) 2014 Ulrich Hecht
+ * Copyright (C) 2019 Renesas Electronics Corporation
  */
 
 #include <linux/gpio.h>
@@ -62,14 +63,9 @@ static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
 	return retval;
 }
 
-static int usbhs_rcar2_get_id(struct platform_device *pdev)
-{
-	return USBHS_GADGET;
-}
-
 const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = {
 	.hardware_init = usbhs_rcar2_hardware_init,
 	.hardware_exit = usbhs_rcar2_hardware_exit,
 	.power_ctrl = usbhs_rcar2_power_ctrl,
-	.get_id = usbhs_rcar2_get_id,
+	.get_id = usbhs_get_id_as_gadget,
 };
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
index 5e730e9..8dbbd14 100644
--- a/drivers/usb/renesas_usbhs/rcar3.c
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -2,7 +2,7 @@
 /*
  * Renesas USB driver R-Car Gen. 3 initialization and power control
  *
- * Copyright (C) 2016 Renesas Electronics Corporation
+ * Copyright (C) 2016-2019 Renesas Electronics Corporation
  */
 
 #include <linux/delay.h>
@@ -95,17 +95,12 @@ static int usbhs_rcar3_power_and_pll_ctrl(struct platform_device *pdev,
 	return 0;
 }
 
-static int usbhs_rcar3_get_id(struct platform_device *pdev)
-{
-	return USBHS_GADGET;
-}
-
 const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
 	.power_ctrl = usbhs_rcar3_power_ctrl,
-	.get_id = usbhs_rcar3_get_id,
+	.get_id = usbhs_get_id_as_gadget,
 };
 
 const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = {
 	.power_ctrl = usbhs_rcar3_power_and_pll_ctrl,
-	.get_id = usbhs_rcar3_get_id,
+	.get_id = usbhs_get_id_as_gadget,
 };
diff --git a/drivers/usb/renesas_usbhs/rza.c b/drivers/usb/renesas_usbhs/rza.c
index 8c739bd..64ce584 100644
--- a/drivers/usb/renesas_usbhs/rza.c
+++ b/drivers/usb/renesas_usbhs/rza.c
@@ -3,7 +3,7 @@
  * Renesas USB driver RZ/A initialization and power control
  *
  * Copyright (C) 2018 Chris Brandt
- * Copyright (C) 2018 Renesas Electronics Corporation
+ * Copyright (C) 2018-2019 Renesas Electronics Corporation
  */
 
 #include <linux/delay.h>
@@ -41,12 +41,7 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev)
 	return 0;
 }
 
-static int usbhs_rza_get_id(struct platform_device *pdev)
-{
-	return USBHS_GADGET;
-}
-
 const struct renesas_usbhs_platform_callback usbhs_rza1_ops = {
 	.hardware_init = usbhs_rza1_hardware_init,
-	.get_id = usbhs_rza_get_id,
+	.get_id = usbhs_get_id_as_gadget,
 };
diff --git a/drivers/usb/renesas_usbhs/rza2.c b/drivers/usb/renesas_usbhs/rza2.c
index 9d8551f..6e32768 100644
--- a/drivers/usb/renesas_usbhs/rza2.c
+++ b/drivers/usb/renesas_usbhs/rza2.c
@@ -59,14 +59,9 @@ static int usbhs_rza2_power_ctrl(struct platform_device *pdev,
 	return retval;
 }
 
-static int usbhs_rza2_get_id(struct platform_device *pdev)
-{
-	return USBHS_GADGET;
-}
-
 const struct renesas_usbhs_platform_callback usbhs_rza2_ops = {
 	.hardware_init = usbhs_rza2_hardware_init,
 	.hardware_exit = usbhs_rza2_hardware_exit,
 	.power_ctrl = usbhs_rza2_power_ctrl,
-	.get_id = usbhs_rza2_get_id,
+	.get_id = usbhs_get_id_as_gadget,
 };
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 12/13] usb: renesas_usbhs: Use renesas_usbhs_platform_info on of_device_id.data
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (10 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 11/13] usb: renesas_usbhs: Add a common function for the .get_id Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-25  5:38 ` [PATCH 13/13] usb: renesas_usbhs: Use struct platform_callback pointer Yoshihiro Shimoda
  2019-06-26  2:34 ` [PATCH 00/13] usb: renesas_usbhs: refactor this driver Greg KH
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

In device tree environment, the previous code allocates
renesas_usbhs_platform_info by using devm_kzalloc() and then copies
usbhs_of_data to the allocated memory. This reason is some values
(e.g. .platform_callback.get_vbus) are overwritten by the driver,
but the of_device_id.data is "const". Now the driver doesn't have
such a code, so this patch uses renesas_usbhs_platform_info on
of_device_id.data.

Note that the previous code set the pdev->dev.platform_data pointer
even if device tree environment, but the value is not used. So,
this patch also remove such a code.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 93 +++++++-------------------------------
 drivers/usb/renesas_usbhs/common.h |  5 --
 drivers/usb/renesas_usbhs/rcar2.c  | 16 +++++--
 drivers/usb/renesas_usbhs/rcar2.h  |  3 +-
 drivers/usb/renesas_usbhs/rcar3.c  | 26 ++++++++---
 drivers/usb/renesas_usbhs/rcar3.h  |  5 +-
 drivers/usb/renesas_usbhs/rza.c    | 11 +++--
 drivers/usb/renesas_usbhs/rza.h    |  4 +-
 drivers/usb/renesas_usbhs/rza2.c   | 17 +++++--
 9 files changed, 73 insertions(+), 107 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 656f976..fe7dc91 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -530,128 +530,65 @@ int usbhsc_schedule_notify_hotplug(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct usbhs_of_data rcar_gen2_data = {
-	.platform_callback = &usbhs_rcar2_ops,
-	.param = {
-		.has_usb_dmac = 1,
-		.has_new_pipe_configs = 1,
-	}
-};
-
-static const struct usbhs_of_data rcar_gen3_data = {
-	.platform_callback = &usbhs_rcar3_ops,
-	.param = {
-		.has_usb_dmac = 1,
-		.multi_clks = 1,
-		.has_new_pipe_configs = 1,
-	}
-};
-
-static const struct usbhs_of_data rcar_gen3_with_pll_data = {
-	.platform_callback = &usbhs_rcar3_with_pll_ops,
-	.param = {
-		.has_usb_dmac = 1,
-		.multi_clks = 1,
-		.has_new_pipe_configs = 1,
-	}
-};
-
-static const struct usbhs_of_data rza1_data = {
-	.platform_callback = &usbhs_rza1_ops,
-	.param = {
-		.has_new_pipe_configs = 1,
-	}
-};
-
-static const struct usbhs_of_data rza2_data = {
-	.platform_callback = &usbhs_rza2_ops,
-	.param = {
-		.has_cnen = 1,
-		.cfifo_byte_addr = 1,
-		.has_new_pipe_configs = 1,
-	}
-};
-
 /*
  *		platform functions
  */
 static const struct of_device_id usbhs_of_match[] = {
 	{
 		.compatible = "renesas,usbhs-r8a774c0",
-		.data = &rcar_gen3_with_pll_data,
+		.data = &usbhs_rcar_gen3_with_pll_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a7790",
-		.data = &rcar_gen2_data,
+		.data = &usbhs_rcar_gen2_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a7791",
-		.data = &rcar_gen2_data,
+		.data = &usbhs_rcar_gen2_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a7794",
-		.data = &rcar_gen2_data,
+		.data = &usbhs_rcar_gen2_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a7795",
-		.data = &rcar_gen3_data,
+		.data = &usbhs_rcar_gen3_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a7796",
-		.data = &rcar_gen3_data,
+		.data = &usbhs_rcar_gen3_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a77990",
-		.data = &rcar_gen3_with_pll_data,
+		.data = &usbhs_rcar_gen3_with_pll_plat_info,
 	},
 	{
 		.compatible = "renesas,usbhs-r8a77995",
-		.data = &rcar_gen3_with_pll_data,
+		.data = &usbhs_rcar_gen3_with_pll_plat_info,
 	},
 	{
 		.compatible = "renesas,rcar-gen2-usbhs",
-		.data = &rcar_gen2_data,
+		.data = &usbhs_rcar_gen2_plat_info,
 	},
 	{
 		.compatible = "renesas,rcar-gen3-usbhs",
-		.data = &rcar_gen3_data,
+		.data = &usbhs_rcar_gen3_plat_info,
 	},
 	{
 		.compatible = "renesas,rza1-usbhs",
-		.data = &rza1_data,
+		.data = &usbhs_rza1_plat_info,
 	},
 	{
 		.compatible = "renesas,rza2-usbhs",
-		.data = &rza2_data,
+		.data = &usbhs_rza2_plat_info,
 	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, usbhs_of_match);
 
-static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
-{
-	struct renesas_usbhs_platform_info *info;
-	struct renesas_usbhs_driver_param *dparam;
-	const struct usbhs_of_data *data;
-
-	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
-	if (!info)
-		return NULL;
-
-	data = of_device_get_match_data(dev);
-	if (!data)
-		return NULL;
-
-	dparam = &info->driver_param;
-	*dparam = data->param;
-	info->platform_callback = *data->platform_callback;
-
-	return info;
-}
-
 static int usbhs_probe(struct platform_device *pdev)
 {
-	struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
+	const struct renesas_usbhs_platform_info *info;
 	struct usbhs_priv *priv;
 	struct resource *res, *irq_res;
 	struct device *dev = &pdev->dev;
@@ -660,7 +597,9 @@ static int usbhs_probe(struct platform_device *pdev)
 
 	/* check device node */
 	if (dev_of_node(dev))
-		info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
+		info = of_device_get_match_data(dev);
+	else
+		info = renesas_usbhs_get_info(pdev);
 
 	/* check platform information */
 	if (!info) {
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 65e9abc..f6ffdb2 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -282,11 +282,6 @@ struct usbhs_priv {
 	struct clk *clks[2];
 };
 
-struct usbhs_of_data {
-	const struct renesas_usbhs_platform_callback	*platform_callback;
-	const struct renesas_usbhs_driver_param		param;
-};
-
 /*
  * common
  */
diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c
index 741bd81..440d213 100644
--- a/drivers/usb/renesas_usbhs/rcar2.c
+++ b/drivers/usb/renesas_usbhs/rcar2.c
@@ -63,9 +63,15 @@ static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
 	return retval;
 }
 
-const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = {
-	.hardware_init = usbhs_rcar2_hardware_init,
-	.hardware_exit = usbhs_rcar2_hardware_exit,
-	.power_ctrl = usbhs_rcar2_power_ctrl,
-	.get_id = usbhs_get_id_as_gadget,
+const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info = {
+	.platform_callback = {
+		.hardware_init = usbhs_rcar2_hardware_init,
+		.hardware_exit = usbhs_rcar2_hardware_exit,
+		.power_ctrl = usbhs_rcar2_power_ctrl,
+		.get_id = usbhs_get_id_as_gadget,
+	},
+	.driver_param = {
+		.has_usb_dmac = 1,
+		.has_new_pipe_configs = 1,
+	},
 };
diff --git a/drivers/usb/renesas_usbhs/rcar2.h b/drivers/usb/renesas_usbhs/rcar2.h
index 45e3526..7d88732 100644
--- a/drivers/usb/renesas_usbhs/rcar2.h
+++ b/drivers/usb/renesas_usbhs/rcar2.h
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "common.h"
 
-extern const struct renesas_usbhs_platform_callback
-	usbhs_rcar2_ops;
+extern const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info;
diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c
index 8dbbd14..c181b2a 100644
--- a/drivers/usb/renesas_usbhs/rcar3.c
+++ b/drivers/usb/renesas_usbhs/rcar3.c
@@ -95,12 +95,26 @@ static int usbhs_rcar3_power_and_pll_ctrl(struct platform_device *pdev,
 	return 0;
 }
 
-const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
-	.power_ctrl = usbhs_rcar3_power_ctrl,
-	.get_id = usbhs_get_id_as_gadget,
+const struct renesas_usbhs_platform_info usbhs_rcar_gen3_plat_info = {
+	.platform_callback = {
+		.power_ctrl = usbhs_rcar3_power_ctrl,
+		.get_id = usbhs_get_id_as_gadget,
+	},
+	.driver_param = {
+		.has_usb_dmac = 1,
+		.multi_clks = 1,
+		.has_new_pipe_configs = 1,
+	},
 };
 
-const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = {
-	.power_ctrl = usbhs_rcar3_power_and_pll_ctrl,
-	.get_id = usbhs_get_id_as_gadget,
+const struct renesas_usbhs_platform_info usbhs_rcar_gen3_with_pll_plat_info = {
+	.platform_callback = {
+		.power_ctrl = usbhs_rcar3_power_and_pll_ctrl,
+		.get_id = usbhs_get_id_as_gadget,
+	},
+	.driver_param = {
+		.has_usb_dmac = 1,
+		.multi_clks = 1,
+		.has_new_pipe_configs = 1,
+	},
 };
diff --git a/drivers/usb/renesas_usbhs/rcar3.h b/drivers/usb/renesas_usbhs/rcar3.h
index 49e535a..c7c5ec1 100644
--- a/drivers/usb/renesas_usbhs/rcar3.h
+++ b/drivers/usb/renesas_usbhs/rcar3.h
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "common.h"
 
-extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops;
-extern const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops;
+extern const struct renesas_usbhs_platform_info usbhs_rcar_gen3_plat_info;
+extern const struct renesas_usbhs_platform_info
+					usbhs_rcar_gen3_with_pll_plat_info;
diff --git a/drivers/usb/renesas_usbhs/rza.c b/drivers/usb/renesas_usbhs/rza.c
index 64ce584..24de64edb 100644
--- a/drivers/usb/renesas_usbhs/rza.c
+++ b/drivers/usb/renesas_usbhs/rza.c
@@ -41,7 +41,12 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev)
 	return 0;
 }
 
-const struct renesas_usbhs_platform_callback usbhs_rza1_ops = {
-	.hardware_init = usbhs_rza1_hardware_init,
-	.get_id = usbhs_get_id_as_gadget,
+const struct renesas_usbhs_platform_info usbhs_rza1_plat_info = {
+	.platform_callback = {
+		.hardware_init = usbhs_rza1_hardware_init,
+		.get_id = usbhs_get_id_as_gadget,
+	},
+	.driver_param = {
+		.has_new_pipe_configs = 1,
+	},
 };
diff --git a/drivers/usb/renesas_usbhs/rza.h b/drivers/usb/renesas_usbhs/rza.h
index 073a53d..1ca42a6 100644
--- a/drivers/usb/renesas_usbhs/rza.h
+++ b/drivers/usb/renesas_usbhs/rza.h
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "common.h"
 
-extern const struct renesas_usbhs_platform_callback usbhs_rza1_ops;
-extern const struct renesas_usbhs_platform_callback usbhs_rza2_ops;
+extern const struct renesas_usbhs_platform_info usbhs_rza1_plat_info;
+extern const struct renesas_usbhs_platform_info usbhs_rza2_plat_info;
diff --git a/drivers/usb/renesas_usbhs/rza2.c b/drivers/usb/renesas_usbhs/rza2.c
index 6e32768..0217495 100644
--- a/drivers/usb/renesas_usbhs/rza2.c
+++ b/drivers/usb/renesas_usbhs/rza2.c
@@ -59,9 +59,16 @@ static int usbhs_rza2_power_ctrl(struct platform_device *pdev,
 	return retval;
 }
 
-const struct renesas_usbhs_platform_callback usbhs_rza2_ops = {
-	.hardware_init = usbhs_rza2_hardware_init,
-	.hardware_exit = usbhs_rza2_hardware_exit,
-	.power_ctrl = usbhs_rza2_power_ctrl,
-	.get_id = usbhs_get_id_as_gadget,
+const struct renesas_usbhs_platform_info usbhs_rza2_plat_info = {
+	.platform_callback = {
+		.hardware_init = usbhs_rza2_hardware_init,
+		.hardware_exit = usbhs_rza2_hardware_exit,
+		.power_ctrl = usbhs_rza2_power_ctrl,
+		.get_id = usbhs_get_id_as_gadget,
+	},
+	.driver_param = {
+		.has_cnen = 1,
+		.cfifo_byte_addr = 1,
+		.has_new_pipe_configs = 1,
+	},
 };
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 13/13] usb: renesas_usbhs: Use struct platform_callback pointer
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (11 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 12/13] usb: renesas_usbhs: Use renesas_usbhs_platform_info on of_device_id.data Yoshihiro Shimoda
@ 2019-06-25  5:38 ` Yoshihiro Shimoda
  2019-06-26  2:34 ` [PATCH 00/13] usb: renesas_usbhs: refactor this driver Greg KH
  13 siblings, 0 replies; 15+ messages in thread
From: Yoshihiro Shimoda @ 2019-06-25  5:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-renesas-soc, Yoshihiro Shimoda

Now the driver fixes the issue of the commit 482982062f1b ("usb:
gadget: renesas_usbhs: bugfix: don't modify platform data") by
using usbhs_mod_info.get_vbus, this patches uses the pointer
instead of copied value to avoid redundancy. Note that struct
renesas_usbhs_driver_param has to use copied value because
the driver has to set some members (e.g. buswait_bwait).

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c | 8 ++++----
 drivers/usb/renesas_usbhs/common.h | 2 +-
 drivers/usb/renesas_usbhs/mod.c    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index fe7dc91..4c3de77 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -53,8 +53,8 @@
  */
 #define usbhs_platform_call(priv, func, args...)\
 	(!(priv) ? -ENODEV :			\
-	 !((priv)->pfunc.func) ? 0 :		\
-	 (priv)->pfunc.func(args))
+	 !((priv)->pfunc->func) ? 0 :		\
+	 (priv)->pfunc->func(args))
 
 /*
  *		common functions
@@ -644,7 +644,7 @@ static int usbhs_probe(struct platform_device *pdev)
 		dev_err(dev, "no platform callbacks\n");
 		return -EINVAL;
 	}
-	priv->pfunc = info->platform_callback;
+	priv->pfunc = &info->platform_callback;
 
 	/* set default param if platform doesn't have */
 	if (usbhs_get_dparam(priv, has_new_pipe_configs)) {
@@ -665,7 +665,7 @@ static int usbhs_probe(struct platform_device *pdev)
 
 	/* FIXME */
 	/* runtime power control ? */
-	if (priv->pfunc.get_vbus)
+	if (priv->pfunc->get_vbus)
 		usbhs_get_dparam(priv, runtime_pwctrl) = 1;
 
 	/*
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index f6ffdb2..d1a0a35 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -252,7 +252,7 @@ struct usbhs_priv {
 	unsigned int irq;
 	unsigned long irqflags;
 
-	struct renesas_usbhs_platform_callback	pfunc;
+	const struct renesas_usbhs_platform_callback *pfunc;
 	struct renesas_usbhs_driver_param	dparam;
 
 	struct delayed_work notify_hotplug_work;
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index ddf0153..10fc655 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -52,7 +52,7 @@ void usbhs_mod_non_autonomy_mode(struct usbhs_priv *priv)
 {
 	struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv);
 
-	info->get_vbus = priv->pfunc.get_vbus;
+	info->get_vbus = priv->pfunc->get_vbus;
 }
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/13] usb: renesas_usbhs: refactor this driver
  2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
                   ` (12 preceding siblings ...)
  2019-06-25  5:38 ` [PATCH 13/13] usb: renesas_usbhs: Use struct platform_callback pointer Yoshihiro Shimoda
@ 2019-06-26  2:34 ` Greg KH
  13 siblings, 0 replies; 15+ messages in thread
From: Greg KH @ 2019-06-26  2:34 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: linux-usb, linux-renesas-soc

On Tue, Jun 25, 2019 at 02:38:44PM +0900, Yoshihiro Shimoda wrote:
> This patch series is based on Greg's usb.git / usb-next branch.
> 
> The previous code had redundant memory allocations so that
> the code readability was not good. I believe this patch series
> makes it better.

Nice cleanups, thanks for this!

greg k-h

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-06-26  2:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25  5:38 [PATCH 00/13] usb: renesas_usbhs: refactor this driver Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 01/13] usb: renesas_usbhs: revise the irq_vbus comments Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 02/13] usb: renesas_usbhs: remove notify_hotplug callback Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 03/13] usb: renesas_usbhs: move macros from mod.c to the mod.h Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 04/13] usb: renesas_usbhs: Avoid to write platform_data's value Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 05/13] usb: renesas_usbhs: Use a specific flag instead of type for multi_clks Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 06/13] usb: renesas_usbhs: Remove type member from renesas_usbhs_driver_param Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 07/13] usb: renesas_usbhs: Use dev_of_node macro instead of open coded Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 08/13] usb: renesas_usbhs: Add has_new_pipe_configs flag Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 09/13] usb: renesas_usbhs: Add struct device * declaration in usbhs_probe() Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 10/13] usb: renesas_usbhs: move device tree properties parsing Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 11/13] usb: renesas_usbhs: Add a common function for the .get_id Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 12/13] usb: renesas_usbhs: Use renesas_usbhs_platform_info on of_device_id.data Yoshihiro Shimoda
2019-06-25  5:38 ` [PATCH 13/13] usb: renesas_usbhs: Use struct platform_callback pointer Yoshihiro Shimoda
2019-06-26  2:34 ` [PATCH 00/13] usb: renesas_usbhs: refactor this driver Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).