From owner-p4-projects@FreeBSD.ORG Fri Jul 4 13:15:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 50E901065733; Fri, 4 Jul 2008 13:15:15 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA4311065676 for ; Fri, 4 Jul 2008 13:15:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D877D8FC19 for ; Fri, 4 Jul 2008 13:15:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m64DFEjN011477 for ; Fri, 4 Jul 2008 13:15:14 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m64DFEZJ011475 for perforce@freebsd.org; Fri, 4 Jul 2008 13:15:14 GMT (envelope-from hselasky@FreeBSD.org) Date: Fri, 4 Jul 2008 13:15:14 GMT Message-Id: <200807041315.m64DFEZJ011475@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 144613 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jul 2008 13:15:15 -0000 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 #include #include +#include #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