static int init_device (void) { char buf [4096], *cp = &buf [0]; int fd; int result; #ifdef AIO if (iso) result = iso_autoconfig (); else #endif result = autoconfig (); if (result < 0) { fprintf (stderr, "?? don't recognize %s %s device\n", gadgetfs, iso ? "iso" : "bulk"); return result; } fd = open (DEVNAME, O_RDWR); if (fd < 0) { perror (DEVNAME); return -errno; } *(__u32 *)cp = 0; /* tag for this format */ cp += 4; /* write full then high speed configs */ cp = build_config (cp, fs_eps); if (HIGHSPEED) cp = build_config (cp, hs_eps); device_desc.idVendor = __cpu_to_le16 (vendorid); device_desc.idProduct = __cpu_to_le16 (productid); if (verbose) { fprintf(stderr, "idVendor=%04X idProduct=%04X\n", vendorid, productid); } /* and device descriptor at the end */ memcpy (cp, &device_desc, sizeof device_desc); cp += sizeof device_desc; result = write (fd, &buf [0], cp - &buf [0]); if (result < 0) { perror ("write dev descriptors"); close (fd); return result; } else if (result != (cp - buf)) { fprintf (stderr, "dev init, wrote %d expected %ld\n", result, (long int) (cp - buf)); close (fd); return -EIO; } return fd; }
static int init_device (void) { char buf [4096], *cp = &buf [0]; int fd; int status; #ifdef AIO if (iso) status = iso_autoconfig (); else #endif status = autoconfig (); if (status < 0) { fprintf (stderr, "?? don't recognize /dev/gadget %s device\n", iso ? "iso" : "bulk"); return status; } fd = open (DEVNAME, O_RDWR); if (fd < 0) { perror (DEVNAME); return -errno; } *(__u32 *)cp = 0; /* tag for this format */ cp += 4; /* write full then high speed configs */ cp = build_config (cp, fs_eps); if (HIGHSPEED) cp = build_config (cp, hs_eps); /* and device descriptor at the end */ memcpy (cp, &device_desc, sizeof device_desc); cp += sizeof device_desc; status = write (fd, &buf [0], cp - &buf [0]); if (status < 0) { perror ("write dev descriptors"); close (fd); return status; } else if (status != (cp - buf)) { fprintf (stderr, "dev init, wrote %d expected %d\n", status, cp - buf); close (fd); return -EIO; } return fd; }
static void serial8250_config_port(struct uart_port *port, int flags) { struct uart_8250_port *up = (struct uart_8250_port *)port; struct resource *res_std = NULL, *res_rsa = NULL; int probeflags = PROBE_ANY; probeflags &= ~PROBE_RSA; if (flags & UART_CONFIG_TYPE) autoconfig(up, probeflags); /* * If the port wasn't an RSA port, release the resource. */ if (up->port.type != PORT_RSA && res_rsa) release_resource(res_rsa); if (up->port.type == PORT_UNKNOWN && res_std) release_resource(res_std); }