From nobody Fri May 20 00:21:00 2022 X-Original-To: dev-commits-src-branches@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 0FF5A1B40650; Fri, 20 May 2022 00:21:02 +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 4L46p55172z3l6h; Fri, 20 May 2022 00:21:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653006061; 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=UAJjuAO9zkqbmDC+B9+IH3QWHgN+WZeUcmibWwPkVNk=; b=ylOVAhtdaN0uIUuc0iDpTGKQrbJnHfrQtjTXSzs7DO24Tqtz+DcIHq2mi/QgJv3Ilv81nQ t+U8EjBXZMpeYMRP7mUXZh/ICCoMPy4CUmKlHLMMFd2FpTB1I8nWL5b91qgqnKLVIF+tW1 tHH26NPMhHMf2wUrBipnEY6MSmFxjXs4ffh/9SUhyP6GCfNTcCztGpbYDdlSpnWyPVAIkJ b8VYIAg7XmSSBQXUeyInAu93LGwg5euE0b+cDwKoAaY9LxCKQvDL1b3h+U2zA95JBJPIC6 mAPjKKaGIvVOcrwxMsK1IMZ9LxiU+HV9pUelc6Y/VxSye4OrBYHc0rgYtKTSGQ== 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 AF5C127C8E; Fri, 20 May 2022 00:21:00 +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 24K0L0DT071860; Fri, 20 May 2022 00:21:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24K0L0R7071859; Fri, 20 May 2022 00:21:00 GMT (envelope-from git) Date: Fri, 20 May 2022 00:21:00 GMT Message-Id: <202205200021.24K0L0R7071859@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: c7f0b91ba269 - stable/13 - smapi: Store softc pointer in si_drv1 of cdev. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: c7f0b91ba2693e50f32402e1094f51c6431b4768 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653006061; 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=UAJjuAO9zkqbmDC+B9+IH3QWHgN+WZeUcmibWwPkVNk=; b=xLJurnCg1NVIJBRpvJ2k0Tjr8p6Q1P+rCqzQX7HJY5ckLEzN37NMoDXE4HW4yzIwjaZim7 u4SZsQ/RWhNiWcAdfYGbZ3/vt8rkwmope2PnnDodgsGCjBK3XCFJ71wIMBub500MQ86kqL WAIZB3GMOE3V6v2V9nVv4Ma9gVK2js9WYnecjvRhww2UoS4n81yqr3W9gwJ0vNF5CctN/0 J6OCe2TyrfRcInV2Dz1iO/30z5gRyJuoMPXbYCt3Jz/1c3v3JJ4B6cmtcgjcaCEgZSMKlx UmUuWP+7bV7rTG52XVrcSO0oiHv1j4exG++eaCytRtqBe6Exk7NcFskAUCXUEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653006061; a=rsa-sha256; cv=none; b=qFJvDXFogDnJ5ZGiPVstLwOEQbSD3xyOvutucyAnacWrsl8eu9fG/FYq0f54rpZptXctou BF5ghTaCI4QRJe/DVbCAwpOEiTaji4MLVmDNe7Tys68jpTYoyh6ONPccVIHJXDaN0OBXVW YdVcFHA/luK+WVQ+LIKRsNTAx5lSNrCJAAkrXjXTawW5qGn0+Su/BN3NKPZJj7SNoDo/Xw q0LFDk2UUaghyMirRIVnRDL+puA9hW9MyJG9GEB3Q0YsXuenCukoHWWx15gDVvpPVCSTc5 9G2fnJQKpHGgA0zIW8Ekp+9kp23nitPhy8hqrukSZ6zExTvbtUxErYirJ+YDOA== 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=c7f0b91ba2693e50f32402e1094f51c6431b4768 commit c7f0b91ba2693e50f32402e1094f51c6431b4768 Author: John Baldwin AuthorDate: 2022-05-05 23:35:19 +0000 Commit: John Baldwin CommitDate: 2022-05-19 22:01:50 +0000 smapi: Store softc pointer in si_drv1 of cdev. Rather than fetching the softc using the device's unit number as an index into the devclass. Differential Revision: https://reviews.freebsd.org/D35063 (cherry picked from commit d4f988e1886fee0c89443b6937bf47b6439f80b0) --- sys/i386/bios/smapi.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sys/i386/bios/smapi.c b/sys/i386/bios/smapi.c index 5b82df87e980..653399e1ca58 100644 --- a/sys/i386/bios/smapi.c +++ b/sys/i386/bios/smapi.c @@ -102,16 +102,9 @@ extern int smapi32_new(u_long, u_short, static int smapi_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) { - struct smapi_softc *sc; + struct smapi_softc *sc = dev->si_drv1; int error; - error = 0; - sc = devclass_get_softc(smapi_devclass, dev2unit(dev)); - if (sc == NULL) { - error = ENXIO; - goto fail; - } - switch (cmd) { case SMAPIOGHEADER: bcopy((caddr_t)sc->header, data, @@ -127,7 +120,6 @@ smapi_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct threa error = ENOTTY; } -fail: return (error); } @@ -204,6 +196,7 @@ bad: static int smapi_attach (device_t dev) { + struct make_dev_args args; struct smapi_softc *sc; int error; @@ -224,12 +217,17 @@ smapi_attach (device_t dev) sc->header->prot32_segment + sc->header->prot32_offset); - sc->cdev = make_dev(&smapi_cdevsw, - device_get_unit(sc->dev), - UID_ROOT, GID_WHEEL, 0600, - "%s%d", + make_dev_args_init(&args); + args.mda_devsw = &smapi_cdevsw; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_WHEEL; + args.mda_mode = 0600; + args.mda_si_drv1 = sc; + error = make_dev_s(&args, &sc->cdev, "%s%d", smapi_cdevsw.d_name, device_get_unit(sc->dev)); + if (error != 0) + goto bad; device_printf(dev, "Version: %d.%02d, Length: %d, Checksum: 0x%02x\n", bcd2bin(sc->header->version_major),