Skip to content

Commit 3b9e5e1

Browse files
committed
usb.c : avoid using 'interface' as an identifier.
per #508, a windows header (combaseapi.h) includes this: making 'interface' a keyword, which we need to avoid using, so - avoid using it to ensure things compile without issues. Signed-off-by: Robin Getz <robin.getz@analog.com>
1 parent 956e384 commit 3b9e5e1

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

iio-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ struct iio_context * network_create_context(const char *hostname);
285285
struct iio_context * xml_create_context_mem(const char *xml, size_t len);
286286
struct iio_context * xml_create_context(const char *xml_file);
287287
struct iio_context * usb_create_context(unsigned int bus, uint16_t address,
288-
uint16_t interface);
288+
uint16_t intrfc);
289289
struct iio_context * usb_create_context_from_uri(const char *uri);
290290
struct iio_context * serial_create_context_from_uri(const char *uri);
291291

usb.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct iio_usb_io_context {
5858
struct iio_context_pdata {
5959
libusb_context *ctx;
6060
libusb_device_handle *hdl;
61-
uint16_t interface;
61+
uint16_t intrfc;
6262

6363
struct iiod_client *iiod_client;
6464

@@ -173,7 +173,7 @@ static int usb_reset_pipes(struct iio_context_pdata *pdata)
173173
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_INTERFACE,
174174
IIO_USD_CMD_RESET_PIPES,
175175
0,
176-
pdata->interface,
176+
pdata->intrfc,
177177
NULL,
178178
0,
179179
USB_PIPE_CTRL_TIMEOUT);
@@ -200,7 +200,7 @@ static int usb_open_pipe(struct iio_context_pdata *pdata, uint16_t pipe_id)
200200
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_INTERFACE,
201201
IIO_USD_CMD_OPEN_PIPE,
202202
pipe_id,
203-
pdata->interface,
203+
pdata->intrfc,
204204
NULL,
205205
0,
206206
USB_PIPE_CTRL_TIMEOUT);
@@ -215,7 +215,7 @@ static int usb_close_pipe(struct iio_context_pdata *pdata, uint16_t pipe_id)
215215

216216
ret = libusb_control_transfer(pdata->hdl, LIBUSB_REQUEST_TYPE_VENDOR |
217217
LIBUSB_RECIPIENT_INTERFACE, IIO_USD_CMD_CLOSE_PIPE,
218-
pipe_id, pdata->interface, NULL, 0, USB_PIPE_CTRL_TIMEOUT);
218+
pipe_id, pdata->intrfc, NULL, 0, USB_PIPE_CTRL_TIMEOUT);
219219
if (ret < 0)
220220
return -(int) libusb_to_errno(ret);
221221
return 0;
@@ -482,15 +482,15 @@ static void usb_shutdown(struct iio_context *ctx)
482482
}
483483

