1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-08 13:28:05 +00:00

Style change.

- Make it easier to port the USB code to other platforms by only using
one set of memory functions for clearing and copying memory. None of
the memory copies are overlapping. This means using bcopy() is not
required.
- Fix a compile warning when USB_HAVE_BUSDMA=0
- Add missing semicolon in avr32dci.
- Update some comments.

MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2011-11-12 08:16:45 +00:00
parent 0f1aca6519
commit 271ae033e9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227461
27 changed files with 106 additions and 99 deletions

View File

@ -2123,7 +2123,7 @@ at91dci_roothub_exec(struct usb_device *udev,
if (sc->sc_flags.status_vbus &&
sc->sc_flags.status_bus_reset) {
/* reset endpoint flags */
bzero(sc->sc_ep_flags, sizeof(sc->sc_ep_flags));
memset(sc->sc_ep_flags, 0, sizeof(sc->sc_ep_flags));
}
}
if (sc->sc_flags.change_suspend) {

View File

@ -415,12 +415,11 @@ avr32dci_data_rx(struct avr32dci_td *td)
buf_res.length = count;
}
/* receive data */
bcopy(sc->physdata +
memcpy(buf_res.buffer, sc->physdata +
(AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) +
(td->ep_no << 16) + (td->offset % td->max_packet_size),
buf_res.buffer, buf_res.length)
(td->ep_no << 16) + (td->offset % td->max_packet_size), buf_res.length);
/* update counters */
count -= buf_res.length;
count -= buf_res.length;
td->offset += buf_res.length;
td->remainder -= buf_res.length;
}
@ -491,12 +490,12 @@ avr32dci_data_tx(struct avr32dci_td *td)
buf_res.length = count;
}
/* transmit data */
bcopy(buf_res.buffer, sc->physdata +
memcpy(sc->physdata +
(AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) +
(td->ep_no << 16) + (td->offset % td->max_packet_size),
buf_res.length)
buf_res.buffer, buf_res.length);
/* update counters */
count -= buf_res.length;
count -= buf_res.length;
td->offset += buf_res.length;
td->remainder -= buf_res.length;
}

View File

