Skip to content

Commit

Permalink
fsl_usb2_udc: Fix some sparse warnings and remove redundant code.
Browse files Browse the repository at this point in the history
Fix some sparse "integer used as NULL pointer" warnings.
Remove some unnecessary volatiles and static initialization.
Remove some unused struct members and reorder to improve packing.
Remove a few unneeded includes.

Signed-off-by: Will Newton <will.newton@gmail.com>
Acked-by: Li Yang <leoli@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Will Newton authored and Greg Kroah-Hartman committed Oct 17, 2008
1 parent f6e4411 commit 7483cff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
28 changes: 9 additions & 19 deletions drivers/usb/gadget/fsl_usb2_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
#include <linux/ioport.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
Expand All @@ -44,11 +41,9 @@

#include <asm/byteorder.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
#include <asm/unaligned.h>
#include <asm/dma.h>
#include <asm/cacheflush.h>

#include "fsl_usb2_udc.h"

Expand All @@ -61,8 +56,8 @@
static const char driver_name[] = "fsl-usb2-udc";
static const char driver_desc[] = DRIVER_DESC;

volatile static struct usb_dr_device *dr_regs = NULL;
volatile static struct usb_sys_interface *usb_sys_regs = NULL;
static struct usb_dr_device *dr_regs;
static struct usb_sys_interface *usb_sys_regs;

/* it is initialized in probe() */
static struct fsl_udc *udc_controller = NULL;
Expand Down Expand Up @@ -560,7 +555,7 @@ static int fsl_ep_disable(struct usb_ep *_ep)
/* nuke all pending requests (does flush) */
nuke(ep, -ESHUTDOWN);

ep->desc = 0;
ep->desc = NULL;
ep->stopped = 1;
spin_unlock_irqrestore(&udc->lock, flags);

Expand Down Expand Up @@ -1565,9 +1560,6 @@ static void port_change_irq(struct fsl_udc *udc)
{
u32 speed;

if (udc->bus_reset)
udc->bus_reset = 0;

/* Bus resetting is finished */
if (!(fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET)) {
/* Get the speed */
Expand Down Expand Up @@ -1675,8 +1667,6 @@ static void reset_irq(struct fsl_udc *udc)

if (fsl_readl(&dr_regs->portsc1) & PORTSCX_PORT_RESET) {
VDBG("Bus reset");
/* Bus is reseting */
udc->bus_reset = 1;
/* Reset all the queues, include XD, dTD, EP queue
* head and TR Queue */
reset_queues(udc);
Expand Down Expand Up @@ -1796,7 +1786,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
/* lock is needed but whether should use this lock or another */
spin_lock_irqsave(&udc_controller->lock, flags);

driver->driver.bus = 0;
driver->driver.bus = NULL;
/* hook up the driver */
udc_controller->driver = driver;
udc_controller->gadget.dev.driver = &driver->driver;
Expand All @@ -1806,8 +1796,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
retval = driver->bind(&udc_controller->gadget);
if (retval) {
VDBG("bind to %s --> %d", driver->driver.name, retval);
udc_controller->gadget.dev.driver = 0;
udc_controller->driver = 0;
udc_controller->gadget.dev.driver = NULL;
udc_controller->driver = NULL;
goto out;
}

Expand Down Expand Up @@ -1839,7 +1829,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
return -EINVAL;

if (udc_controller->transceiver)
(void)otg_set_peripheral(udc_controller->transceiver, 0);
otg_set_peripheral(udc_controller->transceiver, NULL);

/* stop DR, disable intr */
dr_controller_stop(udc_controller);
Expand All @@ -1860,8 +1850,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)

/* unbind gadget and unhook driver. */
driver->unbind(&udc_controller->gadget);
udc_controller->gadget.dev.driver = 0;
udc_controller->driver = 0;
udc_controller->gadget.dev.driver = NULL;
udc_controller->driver = NULL;

printk("unregistered gadget driver '%s'\r\n", driver->driver.name);
return 0;
Expand Down
21 changes: 2 additions & 19 deletions drivers/usb/gadget/fsl_usb2_udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,6 @@ struct ep_td_struct {
/* Controller dma boundary */
#define UDC_DMA_BOUNDARY 0x1000

/* -----------------------------------------------------------------------*/
/* ##### enum data
*/
typedef enum {
e_ULPI,
e_UTMI_8BIT,
e_UTMI_16BIT,
e_SERIAL
} e_PhyInterface;

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

/* ### driver private data
Expand Down Expand Up @@ -469,9 +459,9 @@ struct fsl_ep {
#define EP_DIR_OUT 0

struct fsl_udc {

struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct completion *done; /* to make sure release() is done */
struct fsl_ep *eps;
unsigned int max_ep;
unsigned int irq;
Expand All @@ -492,20 +482,13 @@ struct fsl_udc {
size_t ep_qh_size; /* size after alignment adjustment*/
dma_addr_t ep_qh_dma; /* dma address of QH */

u32 max_pipes; /* Device max pipes */
u32 max_use_endpts; /* Max endpointes to be used */
u32 bus_reset; /* Device is bus reseting */
u32 max_pipes; /* Device max pipes */
u32 resume_state; /* USB state to resume */
u32 usb_state; /* USB current state */
u32 usb_next_state; /* USB next state */
u32 ep0_state; /* Endpoint zero state */
u32 ep0_dir; /* Endpoint zero direction: can be
USB_DIR_IN or USB_DIR_OUT */
u32 usb_sof_count; /* SOF count */
u32 errors; /* USB ERRORs count */
u8 device_address; /* Device USB address */

struct completion *done; /* to make sure release() is done */
};

/*-------------------------------------------------------------------------*/
Expand Down

0 comments on commit 7483cff

Please sign in to comment.