484484
static int iio_usb_match_interface(const struct libusb_config_descriptor *desc,
485-
struct libusb_device_handle *hdl, unsigned int interface)
485+
struct libusb_device_handle *hdl, unsigned int intrfc)
486486
{
487487
const struct libusb_interface *iface;
488488
unsigned int i;
489489

490-
if (interface >= desc->bNumInterfaces)
490+
if (intrfc >= desc->bNumInterfaces)
491491
return -EINVAL;
492492

493-
iface = &desc->interface[interface];
493+
iface = &desc->interface[intrfc];
494494

495495
for (i = 0; i < (unsigned int) iface->num_altsetting; i++) {
496496
const struct libusb_interface_descriptor *idesc =
@@ -515,7 +515,7 @@ static int iio_usb_match_interface(const struct libusb_config_descriptor *desc,
515515

516516
static int iio_usb_match_device(struct libusb_device *dev,
517517
struct libusb_device_handle *hdl,
518-
unsigned int *interface)
518+
unsigned int *intrfc)
519519
{
520520
struct libusb_config_descriptor *desc;
521521
unsigned int i;
@@ -537,7 +537,7 @@ static int iio_usb_match_device(struct libusb_device *dev,
537537
libusb_get_bus_number(dev),
538538
libusb_get_device_address(dev), i - 1);
539539

540-
*interface = i - 1;
540+
*intrfc = i - 1;
541541
return ret;
542542
}
543543

@@ -810,7 +810,7 @@ static int usb_populate_context_attrs(struct iio_context *ctx,
810810
}
811811

812812
struct iio_context * usb_create_context(unsigned int bus,
813-
uint16_t address, uint16_t interface)
813+
uint16_t address, uint16_t intrfc)
814814
{
815815
libusb_context *usb_ctx;
816816
libusb_device_handle *hdl = NULL;
@@ -912,13 +912,13 @@ struct iio_context * usb_create_context(unsigned int bus,
912912
libusb_set_auto_detach_kernel_driver(hdl, true);
913913
#endif
914914

915-
ret = libusb_claim_interface(hdl, interface);
915+
ret = libusb_claim_interface(hdl, intrfc);
916916
if (ret) {
917917
char err_str[1024];
918918
ret = -(int) libusb_to_errno(ret);
919919
iio_strerror(-ret, err_str, sizeof(err_str));
920920
IIO_ERROR("Unable to claim interface %u:%u:%u: %s (%i)\n",
921-
bus, address, interface, err_str, ret);
921+
bus, address, intrfc, err_str, ret);
922922
goto err_libusb_close;
923923
}
924924

@@ -932,7 +932,7 @@ struct iio_context * usb_create_context(unsigned int bus,
932932
goto err_libusb_close;
933933
}
934934

935-
iface = &conf_desc->interface[interface].altsetting[0];
935+
iface = &conf_desc->interface[intrfc].altsetting[0];
936936

937937
ret = usb_verify_eps(iface);
938938
if (ret) {
@@ -973,7 +973,7 @@ struct iio_context * usb_create_context(unsigned int bus,
973973
pdata->ctx = usb_ctx;
974974
pdata->hdl = hdl;
975975
pdata->timeout_ms = DEFAULT_TIMEOUT_MS;
976-
pdata->interface = interface;
976+
pdata->intrfc = intrfc;
977977

978978
ret = usb_io_context_init(&pdata->io_ctx);
979979
if (ret)
@@ -1066,7 +1066,7 @@ struct iio_context * usb_create_context(unsigned int bus,
10661066

10671067
struct iio_context * usb_create_context_from_uri(const char *uri)
10681068
{
1069-
long bus, address, interface;
1069+
long bus, address, intrfc;
10701070
char *end;
10711071
const char *ptr;
10721072
/* keep MSVS happy by setting these to NULL */
@@ -1136,31 +1136,31 @@ struct iio_context * usb_create_context_from_uri(const char *uri)
11361136
goto err_bad_uri;
11371137

11381138
if (*end == '\0') {
1139-
interface = 0;
1139+
intrfc = 0;
11401140
} else if (*end == '.') {
11411141
ptr = (const char *) ((uintptr_t) end + 1);
11421142
if (!isdigit(*ptr))
11431143
goto err_bad_uri;
11441144

1145-
interface = strtol(ptr, &end, 10);
1145+
intrfc = strtol(ptr, &end, 10);
11461146
if (ptr == end || *end != '\0')
11471147
goto err_bad_uri;
11481148
} else {
11491149
goto err_bad_uri;
11501150
}
11511151

1152-
if (bus < 0 || address < 0 || interface < 0)
1152+
if (bus < 0 || address < 0 || intrfc < 0)
11531153
goto err_bad_uri;
11541154

1155-
if (bus > (long) UINT_MAX || address > UINT8_MAX || interface > UINT8_MAX)
1155+
if (bus > (long) UINT_MAX || address > UINT8_MAX || intrfc > UINT8_MAX)
11561156
goto err_bad_uri;
11571157

11581158
if (scan) {
11591159
iio_context_info_list_free(info);
11601160
iio_scan_context_destroy(scan_ctx);
11611161
}
11621162
return usb_create_context((unsigned int) bus,
1163-
(uint16_t) address, (uint16_t) interface);
1163+
(uint16_t) address, (uint16_t) intrfc);
11641164

11651165
err_bad_uri:
11661166
if (scan) {
@@ -1175,7 +1175,7 @@ struct iio_context * usb_create_context_from_uri(const char *uri)
11751175

11761176
static int usb_fill_context_info(struct iio_context_info *info,
11771177
struct libusb_device *dev, struct libusb_device_handle *hdl,
1178-
unsigned int interface)
1178+
unsigned int intrfc)
11791179
{
11801180
struct libusb_device_descriptor desc;
11811181
char manufacturer[64], product[64], serial[64];
@@ -1188,7 +1188,7 @@ static int usb_fill_context_info(struct iio_context_info *info,
11881188

11891189
iio_snprintf(uri, sizeof(uri), "usb:%d.%d.%u",
11901190
libusb_get_bus_number(dev), libusb_get_device_address(dev),
1191-
interface);
1191+
intrfc);
11921192

11931193
if (desc.iManufacturer == 0) {
11941194
manufacturer[0] = '\0';
@@ -1282,19 +1282,19 @@ int usb_context_scan(struct iio_scan_backend_context *ctx,
12821282
for (i = 0; device_list[i]; i++) {
12831283
struct libusb_device_handle *hdl;
12841284
struct libusb_device *dev = device_list[i];
1285-
unsigned int interface = 0;
1285+
unsigned int intrfc = 0;
12861286

12871287
ret = libusb_open(dev, &hdl);
12881288
if (ret)
12891289
continue;
12901290

1291-
if (!iio_usb_match_device(dev, hdl, &interface)) {
1291+
if (!iio_usb_match_device(dev, hdl, &intrfc)) {
12921292
info = iio_scan_result_add(scan_result, 1);
12931293
if (!info)
12941294
ret = -ENOMEM;
12951295
else
12961296
ret = usb_fill_context_info(*info, dev, hdl,
1297-
interface);
1297+
intrfc);
12981298
}
12991299

13001300
libusb_close(hdl);

0 commit comments

Comments
 (0)