o wl3501: use offsetof(struct wl3501_{rx,tx}_hdr, addr4) in more places

parent 42d6581e
...@@ -898,6 +898,7 @@ static int wl3501_unblock_interrupt(struct wl3501_card *this) ...@@ -898,6 +898,7 @@ static int wl3501_unblock_interrupt(struct wl3501_card *this)
*/ */
static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size) static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
{ {
const int offset_addr4 = offsetof(struct wl3501_rx_hdr, addr4);
u16 next_addr, next_addr1; u16 next_addr, next_addr1;
u8 *data = bf + 12; u8 *data = bf + 12;
...@@ -914,10 +915,10 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size) ...@@ -914,10 +915,10 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
WL3501_BLKSZ - WL3501_BLKSZ -
sizeof(struct sizeof(struct
wl3501_rx_hdr)); wl3501_rx_hdr));
size -= size -= WL3501_BLKSZ -
WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr); sizeof(struct wl3501_rx_hdr);
data += data += WL3501_BLKSZ -
WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr); sizeof(struct wl3501_rx_hdr);
} else { } else {
wl3501_get_from_wla(this, this->start_seg + wl3501_get_from_wla(this, this->start_seg +
sizeof(struct sizeof(struct
...@@ -932,36 +933,31 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size) ...@@ -932,36 +933,31 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
data += 2; data += 2;
if (size > if (size >
WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr) + 6) { WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr) + 6) {
wl3501_get_from_wla(this, this->start_seg + wl3501_get_from_wla(this,
sizeof(struct wl3501_rx_hdr) this->start_seg +
- 6, data, offset_addr4, data,
WL3501_BLKSZ - WL3501_BLKSZ -
sizeof(struct wl3501_rx_hdr) sizeof(struct wl3501_rx_hdr)
+ 6); + 6);
size = size -= WL3501_BLKSZ -
size - (WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr) + 6;
sizeof(struct wl3501_rx_hdr)) + 6; data += WL3501_BLKSZ -
data +=
WL3501_BLKSZ -
sizeof(struct wl3501_rx_hdr) + 6; sizeof(struct wl3501_rx_hdr) + 6;
} else { } else {
wl3501_get_from_wla(this, wl3501_get_from_wla(this,
this->start_seg + this->start_seg +
sizeof(struct wl3501_rx_hdr) offset_addr4,
- 6, data, size); data, size);
size = 0; size = 0;
} }
} }
} else { } else {
if (size > WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr) - 6) { if (size > WL3501_BLKSZ - offset_addr4) {
wl3501_get_from_wla(this, this->start_seg + wl3501_get_from_wla(this, this->start_seg +
sizeof(struct wl3501_rx_hdr) + 6, sizeof(struct wl3501_rx_hdr) + 6,
data, WL3501_BLKSZ - data, WL3501_BLKSZ - offset_addr4);
sizeof(struct wl3501_rx_hdr) - 6); size -= WL3501_BLKSZ - offset_addr4;
size = size - (WL3501_BLKSZ - data += WL3501_BLKSZ - offset_addr4;
sizeof(struct wl3501_rx_hdr)) - 6;
data +=
(WL3501_BLKSZ - sizeof(struct wl3501_rx_hdr) - 6);
} else { } else {
wl3501_get_from_wla(this, this->start_seg + wl3501_get_from_wla(this, this->start_seg +
sizeof(struct wl3501_rx_hdr) + 6, sizeof(struct wl3501_rx_hdr) + 6,
...@@ -973,8 +969,8 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size) ...@@ -973,8 +969,8 @@ static u16 wl3501_receive(struct wl3501_card *this, u8 *bf, u16 size)
if (size > WL3501_BLKSZ - 5) { if (size > WL3501_BLKSZ - 5) {
wl3501_get_from_wla(this, next_addr + 5, data, wl3501_get_from_wla(this, next_addr + 5, data,
WL3501_BLKSZ - 5); WL3501_BLKSZ - 5);
size -= (WL3501_BLKSZ - 5); size -= WL3501_BLKSZ - 5;
data += (WL3501_BLKSZ - 5); data += WL3501_BLKSZ - 5;
wl3501_get_from_wla(this, next_addr + 2, &next_addr1, wl3501_get_from_wla(this, next_addr + 2, &next_addr1,
sizeof(next_addr1)); sizeof(next_addr1));
next_addr = next_addr1; next_addr = next_addr1;
...@@ -2292,6 +2288,9 @@ static void wl3501_config(dev_link_t *link) ...@@ -2292,6 +2288,9 @@ static void wl3501_config(dev_link_t *link)
this->essid[2] = 'A'; this->essid[2] = 'A';
this->essid[3] = 'N'; this->essid[3] = 'N';
this->essid[4] = 'Y'; this->essid[4] = 'Y';
this->card_name[0] = '\0';
this->firmware_date[0] = '\0';
this->rssi = 255;
strlcpy(this->nick, "Planet WL3501", sizeof(this->nick)); strlcpy(this->nick, "Planet WL3501", sizeof(this->nick));
spin_lock_init(&this->lock); spin_lock_init(&this->lock);
......
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