[U-Boot] [PATCH 2/6] usb: host: xhci-omap: fix double weak board_usb_init functions

Uri Mashiach uri.mashiach at compulab.co.il
Thu Feb 9 11:36:15 UTC 2017


Hello Marek,

On 02/09/2017 10:35 AM, Marek Vasut wrote:
> On 02/09/2017 08:01 AM, Uri Mashiach wrote:
>> A weak version of the function board_usb_init is implemented in:
>> common/usb.c
>> drivers/usb/host/xhci-omap.c
>>
>> To fix the double implementations:
>> * Convert the board_usb_init function in drivers/usb/host/xhci-omap.c
>>   normal (not weak).
>> * The function board_usb_init in drivers/usb/host/xhci-omap.c calls to
>>   the weak function omap_xhci_board_usb_init.
>> * Rename board version of the function board_usb_init to
>>   omap_xhci_board_usb_init.
>>   Done only for boards that defines CONFIG_USB_XHCI_OMAP.
>>
>> To achieve the same flexibility with the function board_usb_cleanup:
>> * Add a normal (not weak) implementation of the function
>>   board_usb_cleanup in drivers/usb/host/xhci-omap.c
>> * The function board_usb_cleanup in drivers/usb/host/xhci-omap.c calls
>>   to the weak function omap_xhci_board_usb_cleanup.
>> * Rename board version of the function board_usb_cleanup to
>>   omap_xhci_board_usb_cleanup.
>>   Done only for boards that defines CONFIG_USB_XHCI_OMAP.
>>
>> Signed-off-by: Uri Mashiach <uri.mashiach at compulab.co.il>
>> ---
>>  board/compulab/cl-som-am57x/cl-som-am57x.c |  2 +-
>>  board/ti/am43xx/board.c                    |  4 ++--
>>  board/ti/am57xx/board.c                    |  4 ++--
>>  board/ti/dra7xx/evm.c                      |  4 ++--
>>  drivers/usb/host/xhci-omap.c               | 23 +++++++++++++++++++++--
>>  5 files changed, 28 insertions(+), 9 deletions(-)
>>
>> diff --git a/board/compulab/cl-som-am57x/cl-som-am57x.c b/board/compulab/cl-som-am57x/cl-som-am57x.c
>> index bdd0a2b..fe1468f 100644
>> --- a/board/compulab/cl-som-am57x/cl-som-am57x.c
>> +++ b/board/compulab/cl-som-am57x/cl-som-am57x.c
>> @@ -54,7 +54,7 @@ int board_mmc_init(bd_t *bis)
>>  #endif /* CONFIG_GENERIC_MMC */
>>
>>  #ifdef CONFIG_USB_XHCI_OMAP
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_init(int index, enum usb_init_type init)
>>  {
>>  	setbits_le32((*prcm)->cm_l3init_usb_otg_ss1_clkctrl,
>>  		     OTG_SS_CLKCTRL_MODULEMODE_HW | OPTFCLKEN_REFCLK960M);
>> diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
>> index 390cc16..2572029 100644
>> --- a/board/ti/am43xx/board.c
>> +++ b/board/ti/am43xx/board.c
>> @@ -694,7 +694,7 @@ int usb_gadget_handle_interrupts(int index)
>>  #endif /* CONFIG_USB_DWC3 */
>>
>>  #if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_init(int index, enum usb_init_type init)
>>  {
>>  	enable_usb_clocks(index);
>>  #ifdef CONFIG_USB_DWC3
>> @@ -725,7 +725,7 @@ int board_usb_init(int index, enum usb_init_type init)
>>  	return 0;
>>  }
>>
>> -int board_usb_cleanup(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
>>  {
>>  #ifdef CONFIG_USB_DWC3
>>  	switch (index) {
>> diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
>> index 5f2d4df..96fad0f 100644
>> --- a/board/ti/am57xx/board.c
>> +++ b/board/ti/am57xx/board.c
>> @@ -616,7 +616,7 @@ int usb_gadget_handle_interrupts(int index)
>>  #endif /* CONFIG_USB_DWC3 */
>>
>>  #if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP)
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_init(int index, enum usb_init_type init)
>>  {
>>  	enable_usb_clocks(index);
>>  	switch (index) {
>> @@ -650,7 +650,7 @@ int board_usb_init(int index, enum usb_init_type init)
>>  	return 0;
>>  }
>>
>> -int board_usb_cleanup(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
>>  {
>>  #ifdef CONFIG_USB_DWC3
>>  	switch (index) {
>> diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
>> index bd1c809..21fa824 100644
>> --- a/board/ti/dra7xx/evm.c
>> +++ b/board/ti/dra7xx/evm.c
>> @@ -727,7 +727,7 @@ static struct ti_usb_phy_device usb_phy2_device = {
>>  	.index = 1,
>>  };
>>
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int  omap_xhci_board_usb_init(int index, enum usb_init_type init)
>>  {
>>  	enable_usb_clocks(index);
>>  	switch (index) {
>> @@ -764,7 +764,7 @@ int board_usb_init(int index, enum usb_init_type init)
>>  	return 0;
>>  }
>>
>> -int board_usb_cleanup(int index, enum usb_init_type init)
>> +int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
>>  {
>>  	switch (index) {
>>  	case 0:
>> diff --git a/drivers/usb/host/xhci-omap.c b/drivers/usb/host/xhci-omap.c
>> index b881b19..ceee12a 100644
>> --- a/drivers/usb/host/xhci-omap.c
>> +++ b/drivers/usb/host/xhci-omap.c
>> @@ -27,12 +27,31 @@ DECLARE_GLOBAL_DATA_PTR;
>>
>>  static struct omap_xhci omap;
>>
>> -__weak int __board_usb_init(int index, enum usb_init_type init)
>> +__weak int __omap_xhci_board_usb_init(int index, enum usb_init_type init)
>>  {
>>  	return 0;
>>  }
>> +
>> +int omap_xhci_board_usb_init(int index, enum usb_init_type init)
>> +	__attribute__((weak, alias("__omap_xhci_board_usb_init")));
>
> You can just use __weak instead of this attribute block .
>

With the attribute block it is possible to call to 
__omap_xhci_board_usb_init from the board file.
Do you think it's redundant?

>>  int board_usb_init(int index, enum usb_init_type init)
>> -	__attribute__((weak, alias("__board_usb_init")));
>> +{
>> +	return omap_xhci_board_usb_init(index, init);
>> +}
>> +
>> +__weak int __omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
>> +{
>> +	return 0;
>> +}
>> +
>> +int omap_xhci_board_usb_cleanup(int index, enum usb_init_type init)
>> +	__attribute__((weak, alias("__omap_xhci_board_usb_cleanup")));
>> +
>> +int board_usb_cleanup(int index, enum usb_init_type init)
>> +{
>> +	return omap_xhci_board_usb_cleanup(index, init);
>> +}
>>
>>  static int omap_xhci_core_init(struct omap_xhci *omap)
>>  {
>>
>
>

-- 
Thanks,
Uri


More information about the U-Boot mailing list