From nobody Sat Feb 7 21:53:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60F3EEB64DB for ; Tue, 20 Jun 2023 18:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbjFTSe6 (ORCPT ); Tue, 20 Jun 2023 14:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjFTSex (ORCPT ); Tue, 20 Jun 2023 14:34:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F89610E2; Tue, 20 Jun 2023 11:34:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D53361376; Tue, 20 Jun 2023 18:34:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A43D9C433C8; Tue, 20 Jun 2023 18:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687286090; bh=YOzPATmO8wGxwInPsNJVCNLX4H1Ef7rZzowHevjjD/s=; h=From:To:Cc:Subject:Date:From; b=1PLSkGkIsZPxpmUHXeKhKsPySfKl8A/ptcE9hebeInjOUIy3rHWsvPBJuqZFg1vUC gEYjlxlCn3fKyaBlDDyExTW37J8QGIYxqszhKuI5zuYGyBivS5DT8sFa3SJ50VHdun OXHHb+Et160zUAD4d2MXqwAE1RgLasXPi6NkPtzk= From: Greg Kroah-Hartman To: sparclinux@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ivan Orlov , "David S. Miller" , Andrew Morton , Jonathan Corbet , Benjamin Tissoires , "Mike Rapoport (IBM)" , Suren Baghdasaryan , Greg Kroah-Hartman Subject: [PATCH] oradax: make 'cl' a static const structure Date: Tue, 20 Jun 2023 20:34:47 +0200 Message-ID: <20230620183446.684061-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2449; i=gregkh@linuxfoundation.org; h=from:subject; bh=iMcb7lPwqLnwJII9WdVDNBIv4TpcWL4faC5ec2Wi5h8=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTP7o9D5+0ouLTn66PoYd+SuYv1j26WX7Z2qUuHlfMx Ccs+lPs2BHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATcehiWHDgu/t3+3VzPVes 9baYEsd16EL0FTmGBUcsjwgfSZj+e92uJzJzmmcaXs6+2AcA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the 'cl' structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: "David S. Miller" Cc: Andrew Morton Cc: Jonathan Corbet Cc: Benjamin Tissoires Cc: "Mike Rapoport (IBM)" Cc: Suren Baghdasaryan Cc: Ivan Orlov Cc: sparclinux@vger.kernel.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman Acked-by: Sam Ravnborg --- drivers/sbus/char/oradax.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c index aafce8d00000..a536dd6f4f7c 100644 --- a/drivers/sbus/char/oradax.c +++ b/drivers/sbus/char/oradax.c @@ -226,8 +226,10 @@ static int dax_ccb_info(u64 ca, struct ccb_info_result= *info); static int dax_ccb_kill(u64 ca, u16 *kill_res); =20 static struct cdev c_dev; -static struct class *cl; static dev_t first; +static const struct class cl =3D { + .name =3D DAX_NAME, +}; =20 static int max_ccb_version; static int dax_debug; @@ -323,14 +325,11 @@ static int __init dax_attach(void) goto done; } =20 - cl =3D class_create(DAX_NAME); - if (IS_ERR(cl)) { - dax_err("class_create failed"); - ret =3D PTR_ERR(cl); + ret =3D class_register(&cl); + if (ret) goto class_error; - } =20 - if (device_create(cl, NULL, first, NULL, dax_name) =3D=3D NULL) { + if (device_create(&cl, NULL, first, NULL, dax_name) =3D=3D NULL) { dax_err("device_create failed"); ret =3D -ENXIO; goto device_error; @@ -347,9 +346,9 @@ static int __init dax_attach(void) goto done; =20 cdev_error: - device_destroy(cl, first); + device_destroy(&cl, first); device_error: - class_destroy(cl); + class_unregister(&cl); class_error: unregister_chrdev_region(first, 1); done: @@ -362,8 +361,8 @@ static void __exit dax_detach(void) { pr_info("Cleaning up DAX module\n"); cdev_del(&c_dev); - device_destroy(cl, first); - class_destroy(cl); + device_destroy(&cl, first); + class_unregister(&cl); unregister_chrdev_region(first, 1); } module_exit(dax_detach); --=20 2.41.0