[U-Boot] [PATCH v5 03/34] musb: sunxi: Use simple way to fill musb_hdrc pdata

Chen-Yu Tsai wens at csie.org
Mon Apr 23 07:52:38 UTC 2018


On Mon, Apr 23, 2018 at 3:51 PM, Maxime Ripard
<maxime.ripard at bootlin.com> wrote:
> On Sat, Apr 21, 2018 at 05:49:14PM +0530, Jagan Teki wrote:
>> Filling musb_hdrc pdata using structure will unnecessary
>> add extra ifdefs, so fill them inside probe call for
>> better code understanding and get rid ifdefs using
>> devicetree compatible.
>>
>> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
>> ---
>>  drivers/usb/musb-new/sunxi.c | 22 +++++++++-------------
>>  1 file changed, 9 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
>> index 3f3b89886a..0b7ff9ff09 100644
>> --- a/drivers/usb/musb-new/sunxi.c
>> +++ b/drivers/usb/musb-new/sunxi.c
>> @@ -308,22 +308,12 @@ static struct musb_hdrc_config musb_config = {
>>       .ram_bits       = SUNXI_MUSB_RAM_BITS,
>>  };
>>
>> -static struct musb_hdrc_platform_data musb_plat = {
>> -#if defined(CONFIG_USB_MUSB_HOST)
>> -     .mode           = MUSB_HOST,
>> -#else
>> -     .mode           = MUSB_PERIPHERAL,
>> -#endif
>> -     .config         = &musb_config,
>> -     .power          = 250,
>> -     .platform_ops   = &sunxi_musb_ops,
>> -};
>> -
>>  static int musb_usb_probe(struct udevice *dev)
>>  {
>>       struct sunxi_glue *glue = dev_get_priv(dev);
>>       struct musb_host_data *host = &glue->mdata;
>>       struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
>> +     struct musb_hdrc_platform_data pdata;
>
> This will allocate a value on the stack that will have a random
> content, and you're not initializing it anywhere.
>
> You need a memset here.

or

    struct musb_hdrc_platform_data pdata = {0};

ChenYu


More information about the U-Boot mailing list