[adm5120] minor usb driver cleanup

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8385 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
Gabor Juhos 2007-08-10 08:56:41 +00:00
parent be3229bd33
commit a1d8980189
1 changed files with 138 additions and 137 deletions

View File

@ -89,7 +89,6 @@ MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)");
#define ADMHCD_REG_PORTSTATUS1 0x7c #define ADMHCD_REG_PORTSTATUS1 0x7c
#define ADMHCD_REG_HOSTHEAD 0x80 #define ADMHCD_REG_HOSTHEAD 0x80
#define ADMHCD_NUMPORTS 2 #define ADMHCD_NUMPORTS 2
struct admhcd_ed { struct admhcd_ed {
@ -218,12 +217,12 @@ static struct admhcd_td *admhcd_td_alloc(struct admhcd_ed *ed, struct urb *urb)
{ {
struct admhcd_td *tdn, *td; struct admhcd_td *tdn, *td;
tdn = kmalloc(sizeof(struct admhcd_td), GFP_ATOMIC); tdn = kzalloc(sizeof(*tdn), GFP_ATOMIC);
if (!tdn) if (!tdn)
return NULL; return NULL;
tdn->real = tdn; tdn->real = tdn;
tdn = (struct admhcd_td *)KSEG1ADDR(tdn); tdn = (struct admhcd_td *)KSEG1ADDR(tdn);
memset(tdn, 0, sizeof(struct admhcd_td));
if (ed->cur == NULL) { if (ed->cur == NULL) {
ed->cur = tdn; ed->cur = tdn;
ed->head = tdn; ed->head = tdn;
@ -284,10 +283,9 @@ static struct admhcd_ed *admhcd_get_ed(struct admhcd *ahcd,
} }
} }
if (!found) { if (!found) {
found = kmalloc(sizeof(struct admhcd_ed), GFP_ATOMIC); found = kzalloc(sizeof(*found), GFP_ATOMIC);
if (!found) if (!found)
goto out; goto out;
memset(found, 0, sizeof(struct admhcd_ed));
found->real = found; found->real = found;
found->ep = ep; found->ep = ep;
found = (struct admhcd_ed *)KSEG1ADDR(found); found = (struct admhcd_ed *)KSEG1ADDR(found);
@ -342,7 +340,7 @@ static void admhcd_ed_start(struct admhcd *ahcd, struct admhcd_ed *ed)
ahcd->dma_en |= ADMHCD_DMA_EN; ahcd->dma_en |= ADMHCD_DMA_EN;
} }
static irqreturn_t adm5120hcd_irq(struct usb_hcd *hcd) static irqreturn_t admhcd_irq(struct usb_hcd *hcd)
{ {
struct admhcd *ahcd = hcd_to_admhcd(hcd); struct admhcd *ahcd = hcd_to_admhcd(hcd);
u32 intstatus; u32 intstatus;
@ -350,12 +348,14 @@ static irqreturn_t adm5120hcd_irq(struct usb_hcd *hcd)
intstatus = admhcd_reg_get(ahcd, ADMHCD_REG_INTSTATUS); intstatus = admhcd_reg_get(ahcd, ADMHCD_REG_INTSTATUS);
if (intstatus & ADMHCD_INT_FATAL) { if (intstatus & ADMHCD_INT_FATAL) {
admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, ADMHCD_INT_FATAL); admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, ADMHCD_INT_FATAL);
// /* FIXME: handle fatal interrupts */
} }
if (intstatus & ADMHCD_INT_SW) { if (intstatus & ADMHCD_INT_SW) {
admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, ADMHCD_INT_SW); admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, ADMHCD_INT_SW);
// /* FIXME: handle software interrupts */
} }
if (intstatus & ADMHCD_INT_TD) { if (intstatus & ADMHCD_INT_TD) {
struct admhcd_ed *ed, *head; struct admhcd_ed *ed, *head;
@ -551,6 +551,7 @@ static void admhcd_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoin
} }
for (edt = head; edt->next != ed; edt = edt->next); for (edt = head; edt->next != ed; edt = edt->next);
edt->next = ed->next; edt->next = ed->next;
out_free: out_free:
kfree(ed->real); kfree(ed->real);
out: out:
@ -729,10 +730,10 @@ static int admhcd_start(struct usb_hcd *hcd)
admhcd_reg_set(ahcd, ADMHCD_REG_LSTHRESH, 0x628); admhcd_reg_set(ahcd, ADMHCD_REG_LSTHRESH, 0x628);
/* Set interrupts */ /* Set interrupts */
admhcd_reg_set(ahcd, ADMHCD_REG_INTENABLE, admhcd_reg_set(ahcd, ADMHCD_REG_INTENABLE, ADMHCD_INT_ACT |
ADMHCD_INT_ACT | ADMHCD_INT_FATAL | ADMHCD_INT_SW | ADMHCD_INT_TD); ADMHCD_INT_FATAL | ADMHCD_INT_SW | ADMHCD_INT_TD);
admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, admhcd_reg_set(ahcd, ADMHCD_REG_INTSTATUS, ADMHCD_INT_ACT |
ADMHCD_INT_ACT | ADMHCD_INT_FATAL | ADMHCD_INT_SW | ADMHCD_INT_TD); ADMHCD_INT_FATAL | ADMHCD_INT_SW | ADMHCD_INT_TD);
/* Power on all ports */ /* Power on all ports */
admhcd_reg_set(ahcd, ADMHCD_REG_RHDESCR, ADMHCD_NPS | ADMHCD_LPSC); admhcd_reg_set(ahcd, ADMHCD_REG_RHDESCR, ADMHCD_NPS | ADMHCD_LPSC);
@ -830,7 +831,7 @@ static struct hc_driver adm5120_hc_driver = {
.description = hcd_name, .description = hcd_name,
.product_desc = "ADM5120 HCD", .product_desc = "ADM5120 HCD",
.hcd_priv_size = sizeof(struct admhcd), .hcd_priv_size = sizeof(struct admhcd),
.irq = adm5120hcd_irq, .irq = admhcd_irq,
.flags = HCD_USB11, .flags = HCD_USB11,
.urb_enqueue = admhcd_urb_enqueue, .urb_enqueue = admhcd_urb_enqueue,
.urb_dequeue = admhcd_urb_dequeue, .urb_dequeue = admhcd_urb_dequeue,