From nobody Tue Dec 16 19:40:02 2025 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 AD082E92721 for ; Thu, 5 Oct 2023 15:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237930AbjJEP6E (ORCPT ); Thu, 5 Oct 2023 11:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233133AbjJEP4l (ORCPT ); Thu, 5 Oct 2023 11:56:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300F265AD for ; Thu, 5 Oct 2023 06:55:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760D8C43215; Thu, 5 Oct 2023 13:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696514116; bh=FPF7KAEMlwIOVvDpPTd1/Wuts/J4Yv4RkMVq/HLq2eY=; h=From:To:Cc:Subject:Date:From; b=PgDD5hPkbG9WNVHPRTbjh23Grnci0W6b2O4zsqUjNsNTzs+jonusi/zh2/rJtjj4G KZtZ2wJYNYDn6ED8wyEqrVfRnNuPnl4hxlZF5XX+e+lknot1Hs6wKH/XiLus1tZ3OQ NOY+Nnx2idcb61kytiF9b84O+0eTCTGKH2m3f3Pc= From: Greg Kroah-Hartman To: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH v2] staging: pi433: make pi433_class constant Date: Thu, 5 Oct 2023 15:55:13 +0200 Message-ID: <2023100512-sweat-abruptly-2445@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2941; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=FPF7KAEMlwIOVvDpPTd1/Wuts/J4Yv4RkMVq/HLq2eY=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlyBxy3zuDL5GhjjokNbUzOT/sie8G4YJ//q1fBup7+h rddnjZ0xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwEQeP2GYX1z9ifV6QZbIlzdf jioWnaif9rayjWF+uNhaiW9+wvqP+0KOrlfdfb7C4shhAA== 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" Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Signed-off-by: Greg Kroah-Hartman --- v2 : properly call class_unregister() in module exit drivers/staging/pi433/pi433_if.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 58887619b83f..0ec3130225db 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -56,7 +56,10 @@ static DEFINE_IDR(pi433_idr); static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ static struct dentry *root_dir; /* debugfs root directory for the driver */ =20 -static struct class *pi433_class; /* mainly for udev to create /dev/pi433 = */ +/* mainly for udev to create /dev/pi433 */ +static const struct class pi433_class =3D { + .name =3D "pi433", +}; =20 /* * tx config is instance specific @@ -1259,7 +1262,7 @@ static int pi433_probe(struct spi_device *spi) =20 /* create device */ device->devt =3D MKDEV(MAJOR(pi433_dev), device->minor); - device->dev =3D device_create(pi433_class, + device->dev =3D device_create(&pi433_class, &spi->dev, device->devt, device, @@ -1315,7 +1318,7 @@ static int pi433_probe(struct spi_device *spi) cdev_failed: kthread_stop(device->tx_task_struct); send_thread_failed: - device_destroy(pi433_class, device->devt); + device_destroy(&pi433_class, device->devt); device_create_failed: pi433_free_minor(device); minor_failed: @@ -1342,7 +1345,7 @@ static void pi433_remove(struct spi_device *spi) =20 kthread_stop(device->tx_task_struct); =20 - device_destroy(pi433_class, device->devt); + device_destroy(&pi433_class, device->devt); =20 cdev_del(device->cdev); =20 @@ -1398,18 +1401,18 @@ static int __init pi433_init(void) if (status < 0) return status; =20 - pi433_class =3D class_create("pi433"); - if (IS_ERR(pi433_class)) { + status =3D class_register(&pi433_class); + if (status) { unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); - return PTR_ERR(pi433_class); + return status; } =20 root_dir =3D debugfs_create_dir(KBUILD_MODNAME, NULL); =20 status =3D spi_register_driver(&pi433_spi_driver); if (status < 0) { - class_destroy(pi433_class); + class_unregister(&pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); } @@ -1422,7 +1425,7 @@ module_init(pi433_init); static void __exit pi433_exit(void) { spi_unregister_driver(&pi433_spi_driver); - class_destroy(pi433_class); + class_unregister(&pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); debugfs_remove(root_dir); } --=20 2.42.0