From owner-svn-src-all@freebsd.org Sat Dec 3 01:55:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF23BC633A5; Sat, 3 Dec 2016 01:55:39 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99DB01D8; Sat, 3 Dec 2016 01:55:39 +0000 (UTC) (envelope-from loos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB31tc25039225; Sat, 3 Dec 2016 01:55:38 GMT (envelope-from loos@FreeBSD.org) Received: (from loos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB31tcUq039224; Sat, 3 Dec 2016 01:55:38 GMT (envelope-from loos@FreeBSD.org) Message-Id: <201612030155.uB31tcUq039224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: loos set sender to loos@FreeBSD.org using -f From: Luiz Otavio O Souza Date: Sat, 3 Dec 2016 01:55:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309461 - head/sys/dev/etherswitch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2016 01:55:39 -0000 Author: loos Date: Sat Dec 3 01:55:38 2016 New Revision: 309461 URL: https://svnweb.freebsd.org/changeset/base/309461 Log: Allow simultaneous access to switch device, there is no reason to prevent it. Remove bogus wrappers and use the kernel defaults. While here, use DEVMETHOD_END. Obtained from: pfSense MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Modified: head/sys/dev/etherswitch/etherswitch.c Modified: head/sys/dev/etherswitch/etherswitch.c ============================================================================== --- head/sys/dev/etherswitch/etherswitch.c Sat Dec 3 01:14:21 2016 (r309460) +++ head/sys/dev/etherswitch/etherswitch.c Sat Dec 3 01:55:38 2016 (r309461) @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -45,19 +44,11 @@ #include "etherswitch_if.h" -#define BUFSIZE 1024 - struct etherswitch_softc { device_t sc_dev; - int sc_count; - struct cdev *sc_devnode; - struct sx sc_lock; }; -#define SWITCH_LOCK(sc) sx_xlock(&(sc)->sc_lock) -#define SWITCH_UNLOCK(sc) sx_xunlock(&(sc)->sc_lock) - static int etherswitch_probe(device_t); static int etherswitch_attach(device_t); static int etherswitch_detach(device_t); @@ -72,7 +63,7 @@ static device_method_t etherswitch_metho DEVMETHOD(device_attach, etherswitch_attach), DEVMETHOD(device_detach, etherswitch_detach), - { 0, 0 } + DEVMETHOD_END }; driver_t etherswitch_driver = { @@ -81,19 +72,11 @@ driver_t etherswitch_driver = { sizeof(struct etherswitch_softc), }; -static d_open_t etherswitchopen; -static d_close_t etherswitchclose; -static d_write_t etherswitchwrite; -static d_read_t etherswitchread; static d_ioctl_t etherswitchioctl; static struct cdevsw etherswitch_cdevsw = { .d_version = D_VERSION, .d_flags = D_TRACKCLOSE, - .d_open = etherswitchopen, - .d_close = etherswitchclose, - .d_read = etherswitchread, - .d_write = etherswitchwrite, .d_ioctl = etherswitchioctl, .d_name = "etherswitch", }; @@ -119,13 +102,11 @@ etherswitch_attach(device_t dev) struct etherswitch_softc *sc = (struct etherswitch_softc *)device_get_softc(dev); sc->sc_dev = dev; - sx_init(&sc->sc_lock, "etherswitch"); sc->sc_devnode = make_dev(ðerswitch_cdevsw, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, "etherswitch%d", device_get_unit(dev)); if (sc->sc_devnode == NULL) { device_printf(dev, "failed to create character device\n"); - sx_destroy(&sc->sc_lock); return (ENXIO); } sc->sc_devnode->si_drv1 = sc; @@ -140,61 +121,11 @@ etherswitch_detach(device_t dev) if (sc->sc_devnode) destroy_dev(sc->sc_devnode); - sx_destroy(&sc->sc_lock); - - return (0); -} - -static int -etherswitchopen(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - struct etherswitch_softc *sc = dev->si_drv1; - - SWITCH_LOCK(sc); - if (sc->sc_count > 0) { - SWITCH_UNLOCK(sc); - return (EBUSY); - } - - sc->sc_count++; - SWITCH_UNLOCK(sc); - - return (0); -} - -static int -etherswitchclose(struct cdev *dev, int flags, int fmt, struct thread *td) -{ - struct etherswitch_softc *sc = dev->si_drv1; - - SWITCH_LOCK(sc); - if (sc->sc_count == 0) { - SWITCH_UNLOCK(sc); - return (EINVAL); - } - - sc->sc_count--; - - if (sc->sc_count < 0) - panic("%s: etherswitch_count < 0!", __func__); - SWITCH_UNLOCK(sc); return (0); } static int -etherswitchwrite(struct cdev *dev, struct uio * uio, int ioflag) -{ - return (EINVAL); -} - -static int -etherswitchread(struct cdev *dev, struct uio * uio, int ioflag) -{ - return (EINVAL); -} - -static int etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct thread *td) { struct etherswitch_softc *sc = cdev->si_drv1;