Skip to content

Commit 0bf048a

Browse files
arndbgregkh
authored andcommitted
staging: emxx_udc: allow modular build
A change to the usb gadget core allowed certain API functions to be part of a loadable module, which breaks having emxx_udc built-in: drivers/staging/built-in.o: In function `nbu2ss_drv_probe': (.text+0x2428): undefined reference to `usb_ep_set_maxpacket_limit' The original patch already fixed tons of other cases that have the added dependency but apparently missed this one that now appears in an ARM allmodconfig build. This patch makes the symbol "tristate", which lets the Kconfig dependency tracking handle it correctly. To make the module actually usable, I also revert 0af61e6 ("drivers/staging: make emxx_udc.c explicitly non-modular"), which Paul Gortmaker added after noticing that the Kconfig symbol was 'bool'. Compared to the original version however, I leave out the '__exit' annotation on the remove callback, as Paul pointed out that this was incorrect. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 5a8d651 ("usb: gadget: move gadget API functions to udc-core") Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 71da2ba commit 0bf048a

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

drivers/staging/emxx_udc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
config USB_EMXX
2-
bool "EMXX USB Function Device Controller"
2+
tristate "EMXX USB Function Device Controller"
33
depends on USB_GADGET && (ARCH_SHMOBILE || (ARM && COMPILE_TEST))
44
help
55
The Emma Mobile series of SoCs from Renesas Electronics and

drivers/staging/emxx_udc/emxx_udc.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#include <linux/kernel.h>
18-
#include <linux/init.h>
18+
#include <linux/module.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/delay.h>
2121
#include <linux/ioport.h>
@@ -39,9 +39,11 @@
3939

4040
#include "emxx_udc.h"
4141

42+
#define DRIVER_DESC "EMXX UDC driver"
4243
#define DMA_ADDR_INVALID (~(dma_addr_t)0)
4344

4445
static const char driver_name[] = "emxx_udc";
46+
static const char driver_desc[] = DRIVER_DESC;
4547

4648
/*===========================================================================*/
4749
/* Prototype */
@@ -3295,6 +3297,28 @@ static void nbu2ss_drv_shutdown(struct platform_device *pdev)
32953297
_nbu2ss_disable_controller(udc);
32963298
}
32973299

3300+
/*-------------------------------------------------------------------------*/
3301+
static int nbu2ss_drv_remove(struct platform_device *pdev)
3302+
{
3303+
struct nbu2ss_udc *udc;
3304+
struct nbu2ss_ep *ep;
3305+
int i;
3306+
3307+
udc = &udc_controller;
3308+
3309+
for (i = 0; i < NUM_ENDPOINTS; i++) {
3310+
ep = &udc->ep[i];
3311+
if (ep->virt_buf)
3312+
dma_free_coherent(NULL, PAGE_SIZE,
3313+
(void *)ep->virt_buf, ep->phys_buf);
3314+
}
3315+
3316+
/* Interrupt Handler - Release */
3317+
free_irq(INT_VBUS, udc);
3318+
3319+
return 0;
3320+
}
3321+
32983322
/*-------------------------------------------------------------------------*/
32993323
static int nbu2ss_drv_suspend(struct platform_device *pdev, pm_message_t state)
33003324
{
@@ -3347,12 +3371,16 @@ static int nbu2ss_drv_resume(struct platform_device *pdev)
33473371
static struct platform_driver udc_driver = {
33483372
.probe = nbu2ss_drv_probe,
33493373
.shutdown = nbu2ss_drv_shutdown,
3374+
.remove = nbu2ss_drv_remove,
33503375
.suspend = nbu2ss_drv_suspend,
33513376
.resume = nbu2ss_drv_resume,
33523377
.driver = {
3353-
.name = driver_name,
3354-
.suppress_bind_attrs = true,
3378+
.name = driver_name,
33553379
},
33563380
};
33573381

3358-
builtin_platform_driver(udc_driver);
3382+
module_platform_driver(udc_driver);
3383+
3384+
MODULE_DESCRIPTION(DRIVER_DESC);
3385+
MODULE_AUTHOR("Renesas Electronics Corporation");
3386+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)