diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2020-07-22 14:32:47 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2020-07-22 14:32:47 +0000 |
| commit | 94140f4781f83c9e98f582439ed69d000ff0323a (patch) | |
| tree | eb82b0dcf8af2286a9f3eb52cf3cb34652ffa5c1 /sys | |
| parent | 3b01bf881c848ba0be72fc74ba5eaa58c66c35e1 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/compat/linuxkpi/common/src/linux_usb.c | 20 | ||||
| -rw-r--r-- | sys/dev/sound/usb/uaudio.c | 4 | ||||
| -rw-r--r-- | sys/dev/usb/input/uhid.c | 8 | ||||
| -rw-r--r-- | sys/dev/usb/input/uhid_snes.c | 8 | ||||
| -rw-r--r-- | sys/dev/usb/storage/ustorage_fs.c | 4 | ||||
| -rw-r--r-- | sys/dev/usb/usb_dev.c | 15 | ||||
| -rw-r--r-- | sys/dev/usb/usb_device.c | 2 | ||||
| -rw-r--r-- | sys/dev/usb/usb_freebsd.h | 1 | ||||
| -rw-r--r-- | sys/dev/usb/usb_freebsd_loader.h | 1 | ||||
| -rw-r--r-- | sys/dev/usb/usb_generic.c | 5 | ||||
| -rw-r--r-- | sys/dev/usb/usb_mbuf.c | 6 | ||||
| -rw-r--r-- | sys/dev/usb/usb_transfer.c | 5 |
12 files changed, 19 insertions, 60 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_usb.c b/sys/compat/linuxkpi/common/src/linux_usb.c index 774cae98f1d71..abef31e20a071 100644 --- a/sys/compat/linuxkpi/common/src/linux_usb.c +++ b/sys/compat/linuxkpi/common/src/linux_usb.c @@ -707,8 +707,6 @@ usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe, * 0xFFFF is a FreeBSD specific magic value. */ urb = usb_alloc_urb(0xFFFF, size); - if (urb == NULL) - return (-ENOMEM); urb->dev = dev; urb->endpoint = uhe; @@ -1008,16 +1006,14 @@ usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags) } urb = malloc(size, M_USBDEV, M_WAITOK | M_ZERO); - if (urb) { - cv_init(&urb->cv_wait, "URBWAIT"); - if (iso_packets == 0xFFFF) { - urb->setup_packet = (void *)(urb + 1); - urb->transfer_buffer = (void *)(urb->setup_packet + - sizeof(struct usb_device_request)); - } else { - urb->number_of_packets = iso_packets; - } + cv_init(&urb->cv_wait, "URBWAIT"); + if (iso_packets == 0xFFFF) { + urb->setup_packet = (void *)(urb + 1); + urb->transfer_buffer = (void *)(urb->setup_packet + + sizeof(struct usb_device_request)); + } else { + urb->number_of_packets = iso_packets; } return (urb); } @@ -1722,8 +1718,6 @@ usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe, return (err); urb = usb_alloc_urb(0, 0); - if (urb == NULL) - return (-ENOMEM); usb_fill_bulk_urb(urb, udev, uhe, data, len, usb_linux_wait_complete, NULL); diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 06986b03e8e28..54abd63d9ecbc 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -4968,10 +4968,6 @@ uaudio_mixer_fill_info(struct uaudio_softc *sc, iot = malloc(sizeof(struct uaudio_terminal_node) * 256, M_TEMP, M_WAITOK | M_ZERO); - if (iot == NULL) { - DPRINTF("no memory!\n"); - goto done; - } while ((desc = usb_desc_foreach(cd, desc))) { dp = desc; diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c index c3ca63e13f6cb..4ef19631b10ff 100644 --- a/sys/dev/usb/input/uhid.c +++ b/sys/dev/usb/input/uhid.c @@ -451,10 +451,6 @@ uhid_get_report(struct uhid_softc *sc, uint8_t type, if (kern_data == NULL) { kern_data = malloc(len, M_USBDEV, M_WAITOK); - if (kern_data == NULL) { - err = ENOMEM; - goto done; - } free_data = 1; } err = usbd_req_get_report(sc->sc_udev, NULL, kern_data, @@ -487,10 +483,6 @@ uhid_set_report(struct uhid_softc *sc, uint8_t type, if (kern_data == NULL) { kern_data = malloc(len, M_USBDEV, M_WAITOK); - if (kern_data == NULL) { - err = ENOMEM; - goto done; - } free_data = 1; err = copyin(user_data, kern_data, len); if (err) { diff --git a/sys/dev/usb/input/uhid_snes.c b/sys/dev/usb/input/uhid_snes.c index 5c043acdf6a73..79089782a4647 100644 --- a/sys/dev/usb/input/uhid_snes.c +++ b/sys/dev/usb/input/uhid_snes.c @@ -168,10 +168,6 @@ uhid_get_report(struct uhid_snes_softc *sc, uint8_t type, if (kern_data == NULL) { kern_data = malloc(len, M_USBDEV, M_WAITOK); - if (kern_data == NULL) { - err = ENOMEM; - goto done; - } free_data = 1; } err = usbd_req_get_report(sc->sc_udev, NULL, kern_data, @@ -203,10 +199,6 @@ uhid_set_report(struct uhid_snes_softc *sc, uint8_t type, if (kern_data == NULL) { kern_data = malloc(len, M_USBDEV, M_WAITOK); - if (kern_data == NULL) { - err = ENOMEM; - goto done; - } free_data = 1; err = copyin(user_data, kern_data, len); if (err) { diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c index ea3f05fb5db97..454dac07d3c01 100644 --- a/sys/dev/usb/storage/ustorage_fs.c +++ b/sys/dev/usb/storage/ustorage_fs.c @@ -381,10 +381,6 @@ ustorage_fs_attach(device_t dev) ustorage_fs_ramdisk = malloc(USTORAGE_FS_RAM_SECT << 9, M_USB, M_ZERO | M_WAITOK); - - if (ustorage_fs_ramdisk == NULL) { - return (ENOMEM); - } } sc->sc_lun[0].memory_image = ustorage_fs_ramdisk; sc->sc_lun[0].num_sectors = USTORAGE_FS_RAM_SECT; diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 7860fb67e5fec..9e17dfdc09bf0 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -386,13 +386,11 @@ usb_fifo_alloc(struct mtx *mtx) struct usb_fifo *f; f = malloc(sizeof(*f), M_USBDEV, M_WAITOK | M_ZERO); - if (f != NULL) { - cv_init(&f->cv_io, "FIFO-IO"); - cv_init(&f->cv_drain, "FIFO-DRAIN"); - f->priv_mtx = mtx; - f->refcount = 1; - knlist_init_mtx(&f->selinfo.si_note, mtx); - } + cv_init(&f->cv_io, "FIFO-IO"); + cv_init(&f->cv_drain, "FIFO-DRAIN"); + f->priv_mtx = mtx; + f->refcount = 1; + knlist_init_mtx(&f->selinfo.si_note, mtx); return (f); } @@ -2309,9 +2307,6 @@ usb_alloc_symlink(const char *target) struct usb_symlink *ps; ps = malloc(sizeof(*ps), M_USBDEV, M_WAITOK); - if (ps == NULL) { - return (ps); - } /* XXX no longer needed */ strlcpy(ps->src_path, target, sizeof(ps->src_path)); ps->src_len = strlen(ps->src_path); diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index e4ed447b813d2..5560c0ae0acf2 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -1785,9 +1785,11 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus, return (NULL); } udev = malloc(sizeof(*udev), M_USB, M_WAITOK | M_ZERO); +#if (USB_HAVE_MALLOC_WAITOK == 0) if (udev == NULL) { return (NULL); } +#endif /* initialise our SX-lock */ sx_init_flags(&udev->enum_sx, "USB config SX lock", SX_DUPOK); sx_init_flags(&udev->sr_sx, "USB suspend and resume SX lock", SX_NOWITNESS); diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h index 871fc7125ad24..2d2123d4b6229 100644 --- a/sys/dev/usb/usb_freebsd.h +++ b/sys/dev/usb/usb_freebsd.h @@ -53,6 +53,7 @@ #define USB_HAVE_FIXED_CONFIG 0 #define USB_HAVE_FIXED_PORT 0 #define USB_HAVE_DISABLE_ENUM 1 +#define USB_HAVE_MALLOC_WAITOK 1 /* define zero ticks callout value */ #define USB_CALLOUT_ZERO_TICKS 1 diff --git a/sys/dev/usb/usb_freebsd_loader.h b/sys/dev/usb/usb_freebsd_loader.h index 52f895b2e557f..d3aade89640a3 100644 --- a/sys/dev/usb/usb_freebsd_loader.h +++ b/sys/dev/usb/usb_freebsd_loader.h @@ -53,6 +53,7 @@ #define USB_HAVE_FIXED_CONFIG 0 #define USB_HAVE_FIXED_PORT 0 #define USB_HAVE_DISABLE_ENUM 0 +#define USB_HAVE_MALLOC_WAITOK 0 #define USB_CALLOUT_ZERO_TICKS 1 diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index aee2939ee1f74..940b3dc145b40 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -2339,11 +2339,6 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags) } f->fs_xfer = malloc(sizeof(f->fs_xfer[0]) * u.pinit->ep_index_max, M_USB, M_WAITOK | M_ZERO); - if (f->fs_xfer == NULL) { - usb_fifo_free_buffer(f); - error = ENOMEM; - break; - } f->fs_ep_max = u.pinit->ep_index_max; f->fs_ep_ptr = u.pinit->pEndpoints; break; diff --git a/sys/dev/usb/usb_mbuf.c b/sys/dev/usb/usb_mbuf.c index eacef78be4ccb..4eb27cf6977e4 100644 --- a/sys/dev/usb/usb_mbuf.c +++ b/sys/dev/usb/usb_mbuf.c @@ -78,15 +78,10 @@ usb_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, alloc_size = (block_size + sizeof(struct usb_mbuf)) * nblocks; free_ptr = malloc(alloc_size, type, M_WAITOK | M_ZERO); - - if (free_ptr == NULL) { - goto done; - } m_ptr = free_ptr; data_ptr = (void *)(m_ptr + nblocks); while (nblocks--) { - m_ptr->cur_data_ptr = m_ptr->min_data_ptr = data_ptr; @@ -99,6 +94,5 @@ usb_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, data_ptr += block_size; } } -done: return (free_ptr); } diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 15b971bbd0ba9..ab70da8afd4c3 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -1342,14 +1342,15 @@ usbd_transfer_setup(struct usb_device *udev, /* allocate zeroed memory */ buf = malloc(parm->size[0], M_USB, M_WAITOK | M_ZERO); - +#if (USB_HAVE_MALLOC_WAITOK == 0) if (buf == NULL) { parm->err = USB_ERR_NOMEM; DPRINTFN(0, "cannot allocate memory block for " "configuration (%d bytes)\n", parm->size[0]); goto done; - } + } +#endif parm->dma_tag_p = USB_ADD_BYTES(buf, parm->size[1]); parm->dma_page_ptr = USB_ADD_BYTES(buf, parm->size[3]); parm->dma_page_cache_ptr = USB_ADD_BYTES(buf, parm->size[4]); |
