Commit 48298206 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Felipe Balbi

usb: gadget: renesas_usbhs: bugfix: don't modify platform data

renesas_usbhs has default callback functions and settings.
And it tried overwrite to platform private data
if platform doesn't have them.
So, if renesas_usbhs was compiled as module,
it will be hung-up on 2nd insmod.
This patch fixup it.
Special thanks to Bastian
Reported-by: default avatarBastian Hecht <hechtb@googlemail.com>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 034d7c13
...@@ -61,8 +61,8 @@ ...@@ -61,8 +61,8 @@
*/ */
#define usbhs_platform_call(priv, func, args...)\ #define usbhs_platform_call(priv, func, args...)\
(!(priv) ? -ENODEV : \ (!(priv) ? -ENODEV : \
!((priv)->pfunc->func) ? 0 : \ !((priv)->pfunc.func) ? 0 : \
(priv)->pfunc->func(args)) (priv)->pfunc.func(args))
/* /*
* common functions * common functions
...@@ -446,24 +446,28 @@ static int __devinit usbhs_probe(struct platform_device *pdev) ...@@ -446,24 +446,28 @@ static int __devinit usbhs_probe(struct platform_device *pdev)
/* /*
* care platform info * care platform info
*/ */
priv->pfunc = &info->platform_callback; memcpy(&priv->pfunc,
priv->dparam = &info->driver_param; &info->platform_callback,
sizeof(struct renesas_usbhs_platform_callback));
memcpy(&priv->dparam,
&info->driver_param,
sizeof(struct renesas_usbhs_driver_param));
/* set driver callback functions for platform */ /* set driver callback functions for platform */
dfunc = &info->driver_callback; dfunc = &info->driver_callback;
dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug; dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug;
/* set default param if platform doesn't have */ /* set default param if platform doesn't have */
if (!priv->dparam->pipe_type) { if (!priv->dparam.pipe_type) {
priv->dparam->pipe_type = usbhsc_default_pipe_type; priv->dparam.pipe_type = usbhsc_default_pipe_type;
priv->dparam->pipe_size = ARRAY_SIZE(usbhsc_default_pipe_type); priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe_type);
} }
if (!priv->dparam->pio_dma_border) if (!priv->dparam.pio_dma_border)
priv->dparam->pio_dma_border = 64; /* 64byte */ priv->dparam.pio_dma_border = 64; /* 64byte */
/* FIXME */ /* FIXME */
/* runtime power control ? */ /* runtime power control ? */
if (priv->pfunc->get_vbus) if (priv->pfunc.get_vbus)
usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL); usbhsc_flags_set(priv, USBHSF_RUNTIME_PWCTRL);
/* /*
......
...@@ -242,8 +242,8 @@ struct usbhs_priv { ...@@ -242,8 +242,8 @@ struct usbhs_priv {
void __iomem *base; void __iomem *base;
unsigned int irq; unsigned int irq;
struct renesas_usbhs_platform_callback *pfunc; struct renesas_usbhs_platform_callback pfunc;
struct renesas_usbhs_driver_param *dparam; struct renesas_usbhs_driver_param dparam;
struct delayed_work notify_hotplug_work; struct delayed_work notify_hotplug_work;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -318,7 +318,7 @@ int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, u16 upphub, ...@@ -318,7 +318,7 @@ int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, u16 upphub,
* data * data
*/ */
struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev); struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);
#define usbhs_get_dparam(priv, param) (priv->dparam->param) #define usbhs_get_dparam(priv, param) (priv->dparam.param)
#define usbhs_priv_to_pdev(priv) (priv->pdev) #define usbhs_priv_to_pdev(priv) (priv->pdev)
#define usbhs_priv_to_dev(priv) (&priv->pdev->dev) #define usbhs_priv_to_dev(priv) (&priv->pdev->dev)
#define usbhs_priv_to_lock(priv) (&priv->lock) #define usbhs_priv_to_lock(priv) (&priv->lock)
......
...@@ -58,7 +58,7 @@ void usbhs_mod_autonomy_mode(struct usbhs_priv *priv) ...@@ -58,7 +58,7 @@ void usbhs_mod_autonomy_mode(struct usbhs_priv *priv)
struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv); struct usbhs_mod_info *info = usbhs_priv_to_modinfo(priv);
info->irq_vbus = usbhsm_autonomy_irq_vbus; info->irq_vbus = usbhsm_autonomy_irq_vbus;
priv->pfunc->get_vbus = usbhsm_autonomy_get_vbus; priv->pfunc.get_vbus = usbhsm_autonomy_get_vbus;
usbhs_irq_callback_update(priv, NULL); usbhs_irq_callback_update(priv, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment