[PATCH] USB: mark USB drivers as being GPL only

Greg KH
2008-01-25T18:04:41Z

FYI, this is a patch that will be sent out in the next round to Linus
for inclusion in 2.6.25.

If anyone has any objections about it, please let me know.

thanks,

greg k-h

--------

From: Greg Kroah-Hartman <gregkh@suse.de>
Subject: USB: mark USB drivers as being GPL only

Over two years ago, the Linux USB developers stated that they believed
there was no way to create a USB kernel driver that was not under the
GPL. This patch moves the USB apis to enforce that decision.

There are no known closed source USB drivers in the wild, so this patch
should cause no problems.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
Documentation/feature-removal-schedule.txt | 16 -------
drivers/usb/core/driver.c | 10 ++--
drivers/usb/core/file.c | 4 -
drivers/usb/core/hcd-pci.c | 10 ++--
drivers/usb/core/hcd.c | 18 ++++----
drivers/usb/core/hub.c | 5 +-
drivers/usb/core/message.c | 32 +++++---------
drivers/usb/core/urb.c | 15 +++----
drivers/usb/core/usb.c | 62 ++++++++---------------------
9 files changed, 61 insertions(+), 111 deletions(-)

--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -156,22 +156,6 @@ Who: Arjan van de Ven <arjan@linux.intel

---------------------------

-What: USB driver API moves to EXPORT_SYMBOL_GPL
-When: February 2008
-Files: include/linux/usb.h, drivers/usb/core/driver.c
-Why: The USB subsystem has changed a lot over time, and it has been
- possible to create userspace USB drivers using usbfs/libusb/gadgetfs
- that operate as fast as the USB bus allows. Because of this, the USB
- subsystem will not be allowing closed source kernel drivers to
- register with it, after this grace period is over. If anyone needs
- any help in converting their closed source drivers over to use the
- userspace filesystems, please contact the
- linux-usb-devel@lists.sourceforge.net mailing list, and the developers
- there will be glad to help you out.
-Who: Greg Kroah-Hartman <gregkh@suse.de>
-
----------------------------
-
What: vm_ops.nopage
When: Soon, provided in-kernel callers have been converted
Why: This interface is replaced by vm_ops.fault, but it has been around
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -325,7 +325,7 @@ int usb_driver_claim_interface(struct us

return retval;
}
-EXPORT_SYMBOL(usb_driver_claim_interface);
+EXPORT_SYMBOL_GPL(usb_driver_claim_interface);

/**
* usb_driver_release_interface - unbind a driver from an interface
@@ -370,7 +370,7 @@ void usb_driver_release_interface(struct
iface->needs_remote_wakeup = 0;
usb_pm_unlock(udev);
}
-EXPORT_SYMBOL(usb_driver_release_interface);
+EXPORT_SYMBOL_GPL(usb_driver_release_interface);

/* returns 0 if no match, 1 if match */
int usb_match_device(struct usb_device *dev, const struct usb_device_id *id)
@@ -542,7 +542,7 @@ const struct usb_device_id *usb_match_id

return NULL;
}
-EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
+EXPORT_SYMBOL_GPL(usb_match_id);

static int usb_device_match(struct device *dev, struct device_driver *drv)
{
@@ -745,7 +745,7 @@ int usb_register_driver(struct usb_drive

return retval;
}
-EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver);
+EXPORT_SYMBOL_GPL(usb_register_driver);

/**
* usb_deregister - unregister a USB interface driver
@@ -769,7 +769,7 @@ void usb_deregister(struct usb_driver *d

usbfs_update_special();
}
-EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
+EXPORT_SYMBOL_GPL(usb_deregister);

#ifdef CONFIG_PM

--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -204,7 +204,7 @@ int usb_register_dev(struct usb_interfac
exit:
return retval;
}
-EXPORT_SYMBOL(usb_register_dev);
+EXPORT_SYMBOL_GPL(usb_register_dev);

/**
* usb_deregister_dev - deregister a USB device's dynamic minor.
@@ -245,4 +245,4 @@ void usb_deregister_dev(struct usb_inter
intf->minor = -1;
destroy_usb_class();
}
-EXPORT_SYMBOL(usb_deregister_dev);
+EXPORT_SYMBOL_GPL(usb_deregister_dev);
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -144,7 +144,7 @@ int usb_hcd_pci_probe (struct pci_dev *d
dev_err (&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
return retval;
}
-EXPORT_SYMBOL (usb_hcd_pci_probe);
+EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);

/* may be called without controller electrically present */
@@ -179,7 +179,7 @@ void usb_hcd_pci_remove (struct pci_dev
usb_put_hcd (hcd);
pci_disable_device(dev);
}
-EXPORT_SYMBOL (usb_hcd_pci_remove);
+EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);

#ifdef CONFIG_PM
@@ -314,7 +314,7 @@ done:

return retval;
}
-EXPORT_SYMBOL (usb_hcd_pci_suspend);
+EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);

/**
* usb_hcd_pci_resume - power management resume of a PCI-based HCD
@@ -416,7 +416,7 @@ int usb_hcd_pci_resume (struct pci_dev *

return retval;
}
-EXPORT_SYMBOL (usb_hcd_pci_resume);
+EXPORT_SYMBOL_GPL(usb_hcd_pci_resume);

#endif /* CONFIG_PM */

@@ -435,5 +435,5 @@ void usb_hcd_pci_shutdown (struct pci_de
if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd);
}
-EXPORT_SYMBOL (usb_hcd_pci_shutdown);
+EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);

--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -971,7 +971,7 @@ long usb_calc_bus_time (int speed, int i
return -1;
}
}
-EXPORT_SYMBOL (usb_calc_bus_time);
+EXPORT_SYMBOL_GPL(usb_calc_bus_time);

/*-------------------------------------------------------------------------*/
@@ -1427,7 +1427,7 @@ void usb_hcd_giveback_urb(struct usb_hcd
wake_up (&usb_kill_urb_queue);
usb_put_urb (urb);
}
-EXPORT_SYMBOL (usb_hcd_giveback_urb);
+EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb);

/*-------------------------------------------------------------------------*/

@@ -1667,7 +1667,7 @@ int usb_bus_start_enum(struct usb_bus *b
mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10));
return status;
}
-EXPORT_SYMBOL (usb_bus_start_enum);
+EXPORT_SYMBOL_GPL(usb_bus_start_enum);

#endif

@@ -1774,7 +1774,7 @@ struct usb_hcd *usb_create_hcd (const st
"USB Host Controller";
return hcd;
}
-EXPORT_SYMBOL (usb_create_hcd);
+EXPORT_SYMBOL_GPL(usb_create_hcd);

static void hcd_release (struct kref *kref)
{
@@ -1789,14 +1789,14 @@ struct usb_hcd *usb_get_hcd (struct usb_
kref_get (&hcd->kref);
return hcd;
}
-EXPORT_SYMBOL (usb_get_hcd);
+EXPORT_SYMBOL_GPL(usb_get_hcd);

void usb_put_hcd (struct usb_hcd *hcd)
{
if (hcd)
kref_put (&hcd->kref, hcd_release);
}
-EXPORT_SYMBOL (usb_put_hcd);
+EXPORT_SYMBOL_GPL(usb_put_hcd);

/**
* usb_add_hcd - finish generic HCD structure initialization and register
@@ -1922,7 +1922,7 @@ err_register_bus:
hcd_buffer_destroy(hcd);
return retval;
}
-EXPORT_SYMBOL (usb_add_hcd);
+EXPORT_SYMBOL_GPL(usb_add_hcd);

/**
* usb_remove_hcd - shutdown processing for generic HCDs
@@ -1964,7 +1964,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(&hcd->self);
hcd_buffer_destroy(hcd);
}
-EXPORT_SYMBOL (usb_remove_hcd);
+EXPORT_SYMBOL_GPL(usb_remove_hcd);

void
usb_hcd_platform_shutdown(struct platform_device* dev)
@@ -1974,7 +1974,7 @@ usb_hcd_platform_shutdown(struct platfor
if (hcd->driver->shutdown)
hcd->driver->shutdown(hcd);
}
-EXPORT_SYMBOL (usb_hcd_platform_shutdown);
+EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);

/*-------------------------------------------------------------------------*/

--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -494,6 +494,7 @@ void usb_hub_tt_clear_buffer (struct usb
schedule_work (&tt->kevent);
spin_unlock_irqrestore (&tt->lock, flags);
}
+EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer);

static void hub_power_on(struct usb_hub *hub)
{
@@ -3116,7 +3117,7 @@ re_enumerate:
hub_port_logical_disconnect(parent_hub, port1);
return -ENODEV;
}
-EXPORT_SYMBOL(usb_reset_device);
+EXPORT_SYMBOL_GPL(usb_reset_device);

/**
* usb_reset_composite_device - warn interface drivers and perform a USB port reset
@@ -3187,4 +3188,4 @@ int usb_reset_composite_device(struct us
usb_autosuspend_device(udev);
return ret;
}
-EXPORT_SYMBOL(usb_reset_composite_device);
+EXPORT_SYMBOL_GPL(usb_reset_composite_device);
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -147,7 +147,7 @@ int usb_control_msg(struct usb_device *d

return ret;
}
-
+EXPORT_SYMBOL_GPL(usb_control_msg);

/**
* usb_interrupt_msg - Builds an interrupt urb, sends it off and waits for completion
@@ -238,6 +238,7 @@ int usb_bulk_msg(struct usb_device *usb_

return usb_start_wait_urb(urb, timeout, actual_length);
}
+EXPORT_SYMBOL_GPL(usb_bulk_msg);

/*-------------------------------------------------------------------*/

@@ -465,7 +466,7 @@ nomem:
sg_clean (io);
return -ENOMEM;
}
-
+EXPORT_SYMBOL_GPL(usb_sg_init);

/**
* usb_sg_wait - synchronously execute scatter/gather request
@@ -569,6 +570,7 @@ void usb_sg_wait (struct usb_sg_request

sg_clean (io);
}
+EXPORT_SYMBOL_GPL(usb_sg_wait);

/**
* usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait()
@@ -604,6 +606,7 @@ void usb_sg_cancel (struct usb_sg_reques
}
spin_unlock_irqrestore (&io->lock, flags);
}
+EXPORT_SYMBOL_GPL(usb_sg_cancel);

/*-------------------------------------------------------------------*/

@@ -652,6 +655,7 @@ int usb_get_descriptor(struct usb_device
}
return result;
}
+EXPORT_SYMBOL_GPL(usb_get_descriptor);

/**
* usb_get_string - gets a string descriptor
@@ -827,6 +831,7 @@ int usb_string(struct usb_device *dev, i
kfree(tbuf);
return err;
}
+EXPORT_SYMBOL_GPL(usb_string);

/**
* usb_cache_string - read a string descriptor and cache it for later use
@@ -927,6 +932,7 @@ int usb_get_status(struct usb_device *de
kfree(status);
return ret;
}
+EXPORT_SYMBOL_GPL(usb_get_status);

/**
* usb_clear_halt - tells device to clear endpoint halt/stall condition
@@ -985,6 +991,7 @@ int usb_clear_halt(struct usb_device *de

return 0;
}
+EXPORT_SYMBOL_GPL(usb_clear_halt);

/**
* usb_disable_endpoint -- Disable an endpoint by address
@@ -1253,6 +1260,7 @@ int usb_set_interface(struct usb_device

return 0;
}
+EXPORT_SYMBOL_GPL(usb_set_interface);

/**
* usb_reset_configuration - lightweight device reset
@@ -1328,6 +1336,7 @@ int usb_reset_configuration(struct usb_d
}
return 0;
}
+EXPORT_SYMBOL_GPL(usb_reset_configuration);

static void usb_release_interface(struct device *dev)
{
@@ -1677,22 +1686,3 @@ int usb_driver_set_configuration(struct
return 0;
}
EXPORT_SYMBOL_GPL(usb_driver_set_configuration);
-
-// synchronous request completion model
-EXPORT_SYMBOL(usb_control_msg);
-EXPORT_SYMBOL(usb_bulk_msg);
-
-EXPORT_SYMBOL(usb_sg_init);
-EXPORT_SYMBOL(usb_sg_cancel);
-EXPORT_SYMBOL(usb_sg_wait);
-
-// synchronous control message convenience routines
-EXPORT_SYMBOL(usb_get_descriptor);
-EXPORT_SYMBOL(usb_get_status);
-EXPORT_SYMBOL(usb_string);
-
-// synchronous calls that also maintain usbcore state
-EXPORT_SYMBOL(usb_clear_halt);
-EXPORT_SYMBOL(usb_reset_configuration);
-EXPORT_SYMBOL(usb_set_interface);
-
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -42,6 +42,7 @@ void usb_init_urb(struct urb *urb)
INIT_LIST_HEAD(&urb->anchor_list);
}
}
+EXPORT_SYMBOL_GPL(usb_init_urb);

/**
* usb_alloc_urb - creates a new urb for a USB driver to use
@@ -73,6 +74,7 @@ struct urb *usb_alloc_urb(int iso_packet
usb_init_urb(urb);
return urb;
}
+EXPORT_SYMBOL_GPL(usb_alloc_urb);

/**
* usb_free_urb - frees the memory used by a urb when all users of it are finished
@@ -89,6 +91,7 @@ void usb_free_urb(struct urb *urb)
if (urb)
kref_put(&urb->kref, urb_destroy);
}
+EXPORT_SYMBOL_GPL(usb_free_urb);

/**
* usb_get_urb - increments the reference count of the urb
@@ -106,6 +109,7 @@ struct urb * usb_get_urb(struct urb *urb
kref_get(&urb->kref);
return urb;
}
+EXPORT_SYMBOL_GPL(usb_get_urb);

/**
* usb_anchor_urb - anchors an URB while it is processed
@@ -444,6 +448,7 @@ int usb_submit_urb(struct urb *urb, gfp_

return usb_hcd_submit_urb(urb, mem_flags);
}
+EXPORT_SYMBOL_GPL(usb_submit_urb);

/*-------------------------------------------------------------------*/

@@ -514,6 +519,7 @@ int usb_unlink_urb(struct urb *urb)
return -EIDRM;
return usb_hcd_unlink_urb(urb, -ECONNRESET);
}
+EXPORT_SYMBOL_GPL(usb_unlink_urb);

/**
* usb_kill_urb - cancel a transfer request and wait for it to finish
@@ -553,6 +559,7 @@ void usb_kill_urb(struct urb *urb)
--urb->reject;
mutex_unlock(&reject_mutex);
}
+EXPORT_SYMBOL_GPL(usb_kill_urb);

/**
* usb_kill_anchored_urbs - cancel transfer requests en masse
@@ -595,11 +602,3 @@ int usb_wait_anchor_empty_timeout(struct
msecs_to_jiffies(timeout));
}
EXPORT_SYMBOL_GPL(usb_wait_anchor_empty_timeout);
-
-EXPORT_SYMBOL(usb_init_urb);
-EXPORT_SYMBOL(usb_alloc_urb);
-EXPORT_SYMBOL(usb_free_urb);
-EXPORT_SYMBOL(usb_get_urb);
-EXPORT_SYMBOL(usb_submit_urb);
-EXPORT_SYMBOL(usb_unlink_urb);
-EXPORT_SYMBOL(usb_kill_urb);
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -96,6 +96,7 @@ struct usb_interface *usb_ifnum_to_if(co

return NULL;
}
+EXPORT_SYMBOL_GPL(usb_ifnum_to_if);

/**
* usb_altnum_to_altsetting - get the altsetting structure with a given
@@ -126,6 +127,7 @@ struct usb_host_interface *usb_altnum_to
}
return NULL;
}
+EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);

struct find_interface_arg {
int minor;
@@ -170,6 +172,7 @@ struct usb_interface *usb_find_interface
__find_interface);
return argb.interface;
}
+EXPORT_SYMBOL_GPL(usb_find_interface);

/**
* usb_release_dev - free a usb device structure when all users of it are finished.
@@ -369,6 +372,7 @@ struct usb_device *usb_get_dev(struct us
get_device(&dev->dev);
return dev;
}
+EXPORT_SYMBOL_GPL(usb_get_dev);

/**
* usb_put_dev - release a use of the usb device structure
@@ -382,6 +386,7 @@ void usb_put_dev(struct usb_device *dev)
if (dev)
put_device(&dev->dev);
}
+EXPORT_SYMBOL_GPL(usb_put_dev);

/**
* usb_get_intf - increments the reference count of the usb interface structure
@@ -402,6 +407,7 @@ struct usb_interface *usb_get_intf(struc
get_device(&intf->dev);
return intf;
}
+EXPORT_SYMBOL_GPL(usb_get_intf);

/**
* usb_put_intf - release a use of the usb interface structure
@@ -416,7 +422,7 @@ void usb_put_intf(struct usb_interface *
if (intf)
put_device(&intf->dev);
}
-
+EXPORT_SYMBOL_GPL(usb_put_intf);

/* USB device locking
*
@@ -489,7 +495,7 @@ int usb_lock_device_for_reset(struct usb
}
return 1;
}
-
+EXPORT_SYMBOL_GPL(usb_lock_device_for_reset);

static struct usb_device *match_device(struct usb_device *dev,
u16 vendor_id, u16 product_id)
@@ -578,6 +584,7 @@ int usb_get_current_frame_number(struct
{
return usb_hcd_get_frame_number(dev);
}
+EXPORT_SYMBOL_GPL(usb_get_current_frame_number);

/*-------------------------------------------------------------------*/
/*
@@ -612,6 +619,7 @@ int __usb_get_extra_descriptor(char *buf
}
return -1;
}
+EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor);

/**
* usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP
@@ -646,6 +654,7 @@ void *usb_buffer_alloc(
return NULL;
return hcd_buffer_alloc(dev->bus, size, mem_flags, dma);
}
+EXPORT_SYMBOL_GPL(usb_buffer_alloc);

/**
* usb_buffer_free - free memory allocated with usb_buffer_alloc()
@@ -671,6 +680,7 @@ void usb_buffer_free(
return;
hcd_buffer_free(dev->bus, size, addr, dma);
}
+EXPORT_SYMBOL_GPL(usb_buffer_free);

/**
* usb_buffer_map - create DMA mapping(s) for an urb
@@ -718,6 +728,7 @@ struct urb *usb_buffer_map(struct urb *u
| URB_NO_SETUP_DMA_MAP);
return urb;
}
+EXPORT_SYMBOL_GPL(usb_buffer_map);
#endif /* 0 */

