From nobody Fri May 06 21:44:11 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 34F031AD459C; Fri, 6 May 2022 21:44:12 +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 4Kw3x80YHZz3nPC; Fri, 6 May 2022 21:44:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651873452; 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=Va/IzLv3QdtRpfVs25ym/UxaFAZ+NmVnccZ3lRupEo0=; b=hjJujGmTOeMWIajkjezURKx15fuQXwmrOC7pZ4tmqStbhbu0DNyMw8XSlZCbBOW/FsiOZd b/JfViFSXKr0pQGD00J84GTi+Ey5hFNT8z/AOV4l3eorT/2qXQ+Dd4r6zlq1WB+nSuflBa Cln0PA0ZoFe3Yt7zDaimuRpTSyiNaIr970oRV/5hd3Velu4AGhpHUZ5njc7LoIpRvKJ45g smFedx9DvPLNhTabfZEoIqAnKSXewg3Pj4kfyJPlwxH3WCatC7ecWyNJEy0dzv8IZT5tTG Yz9Ra648aLx7MYjwzP2oZV0N4vTTihE4hpUh2mSY1y+gTcHlmbQ9Gq7RTmpnwA== 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 DE3DD23D7C; Fri, 6 May 2022 21:44:11 +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 246LiB2l037608; Fri, 6 May 2022 21:44:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 246LiBfS037607; Fri, 6 May 2022 21:44:11 GMT (envelope-from git) Date: Fri, 6 May 2022 21:44:11 GMT Message-Id: <202205062144.246LiBfS037607@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 45dc8e3c2c62 - main - nvdimm: Use devclass_lookup to find devclasses. 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/main X-Git-Reftype: branch X-Git-Commit: 45dc8e3c2c625040433f53d1ab987be68e17e4d3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651873452; 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=Va/IzLv3QdtRpfVs25ym/UxaFAZ+NmVnccZ3lRupEo0=; b=DFa1Uto6/N2xAaVBq5Ah4ZdTdvXvq0L7NG5lALg6VH62n98S/1mTeXU9FGPbCoptmC+Itu X8GEe8nZVcR1RUso3lhr55s5+EcUaB5jZnGGBNqwxh8tE33fmDeP8ht3uEYG1hjXV6kVnt ZJYZfnEnl9p069QwkwZ+utJmUABzV2dLOu29dMCPa35O18A6PsM+vluIuZ96IviMDKKCfm NzRKuavbDwXqNXF2yYqTARFXYh+EF96JErxjYfOEQgxKnLSejapOpR6VvtUbbiKyi+aoZW YvdHBwxNGuEOGfSSGCdgsJOi7crIdt3aSVeAs/bEsOn7WLAS8WoOzQbsbovHlA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651873452; a=rsa-sha256; cv=none; b=gWckESMqPe5FrJmkMw+yXiE9ND6BFrfiVWtsqqvshpKfoLdRb2hVzuJst8rTQz2UI2ArkQ AHHNcULmxix9C5yvpDvNG6Es5Qv0AVoo6uEu/ZcFCPRRED5gApQLZPkU30SHPVV8FUx8ev aL5C7tptdD3B9pdHjXsb5jRnVHM29YA01vLS8biFnCX+C9fi08EOHxXcgg0VWN4qlAzyHq 3XwGsnX1jbizuNCqHqBEvPgdL48XupFeszzqNYZ1uILeadCgrNjHRcoUhHX6Yb5pvTOAJi KV+nPs+++gBi7U2lN3Vzd9c6pV9mAI5CLjdDmt1yoH0XTjXbAMAnOpls2t08Og== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=45dc8e3c2c625040433f53d1ab987be68e17e4d3 commit 45dc8e3c2c625040433f53d1ab987be68e17e4d3 Author: John Baldwin AuthorDate: 2022-05-06 21:41:42 +0000 Commit: John Baldwin CommitDate: 2022-05-06 21:41:42 +0000 nvdimm: Use devclass_lookup to find devclasses. To avoid hardcoding the nvdimm driver name, move nvdimm_find_by_handle below the definition of nvdimm_driver. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D35062 --- sys/dev/nvdimm/nvdimm.c | 43 ++++++++++++++++++++++--------------------- sys/dev/nvdimm/nvdimm_e820.c | 2 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sys/dev/nvdimm/nvdimm.c b/sys/dev/nvdimm/nvdimm.c index a5692fc65857..730fd49fef27 100644 --- a/sys/dev/nvdimm/nvdimm.c +++ b/sys/dev/nvdimm/nvdimm.c @@ -301,27 +301,6 @@ read_labels(struct nvdimm_dev *nv) return (0); } -struct nvdimm_dev * -nvdimm_find_by_handle(nfit_handle_t nv_handle) -{ - struct nvdimm_dev *res; - device_t *dimms; - int i, error, num_dimms; - - res = NULL; - error = devclass_get_devices(nvdimm_devclass, &dimms, &num_dimms); - if (error != 0) - return (NULL); - for (i = 0; i < num_dimms; i++) { - if (nvdimm_root_get_device_handle(dimms[i]) == nv_handle) { - res = device_get_softc(dimms[i]); - break; - } - } - free(dimms, M_TEMP); - return (res); -} - static int nvdimm_probe(device_t dev) { @@ -468,6 +447,28 @@ static driver_t nvdimm_driver = { sizeof(struct nvdimm_dev), }; +struct nvdimm_dev * +nvdimm_find_by_handle(nfit_handle_t nv_handle) +{ + struct nvdimm_dev *res; + device_t *dimms; + int i, error, num_dimms; + + res = NULL; + error = devclass_get_devices(devclass_find(nvdimm_driver.name), &dimms, + &num_dimms); + if (error != 0) + return (NULL); + for (i = 0; i < num_dimms; i++) { + if (nvdimm_root_get_device_handle(dimms[i]) == nv_handle) { + res = device_get_softc(dimms[i]); + break; + } + } + free(dimms, M_TEMP); + return (res); +} + DRIVER_MODULE(nvdimm, nvdimm_acpi_root, nvdimm_driver, nvdimm_devclass, NULL, NULL); MODULE_DEPEND(nvdimm, acpi, 1, 1, 1); diff --git a/sys/dev/nvdimm/nvdimm_e820.c b/sys/dev/nvdimm/nvdimm_e820.c index 66bdff937dc5..97f825004ed0 100644 --- a/sys/dev/nvdimm/nvdimm_e820.c +++ b/sys/dev/nvdimm/nvdimm_e820.c @@ -367,7 +367,7 @@ nvdimm_e820_chainevh(struct module *m, int e, void *arg __unused) switch (e) { case MOD_UNLOAD: - dc = nvdimm_e820_devclass; + dc = devclass_find(nvdimm_e820_driver.name); maxunit = devclass_get_maxunit(dc); for (i = 0; i < maxunit; i++) { dev = devclass_get_device(dc, i);