Commit 104f1bec authored by Duncan Sands's avatar Duncan Sands Committed by Greg Kroah-Hartman

[PATCH] USB speedtouch: trivial cleanups

parent b22a7066
...@@ -148,19 +148,16 @@ struct udsl_control { ...@@ -148,19 +148,16 @@ struct udsl_control {
#define UDSL_SKB(x) ((struct udsl_control *)(x)->cb) #define UDSL_SKB(x) ((struct udsl_control *)(x)->cb)
struct atmsar_vcc_data { struct udsl_vcc_data {
struct atmsar_vcc_data *next; /* vpi/vci lookup */
struct udsl_vcc_data *next;
/* connection specific non-atmsar data */ unsigned int vpi;
struct atm_vcc *vcc; unsigned int vci;
unsigned short mtu; /* max is actually 65k for AAL5... */
/* cell data */
unsigned int vp;
unsigned int vc;
unsigned long atmHeader; unsigned long atmHeader;
struct atm_vcc *vcc;
/* raw cell reassembly */ /* raw cell reassembly */
unsigned short mtu;
struct sk_buff *reasBuffer; struct sk_buff *reasBuffer;
}; };
...@@ -178,7 +175,7 @@ struct udsl_instance_data { ...@@ -178,7 +175,7 @@ struct udsl_instance_data {
/* atm device part */ /* atm device part */
struct atm_dev *atm_dev; struct atm_dev *atm_dev;
struct atmsar_vcc_data *atmsar_vcc_list; struct udsl_vcc_data *vcc_list;
/* receiving */ /* receiving */
struct udsl_receiver all_receivers [UDSL_NUMBER_RCV_URBS]; struct udsl_receiver all_receivers [UDSL_NUMBER_RCV_URBS];
...@@ -252,24 +249,23 @@ static struct usb_driver udsl_usb_driver = { ...@@ -252,24 +249,23 @@ static struct usb_driver udsl_usb_driver = {
#define ATM_HDR_VPVC_MASK (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK) #define ATM_HDR_VPVC_MASK (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)
struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_buff *skb, static struct sk_buff *udsl_decode_rawcell (struct udsl_vcc_data *list, struct sk_buff *skb, struct udsl_vcc_data **ctx)
struct atmsar_vcc_data **ctx)
{ {
if (!list || !skb || !ctx)
return NULL;
if (!skb->data || !skb->tail)
return NULL;
while (skb->len) { while (skb->len) {
unsigned char *cell = skb->data; unsigned char *cell = skb->data;
unsigned char *cell_payload; unsigned char *cell_payload;
struct atmsar_vcc_data *vcc = list; struct udsl_vcc_data *vcc = list;
unsigned long atmHeader = unsigned long atmHeader =
((unsigned long) (cell[0]) << 24) | ((unsigned long) (cell[1]) << 16) | ((unsigned long) (cell[0]) << 24) | ((unsigned long) (cell[1]) << 16) |
((unsigned long) (cell[2]) << 8) | (cell[3] & 0xff); ((unsigned long) (cell[2]) << 8) | (cell[3] & 0xff);
dbg ("atmsar_decode_rawcell (0x%p, 0x%p, 0x%p) called", list, skb, ctx); dbg ("udsl_decode_rawcell (0x%p, 0x%p, 0x%p) called", list, skb, ctx);
dbg ("atmsar_decode_rawcell skb->data %p, skb->tail %p", skb->data, skb->tail); dbg ("udsl_decode_rawcell skb->data %p, skb->tail %p", skb->data, skb->tail);
if (!list || !skb || !ctx)
return NULL;
if (!skb->data || !skb->tail)
return NULL;
/* here should the header CRC check be... */ /* here should the header CRC check be... */
...@@ -279,7 +275,7 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b ...@@ -279,7 +275,7 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b
&& ((vcc->atmHeader & ATM_HDR_VPVC_MASK) != (atmHeader & ATM_HDR_VPVC_MASK)); && ((vcc->atmHeader & ATM_HDR_VPVC_MASK) != (atmHeader & ATM_HDR_VPVC_MASK));
vcc = vcc->next); vcc = vcc->next);
dbg ("atmsar_decode_rawcell found vcc %p for packet on vp %d, vc %d", vcc, dbg ("udsl_decode_rawcell found vcc %p for packet on vpi %d, vci %d", vcc,
(int) ((atmHeader & ATM_HDR_VPI_MASK) >> ATM_HDR_VPI_SHIFT), (int) ((atmHeader & ATM_HDR_VPI_MASK) >> ATM_HDR_VPI_SHIFT),
(int) ((atmHeader & ATM_HDR_VCI_MASK) >> ATM_HDR_VCI_SHIFT)); (int) ((atmHeader & ATM_HDR_VCI_MASK) >> ATM_HDR_VCI_SHIFT));
...@@ -313,9 +309,7 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b ...@@ -313,9 +309,7 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b
tmp = vcc->reasBuffer; tmp = vcc->reasBuffer;
vcc->reasBuffer = NULL; vcc->reasBuffer = NULL;
dbg dbg ("udsl_decode_rawcell returns ATM_AAL5 pdu 0x%p with length %d", tmp, tmp->len);
("atmsar_decode_rawcell returns ATM_AAL5 pdu 0x%p with length %d",
tmp, tmp->len);
return tmp; return tmp;
} }
} }
...@@ -331,14 +325,14 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b ...@@ -331,14 +325,14 @@ struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_b
} }
return NULL; return NULL;
}; }
struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff *skb) static struct sk_buff *udsl_decode_aal5 (struct udsl_vcc_data *ctx, struct sk_buff *skb)
{ {
uint crc = 0xffffffff; uint crc = 0xffffffff;
uint length, pdu_crc, pdu_length; uint length, pdu_crc, pdu_length;
dbg ("atmsar_decode_aal5 (0x%p, 0x%p) called", ctx, skb); dbg ("udsl_decode_aal5 (0x%p, 0x%p) called", ctx, skb);
if (skb->len && (skb->len % 48)) if (skb->len && (skb->len % 48))
return NULL; return NULL;
...@@ -348,7 +342,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff ...@@ -348,7 +342,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff
(skb->tail[-4] << 24) + (skb->tail[-3] << 16) + (skb->tail[-2] << 8) + skb->tail[-1]; (skb->tail[-4] << 24) + (skb->tail[-3] << 16) + (skb->tail[-2] << 8) + skb->tail[-1];
pdu_length = ((length + 47 + 8) / 48) * 48; pdu_length = ((length + 47 + 8) / 48) * 48;
dbg ("atmsar_decode_aal5: skb->len = %d, length = %d, pdu_crc = 0x%x, pdu_length = %d", dbg ("udsl_decode_aal5: skb->len = %d, length = %d, pdu_crc = 0x%x, pdu_length = %d",
skb->len, length, pdu_crc, pdu_length); skb->len, length, pdu_crc, pdu_length);
/* is skb long enough ? */ /* is skb long enough ? */
...@@ -360,7 +354,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff ...@@ -360,7 +354,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff
/* is skb too long ? */ /* is skb too long ? */
if (skb->len > pdu_length) { if (skb->len > pdu_length) {
dbg ("atmsar_decode_aal5: Warning: readjusting illeagl size %d -> %d", dbg ("udsl_decode_aal5: Warning: readjusting illegal size %d -> %d",
skb->len, pdu_length); skb->len, pdu_length);
/* buffer is too long. we can try to recover /* buffer is too long. we can try to recover
* if we discard the first part of the skb. * if we discard the first part of the skb.
...@@ -373,7 +367,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff ...@@ -373,7 +367,7 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff
/* check crc */ /* check crc */
if (pdu_crc != crc) { if (pdu_crc != crc) {
dbg ("atmsar_decode_aal5: crc check failed!"); dbg ("udsl_decode_aal5: crc check failed!");
if (ctx->vcc->stats) if (ctx->vcc->stats)
atomic_inc (&ctx->vcc->stats->rx_err); atomic_inc (&ctx->vcc->stats->rx_err);
return NULL; return NULL;
...@@ -386,16 +380,17 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff ...@@ -386,16 +380,17 @@ struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff
if (ctx->vcc->stats) if (ctx->vcc->stats)
atomic_inc (&ctx->vcc->stats->rx); atomic_inc (&ctx->vcc->stats->rx);
dbg ("atmsar_decode_aal5 returns pdu 0x%p with length %d", skb, skb->len); dbg ("udsl_decode_aal5 returns pdu 0x%p with length %d", skb, skb->len);
return skb; return skb;
}; }
/************* /*************
** encode ** ** encode **
*************/ *************/
static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb) { static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb)
{
struct udsl_control *ctrl = UDSL_SKB (skb); struct udsl_control *ctrl = UDSL_SKB (skb);
unsigned int i, zero_padding; unsigned int i, zero_padding;
unsigned char zero = 0; unsigned char zero = 0;
...@@ -435,7 +430,8 @@ static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb) { ...@@ -435,7 +430,8 @@ static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb) {
ctrl->aal5_trailer [7] = crc; ctrl->aal5_trailer [7] = crc;
} }
unsigned int udsl_write_cells (unsigned int howmany, struct sk_buff *skb, unsigned char **target_p) { static unsigned int udsl_write_cells (unsigned int howmany, struct sk_buff *skb, unsigned char **target_p)
{
struct udsl_control *ctrl = UDSL_SKB (skb); struct udsl_control *ctrl = UDSL_SKB (skb);
unsigned char *target = *target_p; unsigned char *target = *target_p;
unsigned int nc, ne, i; unsigned int nc, ne, i;
...@@ -524,7 +520,7 @@ static void udsl_process_receive (unsigned long data) ...@@ -524,7 +520,7 @@ static void udsl_process_receive (unsigned long data)
unsigned char *data_start; unsigned char *data_start;
struct sk_buff *skb; struct sk_buff *skb;
struct urb *urb; struct urb *urb;
struct atmsar_vcc_data *atmsar_vcc = NULL; struct udsl_vcc_data *atmsar_vcc = NULL;
struct sk_buff *new = NULL, *tmp = NULL; struct sk_buff *new = NULL, *tmp = NULL;
int err; int err;
...@@ -552,13 +548,11 @@ static void udsl_process_receive (unsigned long data) ...@@ -552,13 +548,11 @@ static void udsl_process_receive (unsigned long data)
dbg ("skb->len = %d", skb->len); dbg ("skb->len = %d", skb->len);
PACKETDEBUG (skb->data, skb->len); PACKETDEBUG (skb->data, skb->len);
while ((new = while ((new = udsl_decode_rawcell (instance->vcc_list, skb, &atmsar_vcc))) {
atmsar_decode_rawcell (instance->atmsar_vcc_list, skb,
&atmsar_vcc)) != NULL) {
dbg ("(after cell processing)skb->len = %d", new->len); dbg ("(after cell processing)skb->len = %d", new->len);
tmp = new; tmp = new;
new = atmsar_decode_aal5 (atmsar_vcc, new); new = udsl_decode_aal5 (atmsar_vcc, new);
/* we can't send NULL skbs upstream, the ATM layer would try to close the vcc... */ /* we can't send NULL skbs upstream, the ATM layer would try to close the vcc... */
if (new) { if (new) {
...@@ -574,7 +568,7 @@ static void udsl_process_receive (unsigned long data) ...@@ -574,7 +568,7 @@ static void udsl_process_receive (unsigned long data)
dev_kfree_skb (new); dev_kfree_skb (new);
} }
} else { } else {
dbg ("atmsar_decode_aal5 returned NULL!"); dbg ("udsl_decode_aal5 returned NULL!");
dev_kfree_skb (tmp); dev_kfree_skb (tmp);
} }
} }
...@@ -917,12 +911,10 @@ static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page) ...@@ -917,12 +911,10 @@ static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page)
return 0; return 0;
} }
#define ATMSAR_SET_PTI 0x2L
static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
{ {
struct udsl_instance_data *instance = vcc->dev->dev_data; struct udsl_instance_data *instance = vcc->dev->dev_data;
struct atmsar_vcc_data *new; struct udsl_vcc_data *new;
dbg ("udsl_atm_open called"); dbg ("udsl_atm_open called");
...@@ -931,19 +923,19 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) ...@@ -931,19 +923,19 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
return -ENODEV; return -ENODEV;
} }
/* at the moment only AAL5 support */ /* only support AAL5 */
if (vcc->qos.aal != ATM_AAL5) if (vcc->qos.aal != ATM_AAL5)
return -EINVAL; return -EINVAL;
if (!(new = kmalloc (sizeof (struct atmsar_vcc_data), GFP_KERNEL))) if (!(new = kmalloc (sizeof (struct udsl_vcc_data), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
memset (new, 0, sizeof (struct atmsar_vcc_data)); memset (new, 0, sizeof (struct udsl_vcc_data));
new->vcc = vcc; new->vcc = vcc;
new->vp = vpi; new->vpi = vpi;
new->vc = vci; new->vci = vci;
new->mtu = UDSL_MAX_AAL5_MRU; new->mtu = UDSL_MAX_AAL5_MRU;
...@@ -951,10 +943,10 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) ...@@ -951,10 +943,10 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
((unsigned long) vci << ATM_HDR_VCI_SHIFT); ((unsigned long) vci << ATM_HDR_VCI_SHIFT);
new->reasBuffer = NULL; new->reasBuffer = NULL;
new->next = instance->atmsar_vcc_list; new->next = instance->vcc_list;
instance->atmsar_vcc_list = new; instance->vcc_list = new;
dbg ("Allocated new SARLib vcc 0x%p with vp %d vc %d", new, vpi, vci); dbg ("Allocated new SARLib vcc 0x%p with vpi %d vci %d", new, vpi, vci);
vcc->dev_data = new; vcc->dev_data = new;
...@@ -974,7 +966,7 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) ...@@ -974,7 +966,7 @@ static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci)
static void udsl_atm_close (struct atm_vcc *vcc) static void udsl_atm_close (struct atm_vcc *vcc)
{ {
struct udsl_instance_data *instance = vcc->dev->dev_data; struct udsl_instance_data *instance = vcc->dev->dev_data;
struct atmsar_vcc_data *work; struct udsl_vcc_data *work;
dbg ("udsl_atm_close called"); dbg ("udsl_atm_close called");
...@@ -987,10 +979,10 @@ static void udsl_atm_close (struct atm_vcc *vcc) ...@@ -987,10 +979,10 @@ static void udsl_atm_close (struct atm_vcc *vcc)
/* cancel all sends on this vcc */ /* cancel all sends on this vcc */
udsl_cancel_send (instance, vcc); udsl_cancel_send (instance, vcc);
if (instance->atmsar_vcc_list == vcc->dev_data) { if (instance->vcc_list == vcc->dev_data) {
instance->atmsar_vcc_list = instance->atmsar_vcc_list->next; instance->vcc_list = instance->vcc_list->next;
} else { } else {
for (work = instance->atmsar_vcc_list; work && work->next && (work->next != vcc->dev_data); work = work->next); for (work = instance->vcc_list; work && work->next && (work->next != vcc->dev_data); work = work->next);
/* return if not found */ /* return if not found */
if (work->next != vcc->dev_data) if (work->next != vcc->dev_data)
...@@ -999,11 +991,11 @@ static void udsl_atm_close (struct atm_vcc *vcc) ...@@ -999,11 +991,11 @@ static void udsl_atm_close (struct atm_vcc *vcc)
work->next = work->next->next; work->next = work->next->next;
} }
if (((struct atmsar_vcc_data *)vcc->dev_data)->reasBuffer) { if (((struct udsl_vcc_data *)vcc->dev_data)->reasBuffer) {
dev_kfree_skb (((struct atmsar_vcc_data *)vcc->dev_data)->reasBuffer); dev_kfree_skb (((struct udsl_vcc_data *)vcc->dev_data)->reasBuffer);
} }
dbg ("Deallocated SARLib vcc 0x%p with vp %d vc %d", vcc->dev_data, vcc->dev_data->vp, vcc->dev_data->vc); dbg ("Deallocated SARLib vcc 0x%p with vpi %d vci %d", vcc->dev_data, vcc->dev_data->vpi, vcc->dev_data->vci);
kfree (vcc->dev_data); kfree (vcc->dev_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment