From nobody Fri May 20 00:21:01 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 592A71B40840; Fri, 20 May 2022 00:21:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L46p65Vpyz3kr2; Fri, 20 May 2022 00:21:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653006063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/wLEZh1icP+SXi+cQgXpz+HqN0/2jrZ783bLoTQky4U=; b=bISddHmqTby/9IF6d9I/JKC5wWkIKC8ddwqHJqA4xMcSI8e0hB2zCwDfWyKrJ9Ts1g90mc 0Trpz8lID/hKQJdSFls5xgK/TFSnegP5RZJOpPJIv0W6zD0pXrotnAcBrrjBa3V7sSDLw5 u01/xLqB0zMSLnv6V7D2On/XWKgY3oblU6tz7EPe9I21V0ShMEzKrFEHQFFhsBDs8/D3t2 2V3cGuJNkIFw9Ja30H57BjdX4MzdDKYC8jQmzkvBorBfCoUyJJiymQIEeKAIdKuH0dAPyV cqPtl6wTV5gkIv7P7WEuF7gShQVe/rDlpGfvIaWaWwcBj/We1b7+aYTuIBVf/g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C7A9027BBE; Fri, 20 May 2022 00:21:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24K0L1DS071884; Fri, 20 May 2022 00:21:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24K0L1pQ071883; Fri, 20 May 2022 00:21:01 GMT (envelope-from git) Date: Fri, 20 May 2022 00:21:01 GMT Message-Id: <202205200021.24K0L1pQ071883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: f02bf967fcd3 - stable/13 - pbio: Store softc in si_drv1 for character devices. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f02bf967fcd3e6e544aa08c014ec0fabc1714aad Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653006063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/wLEZh1icP+SXi+cQgXpz+HqN0/2jrZ783bLoTQky4U=; b=hrxtXnx1YH9hzFOMFslDBcuELS6w9L2GtGwCai2U1to2Y4yNMkfqcQL/t8bHzgz4o5jM6e i1qy61yS/wm9E1y/AHwGcpER6lIqJPsVdHlhvuaPcbtf9w0CzQMW4tX29vOlQ0UZIFKCGx ZMhWyKUhJChA3nS207JAuAjUn0M+OHdjb9zGSJ1yFPytg1tGdYbL6gvvc7Haimt5yMViEV WVOnHN1mvvaOb38NonQovmPg+7AObKfIlFqZtdQ8p9cGXiYAN20H6P1F8ZYx3mKiOU8Tlc qrvSE6JxjL/YS+pK7V0+g+45DikHcGADecSMOPpI9k013orjul3vLHXlh3FTFQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653006063; a=rsa-sha256; cv=none; b=LI9Flf26l5vJfxFw/oDq98R8uKQ+Yg+++PdqkKryXEhAvw90zd0SY5nFPP4SJucB48DRvn DN4JpS57kBPVEpBJoRrRcoZlz/fMMOxX0Q/w5UmtDPDPdGjvpEjx79q/A2u1fvsC/0I8+5 7+GBYlksc9m1Q5Rw4WNiJfjFdsySdfVISwgodrKPxuSwehQB9vUq5OOsgk5Ox8GofD9ymY eSrqKgmtYSvvGPMcz+bb/e7uNpfNzjdUuNvXZuGQYwpGWe4+1iNZFxCiPSDsynNFvSCZ4M Gdqj/6ej+bydEnxLkexyuc7zoYUy2DhsdHusc4GfYC5x2OiuUSfN9FBj+Vaeog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f02bf967fcd3e6e544aa08c014ec0fabc1714aad commit f02bf967fcd3e6e544aa08c014ec0fabc1714aad Author: John Baldwin AuthorDate: 2022-05-05 23:38:25 +0000 Commit: John Baldwin CommitDate: 2022-05-19 22:01:50 +0000 pbio: Store softc in si_drv1 for character devices. The port number is still stored in the unit (si_drv0) but is the entire unit value now. While here, removed checks for NULL softc since those can never happen from cdevsw routines. This also resulted in the close method becoming a no-op, so it has been removed. Differential Revision: https://reviews.freebsd.org/D35078 (cherry picked from commit 0db65574bbb9e379ebf3ce027fc7607fdc9118fd) --- sys/dev/pbio/pbio.c | 74 +++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 51 deletions(-) diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c index 4b5f0e9fc819..042a92e39f42 100644 --- a/sys/dev/pbio/pbio.c +++ b/sys/dev/pbio/pbio.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); /* Function prototypes (these should all be static) */ static d_open_t pbioopen; -static d_close_t pbioclose; static d_read_t pbioread; static d_write_t pbiowrite; static d_ioctl_t pbioioctl; @@ -81,8 +80,9 @@ static char *port_names[] = {"a", "b", "ch", "cl"}; #define PBIO_PNAME(n) (port_names[(n)]) -#define UNIT(dev) (dev2unit(dev) >> 2) -#define PORT(dev) (dev2unit(dev) & 0x3) +#define PORT(dev) (dev2unit(dev)) + +#define pbio_addr(dev) ((dev)->si_drv1) #define PBIOPRI ((PZERO + 5) | PCATCH) @@ -90,7 +90,6 @@ static struct cdevsw pbio_cdevsw = { .d_version = D_VERSION, .d_flags = D_NEEDGIANT, .d_open = pbioopen, - .d_close = pbioclose, .d_read = pbioread, .d_write = pbiowrite, .d_ioctl = pbioioctl, @@ -132,8 +131,6 @@ static device_method_t pbio_methods[] = { }; static devclass_t pbio_devclass; -#define pbio_addr(unit) \ - ((struct pbio_softc *) devclass_get_softc(pbio_devclass, unit)) static char driver_name[] = "pbio"; @@ -218,6 +215,7 @@ pbioprobe(device_t dev) static int pbioattach (device_t dev) { + struct make_dev_args args; int unit; int i; int rid; @@ -238,9 +236,17 @@ pbioattach (device_t dev) */ sc->iomode = 0x9b; /* All ports to input */ - for (i = 0; i < PBIO_NPORTS; i++) - sc->pd[i].port = make_dev(&pbio_cdevsw, (unit << 2) + i, 0, 0, - 0600, "pbio%d%s", unit, PBIO_PNAME(i)); + for (i = 0; i < PBIO_NPORTS; i++) { + make_dev_args_init(&args); + args.mda_devsw = &pbio_cdevsw; + args.mda_uid = 0; + args.mda_gid = 0; + args.mda_mode = 0600; + args.mda_unit = i; + args.mda_si_drv1 = sc; + (void)make_dev_s(&args, &sc->pd[i].port, "pbio%d%s", unit, + PBIO_PNAME(i)); + } return (0); } @@ -249,13 +255,10 @@ pbioioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) { struct pbio_softc *scp; - int port, unit; + int port; - unit = UNIT(dev); port = PORT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); + scp = pbio_addr(dev); switch (cmd) { case PBIO_SETDIFF: scp->pd[port].diff = *(int *)data; @@ -285,14 +288,11 @@ static int pbioopen(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct pbio_softc *scp; - int ocfg, port, unit; + int ocfg, port; int portbit; /* Port configuration bit */ - unit = UNIT(dev); port = PORT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); + scp = pbio_addr(dev); switch (port) { case 0: portbit = 0x10; break; /* Port A */ @@ -315,20 +315,6 @@ pbioopen(struct cdev *dev, int oflags, int devtype, struct thread *td) return (0); } -static int -pbioclose(struct cdev *dev, int fflag, int devtype, struct thread *td) -{ - struct pbio_softc *scp; - int unit; - - unit = UNIT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); - - return (0); -} - /* * Return the value of a given port on a given I/O base address * Handles the split C port nibbles and blocking @@ -374,14 +360,11 @@ static int pbioread(struct cdev *dev, struct uio *uio, int ioflag) { struct pbio_softc *scp; - int err, i, port, ret, toread, unit; + int err, i, port, ret, toread; char val; - unit = UNIT(dev); port = PORT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); + scp = pbio_addr(dev); while (uio->uio_resid > 0) { toread = min(uio->uio_resid, PBIO_BUFSIZ); @@ -403,14 +386,11 @@ static int pbiowrite(struct cdev *dev, struct uio *uio, int ioflag) { struct pbio_softc *scp; - int i, port, ret, towrite, unit; + int i, port, ret, towrite; char val, oval; - unit = UNIT(dev); port = PORT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); + scp = pbio_addr(dev); while (uio->uio_resid > 0) { towrite = min(uio->uio_resid, PBIO_BUFSIZ); @@ -450,14 +430,6 @@ pbiowrite(struct cdev *dev, struct uio *uio, int ioflag) static int pbiopoll(struct cdev *dev, int which, struct thread *td) { - struct pbio_softc *scp; - int unit; - - unit = UNIT(dev); - scp = pbio_addr(unit); - if (scp == NULL) - return (ENODEV); - /* * Do processing */