From nobody Thu Jan 1 08:55:39 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 A7ADFC00A8F for ; Tue, 24 Oct 2023 11:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232891AbjJXLuI (ORCPT ); Tue, 24 Oct 2023 07:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbjJXLuF (ORCPT ); Tue, 24 Oct 2023 07:50:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AFDD68 for ; Tue, 24 Oct 2023 04:50:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C5BC433C8; Tue, 24 Oct 2023 11:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698148202; bh=/di0nuchbi/scniKqa/QIzyLS/gyMwWSJ3huyvVHoTU=; h=From:To:Cc:Subject:Date:From; b=AXiGxmFohtREcmv1E7XvCwf13O44ss7wYntxcIqUOt39HWrCEtCmwmXskBRztiiDM PuIlFobNe93mWoUntxzeaRc4bsUVNiK10qIaXWPDbNVZ//bL57x+cowgOZK0AQdFaG 3ks4UwmoJR+jnl6d22gK9G48CG07r9Z5yJZHKlYI= From: Greg Kroah-Hartman To: linux-accelerators@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Zhangfei Gao , Zhou Wang , Arnd Bergmann Subject: [PATCH] uacce: make uacce_class constant Date: Tue, 24 Oct 2023 13:49:59 +0200 Message-ID: <2023102458-designate-vicinity-4c86@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2210; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=/di0nuchbi/scniKqa/QIzyLS/gyMwWSJ3huyvVHoTU=; b=owGbwMvMwCRo6H6F97bub03G02pJDKnm69NMrnaesteR5N94b0dbeW91etkX7549YkWT/B5we 0dPrrXqiGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgIlwGzHMU7Fs/dCx5txKvrXH 1tzInXnqC1PXG4b5Xv2r43OFYnwn8e/qtDh/9mxJQDk/AA== 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, 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: Zhangfei Gao Cc: Zhou Wang Cc: Arnd Bergmann Cc: linux-accelerators@lists.ozlabs.org Signed-off-by: Greg Kroah-Hartman Tested-by: Zhangfei Gao --- drivers/misc/uacce/uacce.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c index 930c252753a0..bdc2e6fda782 100644 --- a/drivers/misc/uacce/uacce.c +++ b/drivers/misc/uacce/uacce.c @@ -7,10 +7,13 @@ #include #include =20 -static struct class *uacce_class; static dev_t uacce_devt; static DEFINE_XARRAY_ALLOC(uacce_xa); =20 +static const struct class uacce_class =3D { + .name =3D UACCE_NAME, +}; + /* * If the parent driver or the device disappears, the queue state is inval= id and * ops are not usable anymore. @@ -530,7 +533,7 @@ struct uacce_device *uacce_alloc(struct device *parent, mutex_init(&uacce->mutex); device_initialize(&uacce->dev); uacce->dev.devt =3D MKDEV(MAJOR(uacce_devt), uacce->dev_id); - uacce->dev.class =3D uacce_class; + uacce->dev.class =3D &uacce_class; uacce->dev.groups =3D uacce_dev_groups; uacce->dev.parent =3D uacce->parent; uacce->dev.release =3D uacce_release; @@ -623,13 +626,13 @@ static int __init uacce_init(void) { int ret; =20 - uacce_class =3D class_create(UACCE_NAME); - if (IS_ERR(uacce_class)) - return PTR_ERR(uacce_class); + ret =3D class_register(&uacce_class); + if (ret) + return ret; =20 ret =3D alloc_chrdev_region(&uacce_devt, 0, MINORMASK, UACCE_NAME); if (ret) - class_destroy(uacce_class); + class_unregister(&uacce_class); =20 return ret; } @@ -637,7 +640,7 @@ static int __init uacce_init(void) static __exit void uacce_exit(void) { unregister_chrdev_region(uacce_devt, MINORMASK); - class_destroy(uacce_class); + class_unregister(&uacce_class); } =20 subsys_initcall(uacce_init); --=20 2.42.0