Date: Fri, 4 Jul 2008 13:15:14 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 144613 for review Message-ID: <200807041315.m64DFEZJ011475@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144613 Change 144613 by hselasky@hselasky_laptop001 on 2008/07/04 13:14:56 Take advantage of new kernel symlink support. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#10 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#5 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#10 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.h#4 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#10 (text+ko) ==== @@ -453,10 +453,19 @@ void usb2_fifo_free(struct usb2_fifo *f) { + uint8_t n; + if (f == NULL) { /* be NULL safe */ return; } + /* destroy symlink devices, if any */ + for (n = 0; n != 2; n++) { + if (f->symlink[n]) { + destroy_dev(f->symlink[n]); + f->symlink[n] = NULL; + } + } mtx_lock(&usb2_ref_lock); /* delink ourselves to stop calls from userland */ @@ -1666,7 +1675,7 @@ mtx_unlock(&usb2_ref_lock); if (snprintf(src, sizeof(src), - "/dev/" USB_DEVICE_NAME "%u.%u.%u.%u", + USB_DEVICE_NAME "%u.%u.%u.%u", device_get_unit(udev->bus->bdev), udev->device_index, iface_index, @@ -1680,27 +1689,31 @@ } if (subunit == 0xFFFF) { if (snprintf(buf, sizeof(buf), - "/dev/%s%u%s", pm->basename[n], + "%s%u%s", pm->basename[n], unit, pm->postfix[n] ? pm->postfix[n] : "")) { /* ignore */ } } else { if (snprintf(buf, sizeof(buf), - "/dev/%s%u.%u%s", pm->basename[n], + "%s%u.%u%s", pm->basename[n], unit, subunit, pm->postfix[n] ? pm->postfix[n] : "")) { /* ignore */ } } - if (kern_unlink(curthread, buf, UIO_SYSSPACE)) { - /* ignore */ + /* + * Distribute the symbolic links into two FIFO structures: + */ + if (n & 1) { + f_rx->symlink[n / 2] = + make_dev_symlink(src, "%s", buf); + } else { + f_tx->symlink[n / 2] = + make_dev_symlink(src, "%s", buf); } - if (kern_symlink(curthread, src, buf, UIO_SYSSPACE)) { - /* ignore */ - } - printf("Symlink: %s -> %s\n", buf, src); + DPRINTF(0, "Symlink: %s -> %s\n", buf, src); } DPRINTF(1, "attached %p/%p\n", f_tx, f_rx); ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#5 (text+ko) ==== @@ -72,6 +72,7 @@ struct cv cv_io; struct cv cv_drain; struct usb2_fifo_methods *methods; + struct cdev *symlink[2]; /* our symlinks */ struct proc *async_p; /* process that wants SIGIO */ struct usb2_device *udev; struct usb2_xfer *xfer[2]; ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#10 (text+ko) ==== @@ -28,6 +28,7 @@ #include <dev/usb2/include/usb2_error.h> #include <dev/usb2/include/usb2_standard.h> #include <dev/usb2/include/usb2_revision.h> +#include <dev/usb2/include/usb2_ioctl.h> #define USB_DEBUG_VAR usb2_debug @@ -1582,6 +1583,22 @@ usb2_bus_port_set_device(bus, parent_hub ? parent_hub->hub->ports + port_index : NULL, udev, device_index); + /* make a symlink for UGEN */ + if (snprintf(scratch_ptr, scratch_size, + USB_DEVICE_NAME "%u.%u.0.0", + device_get_unit(udev->bus->bdev), + udev->device_index)) { + /* ignore */ + } + udev->ugen_symlink = + make_dev_symlink(scratch_ptr, "ugen%u.%u", + device_get_unit(udev->bus->bdev), + udev->device_index); + + printf("ugen%u.%u: <%s> at %s\n", + device_get_unit(udev->bus->bdev), + udev->device_index, udev->manufacturer, + device_get_nameunit(udev->bus->bdev)); done: if (err) { /* free device */ @@ -1610,6 +1627,13 @@ bus = udev->bus; /* + * Destroy UGEN symlink, if any + */ + if (udev->ugen_symlink) { + destroy_dev(udev->ugen_symlink); + udev->ugen_symlink = NULL; + } + /* * Unregister our device first which will prevent any further * references: */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.h#4 (text+ko) ==== @@ -108,6 +108,7 @@ struct usb2_temp_data *usb2_template_ptr; struct usb2_pipe *pipe_curr; /* current clear stall pipe */ struct usb2_fifo *fifo[USB_FIFO_MAX]; + struct cdev *ugen_symlink; /* our generic symlink */ uint16_t refcount; #define USB_DEV_REF_MAX 0xffff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807041315.m64DFEZJ011475>