/* XXX DISABLED, no users currently. If you wish to re-enable this
@@ -755,6 +766,7 @@ void usb_buffer_dmasync(struct urb *urb)
DMA_TO_DEVICE);
}
}
+EXPORT_SYMBOL_GPL(usb_buffer_dmasync);
#endif

/**
@@ -790,6 +802,7 @@ void usb_buffer_unmap(struct urb *urb)
urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP
| URB_NO_SETUP_DMA_MAP);
}
+EXPORT_SYMBOL_GPL(usb_buffer_unmap);
#endif /* 0 */

/**
@@ -834,6 +847,7 @@ int usb_buffer_map_sg(const struct usb_d
return dma_map_sg(controller, sg, nents,
is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
+EXPORT_SYMBOL_GPL(usb_buffer_map_sg);

/* XXX DISABLED, no users currently. If you wish to re-enable this
* XXX please determine whether the sync is to transfer ownership of
@@ -867,6 +881,7 @@ void usb_buffer_dmasync_sg(const struct
dma_sync_sg(controller, sg, n_hw_ents,
is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
+EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg);
#endif

/**
@@ -893,6 +908,7 @@ void usb_buffer_unmap_sg(const struct us
dma_unmap_sg(controller, sg, n_hw_ents,
is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
}
+EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg);

/* format to disable USB on kernel command line is: nousb */
__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444);
@@ -904,6 +920,7 @@ int usb_disabled(void)
{
return nousb;
}
+EXPORT_SYMBOL_GPL(usb_disabled);

/*
* Init
@@ -985,45 +1002,4 @@ static void __exit usb_exit(void)

subsys_initcall(usb_init);
module_exit(usb_exit);
-
-/*
- * USB may be built into the kernel or be built as modules.
- * These symbols are exported for device (or host controller)
- * driver modules to use.
- */
-
-EXPORT_SYMBOL(usb_disabled);
-
-EXPORT_SYMBOL_GPL(usb_get_intf);
-EXPORT_SYMBOL_GPL(usb_put_intf);
-
-EXPORT_SYMBOL(usb_put_dev);
-EXPORT_SYMBOL(usb_get_dev);
-EXPORT_SYMBOL(usb_hub_tt_clear_buffer);
-
-EXPORT_SYMBOL(usb_lock_device_for_reset);
-
-EXPORT_SYMBOL(usb_find_interface);
-EXPORT_SYMBOL(usb_ifnum_to_if);
-EXPORT_SYMBOL(usb_altnum_to_altsetting);
-
-EXPORT_SYMBOL(__usb_get_extra_descriptor);
-
-EXPORT_SYMBOL(usb_get_current_frame_number);
-
-EXPORT_SYMBOL(usb_buffer_alloc);
-EXPORT_SYMBOL(usb_buffer_free);
-
-#if 0
-EXPORT_SYMBOL(usb_buffer_map);
-EXPORT_SYMBOL(usb_buffer_dmasync);
-EXPORT_SYMBOL(usb_buffer_unmap);
-#endif
-
-EXPORT_SYMBOL(usb_buffer_map_sg);
-#if 0
-EXPORT_SYMBOL(usb_buffer_dmasync_sg);
-#endif
-EXPORT_SYMBOL(usb_buffer_unmap_sg);
-
MODULE_LICENSE("GPL");