git: a03d9f263466 - stable/13 - libusb: remove use of COMPAT_32BIT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 30 Apr 2023 06:57:44 UTC
The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=a03d9f2634664361fd7554a7e32f36e0a2131da3 commit a03d9f2634664361fd7554a7e32f36e0a2131da3 Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2021-12-17 21:28:14 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2023-04-30 06:56:15 +0000 libusb: remove use of COMPAT_32BIT This codepath used uint64_t's in place of pointers in structs and arrays to allow 32-bit code to use 64-bit version of ioctls. Now that we support 32-bit compat natively this is no longer needed. Reviewed by: hselasky, jrtc27 (prior version) (cherry picked from commit 8010f4ad21b6120e929bda4eed27696e63514677) --- lib/libusb/Makefile | 8 ++------ lib/libusb/libusb20.c | 12 ++++++------ lib/libusb/libusb20_int.h | 10 ---------- lib/libusb/libusb20_ugen20.c | 16 ++++++++-------- lib/libusbhid/Makefile | 4 ---- lib/libusbhid/data.c | 4 ++-- lib/libusbhid/descr.c | 4 ++-- lib/libusbhid/usbvar.h | 6 ------ 8 files changed, 20 insertions(+), 44 deletions(-) diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile index 1648664b8815..e33ca30ef22d 100644 --- a/lib/libusb/Makefile +++ b/lib/libusb/Makefile @@ -34,10 +34,6 @@ SRCS+= libusb10_desc.c SRCS+= libusb10_hotplug.c SRCS+= libusb10_io.c -.if defined(COMPAT_32BIT) -CFLAGS+= -DCOMPAT_32BIT -.endif - PCFILES= libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc # @@ -45,14 +41,14 @@ PCFILES= libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc # # Examples: # make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h -# make COMPAT_32BIT=YES \ +# make \ # LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \ # DEBUG_FLAGS="-g" # # From Ubuntu 10.04: # freebsd-make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \ # PTHREAD_LIBS="-lpthread -lrt" -# freebsd-make COMPAT32_BIT=YES \ +# freebsd-make \ # LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \ # PTHREAD_LIBS="-lpthread -lrt" # diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c index 4323552b83ad..60a5f8448888 100644 --- a/lib/libusb/libusb20.c +++ b/lib/libusb/libusb20.c @@ -352,7 +352,7 @@ libusb20_tr_clear_stall_sync(struct libusb20_transfer *xfer) void libusb20_tr_set_buffer(struct libusb20_transfer *xfer, void *buffer, uint16_t frIndex) { - xfer->ppBuffer[frIndex] = libusb20_pass_ptr(buffer); + xfer->ppBuffer[frIndex] = buffer; return; } @@ -418,7 +418,7 @@ libusb20_tr_set_total_frames(struct libusb20_transfer *xfer, uint32_t nFrames) void libusb20_tr_setup_bulk(struct libusb20_transfer *xfer, void *pBuf, uint32_t length, uint32_t timeout) { - xfer->ppBuffer[0] = libusb20_pass_ptr(pBuf); + xfer->ppBuffer[0] = pBuf; xfer->pLength[0] = length; xfer->timeout = timeout; xfer->nFrames = 1; @@ -430,7 +430,7 @@ libusb20_tr_setup_control(struct libusb20_transfer *xfer, void *psetup, void *pB { uint16_t len; - xfer->ppBuffer[0] = libusb20_pass_ptr(psetup); + xfer->ppBuffer[0] = psetup; xfer->pLength[0] = 8; /* fixed */ xfer->timeout = timeout; @@ -438,7 +438,7 @@ libusb20_tr_setup_control(struct libusb20_transfer *xfer, void *psetup, void *pB if (len != 0) { xfer->nFrames = 2; - xfer->ppBuffer[1] = libusb20_pass_ptr(pBuf); + xfer->ppBuffer[1] = pBuf; xfer->pLength[1] = len; } else { xfer->nFrames = 1; @@ -449,7 +449,7 @@ libusb20_tr_setup_control(struct libusb20_transfer *xfer, void *psetup, void *pB void libusb20_tr_setup_intr(struct libusb20_transfer *xfer, void *pBuf, uint32_t length, uint32_t timeout) { - xfer->ppBuffer[0] = libusb20_pass_ptr(pBuf); + xfer->ppBuffer[0] = pBuf; xfer->pLength[0] = length; xfer->timeout = timeout; xfer->nFrames = 1; @@ -463,7 +463,7 @@ libusb20_tr_setup_isoc(struct libusb20_transfer *xfer, void *pBuf, uint32_t leng /* should not happen */ return; } - xfer->ppBuffer[frIndex] = libusb20_pass_ptr(pBuf); + xfer->ppBuffer[frIndex] = pBuf; xfer->pLength[frIndex] = length; return; } diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h index 5f54ee3717fc..16796dc1233d 100644 --- a/lib/libusb/libusb20_int.h +++ b/lib/libusb/libusb20_int.h @@ -33,12 +33,6 @@ #ifndef _LIBUSB20_INT_H_ #define _LIBUSB20_INT_H_ -#ifdef COMPAT_32BIT -#define libusb20_pass_ptr(ptr) ((uint64_t)(uintptr_t)(ptr)) -#else -#define libusb20_pass_ptr(ptr) (ptr) -#endif - struct libusb20_device; struct libusb20_backend; struct libusb20_transfer; @@ -159,11 +153,7 @@ struct libusb20_transfer { /* * Pointer to a list of buffer pointers: */ -#ifdef COMPAT_32BIT - uint64_t *ppBuffer; -#else void **ppBuffer; -#endif /* * Pointer to frame lengths, which are updated to actual length * after the USB transfer completes: diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c index 5687caf97e4f..efffff2b5ef0 100644 --- a/lib/libusb/libusb20_ugen20.c +++ b/lib/libusb/libusb20_ugen20.c @@ -251,7 +251,7 @@ ugen20_readdir(struct ugen20_urd_state *st) repeat: if (st->ptr == NULL) { st->urd.urd_startentry += st->nparsed; - st->urd.urd_data = libusb20_pass_ptr(st->buf); + st->urd.urd_data = st->buf; st->urd.urd_maxlen = sizeof(st->buf); st->nparsed = 0; @@ -364,7 +364,7 @@ ugen20_tr_renew(struct libusb20_device *pdev) memset(&fs_init, 0, sizeof(fs_init)); - fs_init.pEndpoints = libusb20_pass_ptr(pdev->privBeData); + fs_init.pEndpoints = pdev->privBeData; fs_init.ep_index_max = nMaxTransfer; if (ioctl(pdev->file, IOUSB(USB_FS_INIT), &fs_init)) { @@ -478,7 +478,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev, memset(&cdesc, 0, sizeof(cdesc)); memset(&gen_desc, 0, sizeof(gen_desc)); - gen_desc.ugd_data = libusb20_pass_ptr(&cdesc); + gen_desc.ugd_data = &cdesc; gen_desc.ugd_maxlen = sizeof(cdesc); gen_desc.ugd_config_index = cfg_index; @@ -499,7 +499,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev, /* make sure memory is initialised */ memset(ptr, 0, len); - gen_desc.ugd_data = libusb20_pass_ptr(ptr); + gen_desc.ugd_data = ptr; gen_desc.ugd_maxlen = len; error = ioctl(pdev->file_ctrl, IOUSB(USB_GET_FULL_DESC), &gen_desc); @@ -726,7 +726,7 @@ ugen20_do_request_sync(struct libusb20_device *pdev, memset(&req, 0, sizeof(req)); - req.ucr_data = libusb20_pass_ptr(data); + req.ucr_data = data; if (!(flags & LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK)) { req.ucr_flags |= USB_SHORT_XFER_OK; } @@ -835,8 +835,8 @@ ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, xfer->maxPacketLen = temp.fs_open.max_packet_length; /* setup buffer and length lists using zero copy */ - fsep->ppBuffer = libusb20_pass_ptr(xfer->ppBuffer); - fsep->pLength = libusb20_pass_ptr(xfer->pLength); + fsep->ppBuffer = xfer->ppBuffer; + fsep->pLength = xfer->pLength; return (0); /* success */ } @@ -956,7 +956,7 @@ ugen20_dev_get_iface_desc(struct libusb20_device *pdev, memset(&ugd, 0, sizeof(ugd)); - ugd.ugd_data = libusb20_pass_ptr(buf); + ugd.ugd_data = buf; ugd.ugd_maxlen = len; ugd.ugd_iface_index = iface_index; diff --git a/lib/libusbhid/Makefile b/lib/libusbhid/Makefile index 7dba7ffc9113..2a58a4b1eb48 100644 --- a/lib/libusbhid/Makefile +++ b/lib/libusbhid/Makefile @@ -19,8 +19,4 @@ SRCS= descr.c descr_compat.c parse.c usage.c data.c INCS= usbhid.h -.if defined(COMPAT_32BIT) -CFLAGS+= -DCOMPAT_32BIT -.endif - .include <bsd.lib.mk> diff --git a/lib/libusbhid/data.c b/lib/libusbhid/data.c index ae81bb321095..cad320562eee 100644 --- a/lib/libusbhid/data.c +++ b/lib/libusbhid/data.c @@ -126,7 +126,7 @@ hid_get_report(int fd, enum hid_kind k, unsigned char *data, unsigned int size) struct usb_gen_descriptor ugd; memset(&ugd, 0, sizeof(ugd)); - ugd.ugd_data = hid_pass_ptr(data); + ugd.ugd_data = data; ugd.ugd_maxlen = size; ugd.ugd_report_type = k + 1; return (ioctl(fd, USB_GET_REPORT, &ugd)); @@ -138,7 +138,7 @@ hid_set_report(int fd, enum hid_kind k, unsigned char *data, unsigned int size) struct usb_gen_descriptor ugd; memset(&ugd, 0, sizeof(ugd)); - ugd.ugd_data = hid_pass_ptr(data); + ugd.ugd_data = data; ugd.ugd_maxlen = size; ugd.ugd_report_type = k + 1; return (ioctl(fd, USB_SET_REPORT, &ugd)); diff --git a/lib/libusbhid/descr.c b/lib/libusbhid/descr.c index 329bbe9261b7..7cd6750ad322 100644 --- a/lib/libusbhid/descr.c +++ b/lib/libusbhid/descr.c @@ -105,7 +105,7 @@ hid_get_report_desc(int fd) memset(&ugd, 0, sizeof(ugd)); /* get actual length first */ - ugd.ugd_data = hid_pass_ptr(NULL); + ugd.ugd_data = NULL; ugd.ugd_maxlen = 65535; if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { #ifdef HID_COMPAT7 @@ -126,7 +126,7 @@ hid_get_report_desc(int fd) return (NULL); /* fetch actual descriptor */ - ugd.ugd_data = hid_pass_ptr(data); + ugd.ugd_data = data; ugd.ugd_maxlen = ugd.ugd_actlen; if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { /* could not read descriptor */ diff --git a/lib/libusbhid/usbvar.h b/lib/libusbhid/usbvar.h index 5072f4787e42..0dfd596e8bb0 100644 --- a/lib/libusbhid/usbvar.h +++ b/lib/libusbhid/usbvar.h @@ -47,10 +47,4 @@ int hid_get_report_id_compat7(int fd); report_desc_t hid_get_report_desc_compat7(int fd); #endif -#ifdef COMPAT_32BIT -#define hid_pass_ptr(ptr) ((uint64_t)(uintptr_t)(ptr)) -#else -#define hid_pass_ptr(ptr) (ptr) -#endif - #endif /* _USBVAR_H_ */