Re: [PATCH 07/19] usb: dwc2: set parameter values in probe function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/9/2015 8:04 AM, Mian Yousaf Kaukab wrote:
> So the parameters can be used in both host and gadget modes.
> 
> Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@xxxxxxxxx>
> ---
>  drivers/usb/dwc2/core.h     |  3 +--
>  drivers/usb/dwc2/hcd.c      | 18 +-----------------
>  drivers/usb/dwc2/hcd.h      |  3 +--
>  drivers/usb/dwc2/pci.c      | 17 ++++++++++++++++-
>  drivers/usb/dwc2/platform.c | 18 +++++++++++++++++-
>  5 files changed, 36 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 795e4ed..9098749 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -1123,8 +1123,7 @@ static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
>  static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
>  static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
>  static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
> -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
> -				const struct dwc2_core_params *params)
> +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
>  { return 0; }
>  #endif
>  
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index c78c874..908fc8a 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -2775,8 +2775,7 @@ EXPORT_SYMBOL_GPL(dwc2_set_all_params);
>   * USB bus with the core and calls the hc_driver->start() function. It returns
>   * a negative error on failure.
>   */
> -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
> -		  const struct dwc2_core_params *params)
> +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
>  {
>  	struct usb_hcd *hcd;
>  	struct dwc2_host_chan *channel;
> @@ -2789,12 +2788,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
>  
>  	dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
>  
> -	/* Detect config values from hardware */
> -	retval = dwc2_get_hwparams(hsotg);
> -
> -	if (retval)
> -		return retval;
> -
>  	retval = -ENOMEM;
>  
>  	hcfg = readl(hsotg->regs + HCFG);
> @@ -2813,15 +2806,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
>  	hsotg->last_frame_num = HFNUM_MAX_FRNUM;
>  #endif
>  
> -	hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
> -	if (!hsotg->core_params)
> -		goto error1;
> -
> -	dwc2_set_all_params(hsotg->core_params, -1);
> -
> -	/* Validate parameter values */
> -	dwc2_set_parameters(hsotg, params);
> -
>  	/* Check if the bus driver or platform code has setup a dma_mask */
>  	if (hsotg->core_params->dma_enable > 0 &&
>  	    hsotg->dev->dma_mask == NULL) {
> diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
> index e69a843..cd803ae 100644
> --- a/drivers/usb/dwc2/hcd.h
> +++ b/drivers/usb/dwc2/hcd.h
> @@ -451,8 +451,7 @@ static inline u8 dwc2_hcd_is_pipe_out(struct dwc2_hcd_pipe_info *pipe)
>  	return !dwc2_hcd_is_pipe_in(pipe);
>  }
>  
> -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
> -			 const struct dwc2_core_params *params);
> +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq);
>  extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
>  extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
>  				const struct dwc2_core_params *params);
> diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
> index e5e6ab9..2e82268 100644
> --- a/drivers/usb/dwc2/pci.c
> +++ b/drivers/usb/dwc2/pci.c
> @@ -147,8 +147,23 @@ static int dwc2_driver_probe(struct pci_dev *dev,
>  	if (retval)
>  		return retval;
>  
> +	/* Detect config values from hardware */
> +	retval = dwc2_get_hwparams(hsotg);
> +	if (retval)
> +		return retval;
> +
> +	hsotg->core_params = devm_kzalloc(&dev->dev,
> +				sizeof(*hsotg->core_params), GFP_KERNEL);
> +	if (!hsotg->core_params)
> +		return -ENOMEM;
> +
> +	dwc2_set_all_params(hsotg->core_params, -1);
> +
> +	/* Validate parameter values */
> +	dwc2_set_parameters(hsotg, &dwc2_module_params);
> +
>  	spin_lock_init(&hsotg->lock);
> -	retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
> +	retval = dwc2_hcd_init(hsotg, dev->irq);
>  	if (retval) {
>  		pci_disable_device(dev);
>  		return retval;
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index f9b7d9f..a6d4b43 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -237,10 +237,26 @@ static int dwc2_driver_probe(struct platform_device *dev)
>  
>  	spin_lock_init(&hsotg->lock);
>  	mutex_init(&hsotg->init_mutex);
> +
> +	/* Detect config values from hardware */
> +	retval = dwc2_get_hwparams(hsotg);
> +	if (retval)
> +		return retval;
> +
> +	hsotg->core_params = devm_kzalloc(&dev->dev,
> +				sizeof(*hsotg->core_params), GFP_KERNEL);
> +	if (!hsotg->core_params)
> +		return -ENOMEM;
> +
> +	dwc2_set_all_params(hsotg->core_params, -1);
> +
> +	/* Validate parameter values */
> +	dwc2_set_parameters(hsotg, params);
> +
>  	retval = dwc2_gadget_init(hsotg, irq);
>  	if (retval)
>  		return retval;
> -	retval = dwc2_hcd_init(hsotg, irq, params);
> +	retval = dwc2_hcd_init(hsotg, irq);
>  	if (retval)
>  		return retval;
>  
> 

dwc2_get_hwparams and dwc2_set_parameters need export.

In core.h, dwc2_set_all_params() is still defined as static
inline nil function when configured as PERIPHERAL.

Also, as part of this enhancement could you consolidate all the
param structures and functions in the core.h/core.c? For example
dwc2_get_hwparams is declared in hcd.h but defined in core.c.

Regards,
John


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux