arcotg_udc: exports duplicate symbol imx_usb_create_charger (owned by kernel)

时间:2021-05-21 23:18:58
/*********************************************************************************
 * arcotg_udc: exports duplicate symbol imx_usb_create_charger (owned by kernel)
 * 说明:
 *     内核驱动中导出的函数和模块中导出的函数重复了。
 *
 *                                              2017-10-14 深圳 南山平山村 曾剑锋
 ********************************************************************************/


一、错误信息:
    [zengjf@root ~]#  modprobe g_ffs idVendor=0x18d1 idProduct=0x4e42 iSerialNumber
    ="buildroot"
    arcotg_udc: exports duplicate symbol imx_usb_create_charger (owned by kernel)
    modprobe: can't load module arcotg_udc (kernel/drivers/usb/gadget/arcotg_udc.ko): invalid module format
    [zengjf@root ~]#

二、查找imx_usb_create_charger函数:
    Qt@zengjf:~/kernel/linuxQt_kernel$ grep imx_usb_create_charger * -R
    Binary file drivers/usb/gadget/arcotg_udc.o matches
    Binary file drivers/usb/gadget/arcotg_udc.ko matches
    drivers/usb/gadget/arcotg_udc.c:    if (imx_usb_create_charger(&udc_controller->charger, "imx_usb_charger"))
    drivers/usb/gadget/imx_usb_charger.c: * imx_usb_create_charger - create a USB charger
    drivers/usb/gadget/imx_usb_charger.c:int imx_usb_create_charger(struct usb_charger *charger,
    drivers/usb/gadget/imx_usb_charger.c:EXPORT_SYMBOL(imx_usb_create_charger);
    Module.symvers:0xa8003a03    imx_usb_create_charger    drivers/usb/gadget/arcotg_udc    EXPORT_SYMBOL
    Qt@zengjf:~/kernel/linuxQt_kernel$

三、cat drivers/usb/gadget/imx_usb_charger.c
    ...
    int imx_usb_create_charger(struct usb_charger *charger,
            const char *name)
    {
        int         ret = 0;
        struct power_supply *psy = &charger->psy;
    
        if (!charger->dev)
            return -EINVAL;
    
        if (name)
            psy->name = name;
        else
            psy->name = "usb_charger";
    
        usb_charger_init(charger);
    
        psy->type       = POWER_SUPPLY_TYPE_USB;
        psy->properties     = power_props;
        psy->num_properties = ARRAY_SIZE(power_props);
        psy->get_property   = usb_charger_get_property;
    
        psy->supplied_to    = usb_charger_supplied_to;
        psy->num_supplicants    = sizeof(usb_charger_supplied_to)/sizeof(char *);
        psy->external_power_changed = my_batt_ext_power_changed;
    
        ret = power_supply_register(charger->dev, psy);
        if (ret)
            goto fail;
    
        mutex_init(&charger->lock);
        INIT_WORK(&charger->work, usb_charger_work);
    
    fail:
        return ret;
    }
    EXPORT_SYMBOL(imx_usb_create_charger);
    ...

四、cat drivers/usb/gadget/arcotg_udc.c
    ...
        /* create usb charger */
    #ifdef CONFIG_IMX_USB_CHARGER
        udc_controller->charger.dev = &pdev->dev;
        udc_controller->charger.dp_pullup = usb_charger_pullup_dp;
        udc_controller->charger.enable = true;
        if (pdata->charger_base_addr)
            udc_controller->charger.charger_base_addr = pdata->charger_base_addr;
        if (imx_usb_create_charger(&udc_controller->charger, "imx_usb_charger"))
            dev_err(&pdev->dev, "Can't create usb charger\n");
    #else
        udc_controller->charger.dp_pullup = usb_charger_pullup_dp;
        udc_controller->charger.enable = false;
    #endif
    ...

五、解决办法:
    make menuconfig去掉CONFIG_IMX_USB_CHARGER