Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp213036lqp; Mon, 10 Jun 2024 01:20:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyC/ZRxN0WJMLXdu5pLK3lt1lbzcwNs05Dy4OhYvXhi60/q2jGvfijZiZmL2ajeZpn445YmQnBKlbquuurmMZUXFWBnCqHVfC2joo5cg== X-Google-Smtp-Source: AGHT+IEC/NCTa27x+sOohqZ1gEiq3UBeqkqcZdrfGM8kRUdJGHPJas28StSxO7QOe8OhYZa5DOwQ X-Received: by 2002:a17:906:a38f:b0:a6f:1e88:37c1 with SMTP id a640c23a62f3a-a6f1e883daemr129286066b.45.1718007612655; Mon, 10 Jun 2024 01:20:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718007612; cv=pass; d=google.com; s=arc-20160816; b=YrSydNgaljwRjx0hg4Msln4yGlAY9SWD8pclkDRZ9ReL8Q+0s0MvFV00VcDqsTjIeb a0UCONo9Rj3xeZ9gcrUJgx9yPeHbZQ+Gx1jJNwNrRp8hH6uNsl4p4R9yAzBqw9tb301j r9T0cqKYJwcuTYzjEWxD6Ho/jL/Sz+rGsGswMoC+HFoO/XMMhZB6xace0wlTCnnLoWZX fr5A3q0x6aa2HqdISwQCIUWE5VYegBAckMuRwaTRzYLEu17fxo/7lNB9we0B3lAwFetJ N54G2NDNx+/rFw1ZoRBjO5NVtkRKxvfRYvZJN7XJHqi5ZyZW0y+EEM4u13TNgyg3SLmx Gakw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=mFaOAIolvjtL4lnpS9IovI+qgab9S27tESh3B+HrYvg=; fh=gAMhCtF7aoGsP9EsbMmdyVC9nY3f+aZ/WYjXVL/HAD4=; b=arFfpeGo0PQy3N/yg1FsdfRq5kwra+g4z+KRokaNWWq+iQRoyixH2U9xwd3vZ6XGAL FpgTGdjhvs+bT5kKf8yyMvC5A5m3u+AuTKlLvmWLoAzuENWVBHkwtoahZ9Jq9VClQF5o 4GanMaRKec4eTqy6uwiBY9ffwqUB0L5EaCoFZ1rkRcWrEGqwh1SMCjDR6O2ji+OklQlp uJCq00+ysa7JkbpjGmGP48KDx0quP8FSvj+gIv/yHvO49dFY/y9yXblT5beZQ06HnngB EpeyvcqvfwFlejUkNNicZ41oOFGEMDlE4DOvpLfATCUb2SzSXHmqvNUpd2fhOORnb3l9 HXWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WQ1p7ErO; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c807484b7si440476866b.915.2024.06.10.01.20.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 01:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WQ1p7ErO; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E602D1F20FFA for ; Mon, 10 Jun 2024 08:20:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 331FD6F317; Mon, 10 Jun 2024 08:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WQ1p7ErO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49C446F2E8; Mon, 10 Jun 2024 08:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718007589; cv=none; b=dLRwudk8nnxtTqT5E+rLBLzqk969cUf/UHr0Qfc9VE6L/lFB4OsN8vfxxY7uBAKbyCwxbDlS31Rl4LE4oipuKbDPGpoBqI9aj+MZ0kVFq9KouHUXOCiAAogS//0A4u5F1a/zV+MCe/oEkhHgRSHyJfQIns8dYzAUCnkRJu7YTIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718007589; c=relaxed/simple; bh=4bnhfABeL9wMNaLRFs7jfMOSG8cNLfTLCbFckvsvrM0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Xeof4Z+2eCz1kVdn6tAYsi71irZM2+cMwOda2PmunLrbduVdH45K1sla8EVq6SYYCCNoWGs3Y4RXfcmgV0qj0rJH7UoqKFqq6e1IH5cXa+2y0gteKGOnHOhl+EVfxwVYwlugnegJ1HROnFJ1BpuaP0ouZ3LQbUbW16+ADFiC+h0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WQ1p7ErO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 631C2C4AF1C; Mon, 10 Jun 2024 08:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718007588; bh=4bnhfABeL9wMNaLRFs7jfMOSG8cNLfTLCbFckvsvrM0=; h=From:To:Cc:Subject:Date:From; b=WQ1p7ErOzdBl73QtueAUgSo46u2ijPYial0jcb6VgRtkEISzyHUenvwC7eyqnhLEO LCLuFqra1fXV4tzOspxnuo6YMmUZVQnNonjEx3EqAHgPHmZvT6R0iXlxnLAfsp7UJR bwxnOwzVfoUMCv85ky7xeXGVMIQ7QYTiA98P8wSw= From: Greg Kroah-Hartman To: nvdimm@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny Subject: [PATCH] nvdimm: make nd_class constant Date: Mon, 10 Jun 2024 10:19:42 +0200 Message-ID: <2024061041-grandkid-coherence-19b0@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 85 X-Developer-Signature: v=1; a=openpgp-sha256; l=2634; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=4bnhfABeL9wMNaLRFs7jfMOSG8cNLfTLCbFckvsvrM0=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlp2+XWaj/ozZMQO/pcs9CCa/38o18cnyXXKCol/Vd6d X51jU9iRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzkVx3DgtaXW6/9E/5d2Lbj bzgfr0mncfHCBoZ5OnNs7oYrnXqUdV3y/7nw2THMfHUHAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Now that the driver core allows for struct class to be in read-only memory, we should make all 'class' structures declared at build time placing them into read-only memory, instead of having to be dynamically allocated at runtime. Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Cc: nvdimm@lists.linux.dev Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/bus.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 508aed017ddc..101c425f3e8b 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -25,9 +25,12 @@ int nvdimm_major; static int nvdimm_bus_major; -static struct class *nd_class; static DEFINE_IDA(nd_ida); +static const struct class nd_class = { + .name = "nd", +}; + static int to_nd_device_type(const struct device *dev) { if (is_nvdimm(dev)) @@ -742,7 +745,7 @@ int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus) device_initialize(dev); lockdep_set_class(&dev->mutex, &nvdimm_ndctl_key); device_set_pm_not_required(dev); - dev->class = nd_class; + dev->class = &nd_class; dev->parent = &nvdimm_bus->dev; dev->devt = devt; dev->release = ndctl_release; @@ -765,7 +768,7 @@ int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus) void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus) { - device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); + device_destroy(&nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); } static const struct nd_cmd_desc __nd_cmd_dimm_descs[] = { @@ -1320,11 +1323,9 @@ int __init nvdimm_bus_init(void) goto err_dimm_chrdev; nvdimm_major = rc; - nd_class = class_create("nd"); - if (IS_ERR(nd_class)) { - rc = PTR_ERR(nd_class); + rc = class_register(&nd_class); + if (rc) goto err_class; - } rc = driver_register(&nd_bus_driver.drv); if (rc) @@ -1333,7 +1334,7 @@ int __init nvdimm_bus_init(void) return 0; err_nd_bus: - class_destroy(nd_class); + class_unregister(&nd_class); err_class: unregister_chrdev(nvdimm_major, "dimmctl"); err_dimm_chrdev: @@ -1347,7 +1348,7 @@ int __init nvdimm_bus_init(void) void nvdimm_bus_exit(void) { driver_unregister(&nd_bus_driver.drv); - class_destroy(nd_class); + class_unregister(&nd_class); unregister_chrdev(nvdimm_bus_major, "ndctl"); unregister_chrdev(nvdimm_major, "dimmctl"); bus_unregister(&nvdimm_bus_type); -- 2.45.2