@ -3369,7 +3369,7 @@ ehci_roothub_exec(struct usb_device *udev,
break;
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
len = 16;
bzero(sc->sc_hub_desc.temp, 16);
memset(sc->sc_hub_desc.temp, 0, 16);
break;
case C(UR_GET_STATUS, UT_READ_CLASS_OTHER):
DPRINTFN(9, "get port status i=%d\n",

View File

@ -2347,7 +2347,7 @@ ohci_roothub_exec(struct usb_device *udev,
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
len = 16;
bzero(sc->sc_hub_desc.temp, 16);
memset(sc->sc_hub_desc.temp, 0, 16);
break;
case C(UR_GET_STATUS, UT_READ_CLASS_OTHER):
DPRINTFN(9, "get port status i=%d\n",

View File

@ -2702,7 +2702,7 @@ uhci_roothub_exec(struct usb_device *udev,
break;
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
len = 16;
bzero(sc->sc_hub_desc.temp, 16);
memset(sc->sc_hub_desc.temp, 0, 16);
break;
case C(UR_GET_STATUS, UT_READ_CLASS_OTHER):
if (index == 1)

View File

@ -380,8 +380,9 @@ kue_setmulti(struct usb_ether *ue)
*/
if (i == KUE_MCFILTCNT(sc))
break;
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
KUE_MCFILT(sc, i), ETHER_ADDR_LEN);
memcpy(KUE_MCFILT(sc, i),
LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
ETHER_ADDR_LEN);
i++;
}
if_maddr_runlock(ifp);

View File

@ -1153,7 +1153,7 @@ uhso_mux_read_callback(struct usb_xfer *xfer, usb_error_t error)
/* FALLTHROUGH */
case USB_ST_SETUP:
tr_setup:
bzero(&req, sizeof(struct usb_device_request));
memset(&req, 0, sizeof(struct usb_device_request));
req.bmRequestType = UT_READ_CLASS_INTERFACE;
req.bRequest = UCDC_GET_ENCAPSULATED_RESPONSE;
USETW(req.wValue, 0);
@ -1206,7 +1206,7 @@ uhso_mux_write_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_get_page(pc, 0, &res);
bzero(&req, sizeof(struct usb_device_request));
memset(&req, 0, sizeof(struct usb_device_request));
req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UCDC_SEND_ENCAPSULATED_COMMAND;
USETW(req.wValue, 0);
@ -1731,7 +1731,7 @@ uhso_if_rxflush(void *arg)
* copy the IP-packet into it.
*/
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
bcopy(mtod(m0, uint8_t *), mtod(m, uint8_t *), iplen);
memcpy(mtod(m, uint8_t *), mtod(m0, uint8_t *), iplen);
m->m_pkthdr.len = m->m_len = iplen;
/* Adjust the size of the original mbuf */

View File

@ -438,7 +438,7 @@ ufoma_attach(device_t dev)
goto detach;
}
sc->sc_modetable[0] = (elements + 1);
bcopy(mad->bMode, &sc->sc_modetable[1], elements);
memcpy(&sc->sc_modetable[1], mad->bMode, elements);
sc->sc_currentmode = UMCPC_ACM_MODE_UNLINKED;
sc->sc_modetoactivate = mad->bMode[0];
@ -968,7 +968,7 @@ ufoma_cfg_param(struct ucom_softc *ucom, struct termios *t)
}
DPRINTF("\n");
bzero(&ls, sizeof(ls));
memset(&ls, 0, sizeof(ls));
USETDW(ls.dwDTERate, t->c_ospeed);

View File

@ -560,7 +560,7 @@ static int
uftdi_set_parm_soft(struct termios *t,
struct uftdi_param_config *cfg, uint8_t type)
{
bzero(cfg, sizeof(*cfg));
memset(cfg, 0, sizeof(*cfg));
switch (type) {
case UFTDI_TYPE_SIO:

View File

@ -540,7 +540,7 @@ umodem_cfg_param(struct ucom_softc *ucom, struct termios *t)
DPRINTF("sc=%p\n", sc);
bzero(&ls, sizeof(ls));
memset(&ls, 0, sizeof(ls));
USETDW(ls.dwDTERate, t->c_ospeed);

View File

@ -659,7 +659,7 @@ uplcom_cfg_param(struct ucom_softc *ucom, struct termios *t)
DPRINTF("sc = %p\n", sc);
bzero(&ls, sizeof(ls));
memset(&ls, 0, sizeof(ls));
USETDW(ls.dwDTERate, t->c_ospeed);

View File

@ -311,8 +311,9 @@ uvisor_attach(device_t dev)
int error;
DPRINTF("sc=%p\n", sc);
bcopy(uvisor_config, uvisor_config_copy,
memcpy(uvisor_config_copy, uvisor_config,
sizeof(uvisor_config_copy));
device_set_usb_desc(dev);
mtx_init(&sc->sc_mtx, "uvisor", NULL, MTX_DEF);

View File

@ -891,7 +891,7 @@ umass_attach(device_t dev)
int32_t err;
/*
* NOTE: the softc struct is bzero-ed in device_set_driver.
* NOTE: the softc struct is cleared in device_set_driver.
* We can safely call umass_detach without specifically
* initializing the struct.
*/
@ -1305,11 +1305,13 @@ umass_t_bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
}
sc->cbw.bCDBLength = sc->sc_transfer.cmd_len;
bcopy(sc->sc_transfer.cmd_data, sc->cbw.CBWCDB,
memcpy(sc->cbw.CBWCDB, sc->sc_transfer.cmd_data,
sc->sc_transfer.cmd_len);
bzero(sc->sc_transfer.cmd_data + sc->sc_transfer.cmd_len,
sizeof(sc->cbw.CBWCDB) - sc->sc_transfer.cmd_len);
memset(sc->sc_transfer.cmd_data +
sc->sc_transfer.cmd_len, 0,
sizeof(sc->cbw.CBWCDB) -
sc->sc_transfer.cmd_len);
DIF(UDMASS_BBB, umass_bbb_dump_cbw(sc, &sc->cbw));
@ -1480,9 +1482,9 @@ umass_t_bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
/* Zero missing parts of the CSW: */
if (actlen < sizeof(sc->csw)) {
bzero(&sc->csw, sizeof(sc->csw));
}
if (actlen < sizeof(sc->csw))
memset(&sc->csw, 0, sizeof(sc->csw));
pc = usbd_xfer_get_frame(xfer, 0);
usbd_copy_out(pc, 0, &sc->csw, actlen);
@ -2755,7 +2757,7 @@ umass_scsi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
if (sc->sc_quirks & NO_TEST_UNIT_READY) {
DPRINTF(sc, UDMASS_SCSI, "Converted TEST_UNIT_READY "
"to START_UNIT\n");
bzero(sc->sc_transfer.cmd_data, cmd_len);
memset(sc->sc_transfer.cmd_data, 0, cmd_len);
sc->sc_transfer.cmd_data[0] = START_STOP_UNIT;
sc->sc_transfer.cmd_data[4] = SSS_START;
return (1);
@ -2768,14 +2770,14 @@ umass_scsi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
* information.
*/
if (sc->sc_quirks & FORCE_SHORT_INQUIRY) {
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
sc->sc_transfer.cmd_data[4] = SHORT_INQUIRY_LENGTH;
return (1);
}
break;
}
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
return (1);
}
@ -2810,10 +2812,11 @@ umass_rbc_transform(struct umass_softc *sc, uint8_t *cmd_ptr, uint8_t cmd_len)
case REQUEST_SENSE:
case PREVENT_ALLOW:
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
if ((sc->sc_quirks & RBC_PAD_TO_12) && (cmd_len < 12)) {
bzero(sc->sc_transfer.cmd_data + cmd_len, 12 - cmd_len);
memset(sc->sc_transfer.cmd_data + cmd_len,
0, 12 - cmd_len);
cmd_len = 12;
}
sc->sc_transfer.cmd_len = cmd_len;
@ -2841,7 +2844,7 @@ umass_ufi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
sc->sc_transfer.cmd_len = UFI_COMMAND_LENGTH;
/* Zero the command data */
bzero(sc->sc_transfer.cmd_data, UFI_COMMAND_LENGTH);
memset(sc->sc_transfer.cmd_data, 0, UFI_COMMAND_LENGTH);
switch (cmd_ptr[0]) {
/*
@ -2898,7 +2901,7 @@ umass_ufi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
return (0); /* failure */
}
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
return (1); /* success */
}
@ -2919,7 +2922,7 @@ umass_atapi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
sc->sc_transfer.cmd_len = ATAPI_COMMAND_LENGTH;
/* Zero the command data */
bzero(sc->sc_transfer.cmd_data, ATAPI_COMMAND_LENGTH);
memset(sc->sc_transfer.cmd_data, 0, ATAPI_COMMAND_LENGTH);
switch (cmd_ptr[0]) {
/*
@ -2933,7 +2936,7 @@ umass_atapi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
* information.
*/
if (sc->sc_quirks & FORCE_SHORT_INQUIRY) {
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
sc->sc_transfer.cmd_data[4] = SHORT_INQUIRY_LENGTH;
return (1);
@ -2994,7 +2997,7 @@ umass_atapi_transform(struct umass_softc *sc, uint8_t *cmd_ptr,
break;
}
bcopy(cmd_ptr, sc->sc_transfer.cmd_data, cmd_len);
memcpy(sc->sc_transfer.cmd_data, cmd_ptr, cmd_len);
return (1); /* success */
}

View File

@ -440,7 +440,7 @@ urio_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
error = EPERM;
goto done;
}
bzero(&ur, sizeof(ur));
memset(&ur, 0, sizeof(ur));
rio_cmd = addr;
ur.ucr_request.bmRequestType =
rio_cmd->requesttype | UT_READ_VENDOR_DEVICE;
@ -451,7 +451,7 @@ urio_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
error = EPERM;
goto done;
}
bzero(&ur, sizeof(ur));
memset(&ur, 0, sizeof(ur));
rio_cmd = addr;
ur.ucr_request.bmRequestType =
rio_cmd->requesttype | UT_WRITE_VENDOR_DEVICE;

View File

@ -355,7 +355,7 @@ ustorage_fs_attach(device_t dev)
int unit;
/*
* NOTE: the softc struct is bzero-ed in device_set_driver.
* NOTE: the softc struct is cleared in device_set_driver.
* We can safely call ustorage_fs_detach without specifically
* initializing the struct.
*/
@ -371,7 +371,9 @@ ustorage_fs_attach(device_t dev)
* further
*/
ustorage_fs_ramdisk =
malloc(USTORAGE_FS_RAM_SECT << 9, M_USB, M_ZERO | M_WAITOK);
malloc(USTORAGE_FS_RAM_SECT << 9, M_USB,
M_ZERO | M_WAITOK);
if (ustorage_fs_ramdisk == NULL) {
return (ENOMEM);
}

View File

@ -913,7 +913,7 @@ usb_hw_ep_resolve(struct usb_device *udev,
}
ues = udev->bus->scratch[0].hw_ep_scratch;
bzero(ues, sizeof(*ues));
memset(ues, 0, sizeof(*ues));
ues->ep_max = ues->ep;
ues->cd = (void *)desc;
@ -1240,7 +1240,7 @@ usb_temp_setup(struct usb_device *udev,
}
uts = udev->bus->scratch[0].temp_setup;
bzero(uts, sizeof(*uts));
memset(uts, 0, sizeof(*uts));
uts->usb_speed = udev->speed;
uts->self_powered = udev->flags.self_powered;

View File

@ -80,9 +80,9 @@ void
usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
struct usb_page_search *res)
{
#if USB_HAVE_BUSDMA
struct usb_page *page;
#if USB_HAVE_BUSDMA
if (pc->page_start) {
/* Case 1 - something has been loaded into DMA */
@ -145,7 +145,7 @@ usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset,
if (buf_res.length > len) {
buf_res.length = len;
}
bcopy(ptr, buf_res.buffer, buf_res.length);
memcpy(buf_res.buffer, ptr, buf_res.length);
offset += buf_res.length;
len -= buf_res.length;
@ -267,7 +267,7 @@ usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset,
if (res.length > len) {
res.length = len;
}
bcopy(res.buffer, ptr, res.length);
memcpy(ptr, res.buffer, res.length);
offset += res.length;
len -= res.length;
@ -325,7 +325,7 @@ usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset,
if (res.length > len) {
res.length = len;
}
bzero(res.buffer, res.length);
memset(res.buffer, 0, res.length);
offset += res.length;
len -= res.length;
@ -560,7 +560,7 @@ usb_pc_alloc_mem(struct usb_page_cache *pc, struct usb_page *pg,
bus_dmamem_free(utag->tag, ptr, map);
goto error;
}
bzero(ptr, size);
memset(ptr, 0, size);
usb_pc_cpu_flush(pc);
@ -797,7 +797,7 @@ usb_dma_tag_setup(struct usb_dma_parent_tag *udpt,
struct mtx *mtx, usb_dma_callback_t *func,
uint8_t ndmabits, uint8_t nudt)
{
bzero(udpt, sizeof(*udpt));
memset(udpt, 0, sizeof(*udpt));
/* sanity checking */
if ((nudt == 0) ||
@ -818,7 +818,7 @@ usb_dma_tag_setup(struct usb_dma_parent_tag *udpt,
udpt->dma_bits = ndmabits;
while (nudt--) {
bzero(udt, sizeof(*udt));
memset(udt, 0, sizeof(*udt));
udt->tag_parent = udpt;
udt++;
}

View File

@ -564,7 +564,7 @@ usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe)
type = uhe->desc.bmAttributes & UE_XFERTYPE;
addr = uhe->desc.bEndpointAddress;
bzero(cfg, sizeof(cfg));
memset(cfg, 0, sizeof(cfg));
cfg[0].type = type;
cfg[0].endpoint = addr & UE_ADDR;
@ -709,12 +709,12 @@ usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe,
urb->dev = dev;
urb->endpoint = uhe;
bcopy(&req, urb->setup_packet, sizeof(req));
memcpy(urb->setup_packet, &req, sizeof(req));
if (size && (!(req.bmRequestType & UT_READ))) {
/* move the data to a real buffer */
bcopy(data, USB_ADD_BYTES(urb->setup_packet,
sizeof(req)), size);
memcpy(USB_ADD_BYTES(urb->setup_packet, sizeof(req)),
data, size);
}
err = usb_start_wait_urb(urb, timeout, &actlen);
@ -789,7 +789,7 @@ usb_setup_endpoint(struct usb_device *dev,
if (bufsize == 0) {
return (0);
}
bzero(cfg, sizeof(cfg));
memset(cfg, 0, sizeof(cfg));
if (type == UE_ISOCHRONOUS) {
@ -1251,7 +1251,7 @@ usb_init_urb(struct urb *urb)
if (urb == NULL) {
return;
}
bzero(urb, sizeof(*urb));
memset(urb, 0, sizeof(*urb));
}
/*------------------------------------------------------------------------*

View File

@ -1809,8 +1809,8 @@ usb_fifo_free_buffer(struct usb_fifo *f)
}
/* reset queues */
bzero(&f->free_q, sizeof(f->free_q));
bzero(&f->used_q, sizeof(f->used_q));
memset(&f->free_q, 0, sizeof(f->free_q));
memset(&f->used_q, 0, sizeof(f->used_q));
}
void
@ -1909,7 +1909,7 @@ usb_fifo_put_data_linear(struct usb_fifo *f, void *ptr,
io_len = MIN(len, m->cur_data_len);
bcopy(ptr, m->cur_data_ptr, io_len);
memcpy(m->cur_data_ptr, ptr, io_len);
m->cur_data_len = io_len;
ptr = USB_ADD_BYTES(ptr, io_len);
@ -2052,7 +2052,7 @@ usb_fifo_get_data_linear(struct usb_fifo *f, void *ptr,
io_len = MIN(len, m->cur_data_len);
bcopy(m->cur_data_ptr, ptr, io_len);
memcpy(ptr, m->cur_data_ptr, io_len);
len -= io_len;
ptr = USB_ADD_BYTES(ptr, io_len);

View File

@ -240,7 +240,7 @@ ugen_open_pipe_write(struct usb_fifo *f)
/* transfers are already opened */
return (0);
}
bzero(usb_config, sizeof(usb_config));
memset(usb_config, 0, sizeof(usb_config));
usb_config[1].type = UE_CONTROL;
usb_config[1].endpoint = 0;
@ -308,7 +308,7 @@ ugen_open_pipe_read(struct usb_fifo *f)
/* transfers are already opened */
return (0);
}
bzero(usb_config, sizeof(usb_config));
memset(usb_config, 0, sizeof(usb_config));
usb_config[1].type = UE_CONTROL;
usb_config[1].endpoint = 0;

View File

@ -475,8 +475,8 @@ bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
sc->data_timeout = (data_timeout + USB_MS_HZ);
sc->actlen = 0;
sc->cmd_len = cmd_len;
bzero(&sc->cbw.CBWCDB, sizeof(sc->cbw.CBWCDB));
bcopy(cmd_ptr, &sc->cbw.CBWCDB, cmd_len);
memset(&sc->cbw.CBWCDB, 0, sizeof(sc->cbw.CBWCDB));
memcpy(&sc->cbw.CBWCDB, cmd_ptr, cmd_len);
DPRINTFN(1, "SCSI cmd = %*D\n", (int)cmd_len, &sc->cbw.CBWCDB, ":");
mtx_lock(&sc->mtx);

View File

@ -517,7 +517,7 @@ usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
}
} else
#endif
bcopy(desc, data, length);
memcpy(data, desc, length);
}
goto done; /* success */
}

View File

@ -858,7 +858,7 @@ usbd_transfer_setup(struct usb_device *udev,
if (parm.err) {
goto done;
}
bzero(&parm, sizeof(parm));
memset(&parm, 0, sizeof(parm));
parm.udev = udev;
parm.speed = usbd_get_speed(udev);
@ -982,7 +982,7 @@ usbd_transfer_setup(struct usb_device *udev,
* memory:
*/
xfer = &dummy;
bzero(&dummy, sizeof(dummy));
memset(&dummy, 0, sizeof(dummy));
refcount++;
}

View File

@ -710,12 +710,12 @@ uath_cmdsend(struct uath_softc *sc, uint32_t code, const void *idata, int ilen,
cmd->buflen = roundup2(sizeof(struct uath_cmd_hdr) + ilen, 4);
hdr = (struct uath_cmd_hdr *)cmd->buf;
bzero(hdr, sizeof (struct uath_cmd_hdr)); /* XXX not needed */
memset(hdr, 0, sizeof(struct uath_cmd_hdr));
hdr->len = htobe32(cmd->buflen);
hdr->code = htobe32(code);
hdr->msgid = cmd->msgid; /* don't care about endianness */
hdr->magic = htobe32((cmd->flags & UATH_CMD_FLAG_MAGIC) ? 1 << 24 : 0);
bcopy(idata, (uint8_t *)(hdr + 1), ilen);
memcpy((uint8_t *)(hdr + 1), idata, ilen);
#ifdef UATH_DEBUG
if (sc->sc_debug & UATH_DEBUG_CMDS) {
@ -1403,7 +1403,7 @@ uath_dataflush(struct uath_softc *sc)
chunk->flags = UATH_CFLAGS_FINAL;
chunk->length = htobe16(sizeof (struct uath_tx_desc));
bzero(desc, sizeof(struct uath_tx_desc));
memset(desc, 0, sizeof(struct uath_tx_desc));
desc->msglen = htobe32(sizeof(struct uath_tx_desc));
desc->msgid = (sc->sc_msgid++) + 1; /* don't care about endianness */
desc->type = htobe32(WDCMSG_FLUSH);
@ -1482,7 +1482,7 @@ uath_set_chan(struct uath_softc *sc, struct ieee80211_channel *c)
#endif
struct uath_cmd_reset reset;
bzero(&reset, sizeof reset);
memset(&reset, 0, sizeof(reset));
if (IEEE80211_IS_CHAN_2GHZ(c))
reset.flags |= htobe32(UATH_CHAN_2GHZ);
if (IEEE80211_IS_CHAN_5GHZ(c))
@ -1971,7 +1971,7 @@ uath_create_connection(struct uath_softc *sc, uint32_t connid)
struct uath_cmd_create_connection create;
ni = ieee80211_ref_node(vap->iv_bss);
bzero(&create, sizeof create);
memset(&create, 0, sizeof(create));
create.connid = htobe32(connid);
create.bssid = htobe32(0);
/* XXX packed or not? */
@ -2000,7 +2000,7 @@ uath_set_rates(struct uath_softc *sc, const struct ieee80211_rateset *rs)
{
struct uath_cmd_rates rates;
bzero(&rates, sizeof rates);
memset(&rates, 0, sizeof(rates));
rates.connid = htobe32(UATH_ID_BSS); /* XXX */
rates.size = htobe32(sizeof(struct uath_cmd_rateset));
/* XXX bounds check rs->rs_nrates */
@ -2022,7 +2022,7 @@ uath_write_associd(struct uath_softc *sc)
struct uath_cmd_set_associd associd;
ni = ieee80211_ref_node(vap->iv_bss);
bzero(&associd, sizeof associd);
memset(&associd, 0, sizeof(associd));
associd.defaultrateix = htobe32(1); /* XXX */
associd.associd = htobe32(ni->ni_associd);
associd.timoffset = htobe32(0x3b); /* XXX */
@ -2168,7 +2168,7 @@ uath_set_key(struct uath_softc *sc, const struct ieee80211_key *wk,
struct uath_cmd_crypto crypto;
int i;
bzero(&crypto, sizeof crypto);
memset(&crypto, 0, sizeof(crypto));
crypto.keyidx = htobe32(index);
crypto.magic1 = htobe32(1);
crypto.size = htobe32(368);
@ -2176,7 +2176,7 @@ uath_set_key(struct uath_softc *sc, const struct ieee80211_key *wk,
crypto.flags = htobe32(0x80000068);
if (index != UATH_DEFAULT_KEY)
crypto.flags |= htobe32(index << 16);
memset(crypto.magic2, 0xff, sizeof crypto.magic2);
memset(crypto.magic2, 0xff, sizeof(crypto.magic2));
/*
* Each byte of the key must be XOR'ed with 10101010 before being

View File

@ -432,7 +432,7 @@ upgt_get_stats(struct upgt_softc *sc)
/*
* Transmit the URB containing the CMD data.
*/
bzero(data_cmd->buf, MCLBYTES);
memset(data_cmd->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data_cmd->buf;
mem->addr = htole32(sc->sc_memaddr_frame_start +
@ -540,7 +540,7 @@ upgt_set_led(struct upgt_softc *sc, int action)
/*
* Transmit the URB containing the CMD data.
*/
bzero(data_cmd->buf, MCLBYTES);
memset(data_cmd->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data_cmd->buf;
mem->addr = htole32(sc->sc_memaddr_frame_start +
@ -670,7 +670,7 @@ upgt_set_macfilter(struct upgt_softc *sc, uint8_t state)
/*
* Transmit the URB containing the CMD data.
*/
bzero(data_cmd->buf, MCLBYTES);
memset(data_cmd->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data_cmd->buf;
mem->addr = htole32(sc->sc_memaddr_frame_start +
@ -785,11 +785,11 @@ upgt_setup_rates(struct ieee80211vap *vap, struct ieee80211com *ic)
* will pickup a rate.
*/
if (ic->ic_curmode == IEEE80211_MODE_11B)
bcopy(rateset_auto_11b, sc->sc_cur_rateset,
memcpy(sc->sc_cur_rateset, rateset_auto_11b,
sizeof(sc->sc_cur_rateset));
if (ic->ic_curmode == IEEE80211_MODE_11G ||
ic->ic_curmode == IEEE80211_MODE_AUTO)
bcopy(rateset_auto_11g, sc->sc_cur_rateset,
memcpy(sc->sc_cur_rateset, rateset_auto_11g,
sizeof(sc->sc_cur_rateset));
} else {
/* set a fixed rate */
@ -975,7 +975,7 @@ upgt_set_chan(struct upgt_softc *sc, struct ieee80211_channel *c)
/*
* Transmit the URB containing the CMD data.
*/
bzero(data_cmd->buf, MCLBYTES);
memset(data_cmd->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data_cmd->buf;
mem->addr = htole32(sc->sc_memaddr_frame_start +
@ -998,11 +998,11 @@ upgt_set_chan(struct upgt_softc *sc, struct ieee80211_channel *c)
chan->settings = sc->sc_eeprom_freq6_settings;
chan->unknown3 = UPGT_CHANNEL_UNKNOWN3;
bcopy(&sc->sc_eeprom_freq3[channel].data, chan->freq3_1,
memcpy(chan->freq3_1, &sc->sc_eeprom_freq3[channel].data,
sizeof(chan->freq3_1));
bcopy(&sc->sc_eeprom_freq4[channel], chan->freq4,
memcpy(chan->freq4, &sc->sc_eeprom_freq4[channel],
sizeof(sc->sc_eeprom_freq4[channel]));
bcopy(&sc->sc_eeprom_freq3[channel].data, chan->freq3_2,
memcpy(chan->freq3_2, &sc->sc_eeprom_freq3[channel].data,
sizeof(chan->freq3_2));
data_cmd->buflen = sizeof(*mem) + sizeof(*chan);
@ -1331,7 +1331,7 @@ upgt_eeprom_read(struct upgt_softc *sc)
/*
* Transmit the URB containing the CMD data.
*/
bzero(data_cmd->buf, MCLBYTES);
memset(data_cmd->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data_cmd->buf;
mem->addr = htole32(sc->sc_memaddr_frame_start +
@ -1423,8 +1423,9 @@ upgt_rxeof(struct usb_xfer *xfer, struct upgt_data *data, int *rssi)
"received EEPROM block (offset=%d, len=%d)\n",
eeprom_offset, eeprom_len);
bcopy(data->buf + sizeof(struct upgt_lmac_eeprom) + 4,
sc->sc_eeprom + eeprom_offset, eeprom_len);
memcpy(sc->sc_eeprom + eeprom_offset,
data->buf + sizeof(struct upgt_lmac_eeprom) + 4,
eeprom_len);
/* EEPROM data has arrived in time, wakeup. */
wakeup(sc);
@ -1498,7 +1499,7 @@ upgt_rx(struct upgt_softc *sc, uint8_t *data, int pkglen, int *rssi)
return (NULL);
}
m_adj(m, ETHER_ALIGN);
bcopy(rxdesc->data, mtod(m, char *), pkglen);
memcpy(mtod(m, char *), rxdesc->data, pkglen);
/* trim FCS */
m->m_len = m->m_pkthdr.len = pkglen - IEEE80211_CRC_LEN;
m->m_pkthdr.rcvif = ifp;
@ -1620,7 +1621,7 @@ upgt_fw_load(struct upgt_softc *sc)
goto fail;
}
data_cmd->buflen = sizeof(start_fwload_cmd);
bcopy(start_fwload_cmd, data_cmd->buf, data_cmd->buflen);
memcpy(data_cmd->buf, start_fwload_cmd, data_cmd->buflen);
upgt_bulk_tx(sc, data_cmd);
/* send X2 header */
@ -1631,7 +1632,7 @@ upgt_fw_load(struct upgt_softc *sc)
}
data_cmd->buflen = sizeof(struct upgt_fw_x2_header);
x2 = (struct upgt_fw_x2_header *)data_cmd->buf;
bcopy(UPGT_X2_SIGNATURE, x2->signature, UPGT_X2_SIGNATURE_SIZE);
memcpy(x2->signature, UPGT_X2_SIGNATURE, UPGT_X2_SIGNATURE_SIZE);
x2->startaddr = htole32(UPGT_MEMADDR_FIRMWARE_START);
x2->len = htole32(fw->datasize);
x2->crc = upgt_crc32_le((uint8_t *)data_cmd->buf +
@ -1925,7 +1926,7 @@ upgt_device_reset(struct upgt_softc *sc)
UPGT_UNLOCK(sc);
return (ENOBUFS);
}
bcopy(init_cmd, data->buf, sizeof(init_cmd));
memcpy(data->buf, init_cmd, sizeof(init_cmd));
data->buflen = sizeof(init_cmd);
upgt_bulk_tx(sc, data);
usb_pause_mtx(&sc->sc_mtx, 100);
@ -2178,7 +2179,7 @@ upgt_tx_start(struct upgt_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
}
/* Transmit the URB containing the TX data. */
bzero(data->buf, MCLBYTES);
memset(data->buf, 0, MCLBYTES);
mem = (struct upgt_lmac_mem *)data->buf;
mem->addr = htole32(data->addr);
txdesc = (struct upgt_lmac_tx_desc *)(mem + 1);
@ -2192,7 +2193,7 @@ upgt_tx_start(struct upgt_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
} else {
/* data frames */
txdesc->header1.flags = UPGT_H1_FLAGS_TX_DATA;
bcopy(sc->sc_cur_rateset, txdesc->rates, sizeof(txdesc->rates));
memcpy(txdesc->rates, sc->sc_cur_rateset, sizeof(txdesc->rates));
}
txdesc->header1.type = UPGT_H1_TYPE_TX_DATA;
txdesc->header1.len = htole16(m->m_pkthdr.len);

View File

@ -1745,7 +1745,7 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0,
if ((0 == xferlen % 64) || (0 == xferlen % 512))
xferlen += 1;
bzero(data->buf, URTW_TX_MAXSIZE);
memset(data->buf, 0, URTW_TX_MAXSIZE);
flags = m0->m_pkthdr.len & 0xfff;
flags |= URTW_TX_FLAG_NO_ENC;
if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) &&

View File

@ -683,7 +683,7 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
if (i != cnt)
continue;
/* copy answer into caller-supplied buffer */
bcopy(cmd->data, rqp->odata, rqp->olen);
memcpy(rqp->odata, cmd->data, rqp->olen);
DPRINTF(sc, ZYD_DEBUG_CMD,
"command %p complete, data = %*D \n",
rqp, rqp->olen, rqp->odata, ":");
@ -783,7 +783,7 @@ zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen,
return (EINVAL);
cmd.code = htole16(code);
bcopy(idata, cmd.data, ilen);
memcpy(cmd.data, idata, ilen);
DPRINTF(sc, ZYD_DEBUG_CMD, "sending cmd %p = %*D\n",
&rq, ilen, idata, ":");