From patchwork Tue Jun 20 14:38:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3724767vqr; Tue, 20 Jun 2023 07:57:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WHR+9GIyPOb23RH5PdKONDHI1vykPpVN2saL2AmdbreeWAi3UpqCsxyQRxo5qGdnm4PrY X-Received: by 2002:a05:6808:14ce:b0:39a:abe8:afc3 with SMTP id f14-20020a05680814ce00b0039aabe8afc3mr16796074oiw.38.1687273038995; Tue, 20 Jun 2023 07:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687273038; cv=none; d=google.com; s=arc-20160816; b=QeYC6m7b26FJ/0pTkON83uMIeXHPe41ZJ7kebY9Cwg+h0Xfy7rC3LvnVDHlJip8PJj 2XauNA9Jy2R6rHAxLeyKp6VnrvIuHAJIXWFn1K+2PboD5ec6QeXKra4bSGjKqbHqZnHw VyjCG79PZBJZXZ0OXCk08zECu4zTZRfeJdob4eLX6EKZu2mrfdoJh+8XtVXAEFG4UI4H RF/S/7C9qt2EmrYslzABWe2VNsR9gpEH2ii3jah0w0zoZHpQAmVuTo59I6+7Qvnv2xF6 ZexWn32JeXXaY2oOpf22/OLX8VMOgRbpZVUzm380TWiVcgbo9C8BsJ8fVWNRtXWZHJot 4D4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7eGeRmCrRdli+B57BCgS/xK30rWbST0PKCjtV+aS44U=; b=eXFirbrIWo9xDPadjU91sUniG1BvgQkgfKKzZT7aS7XUDsN10gzIA/CBqGB98U9Plr fN6tJAcYTuJvnL1dh9fbK0PG6xE7zavc9DIwNtOxHG2+/skX1XplIoyi69Vyh8pRGdCM 0rX8H0WQq4PF05xOC9oOSrJEBIk3mBb85NB7mK2GLNq/pEoCGQ+cLvBVzG/Z8eviJflF c26hS6+vAUFBniCRaV9KoTO0MbwkhIkVRT1G+eJveptL8/aT74G28zoGigQ8T35vK7/Z fpZxdGzkPMTk+YAYmtCPYKs4eGkWbXXmbCRF7+tIj1MDjf1jA8IormmsYvootf31QlTr wNnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jCixr9sU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n31-20020a17090a5aa200b0025691c00096si1993908pji.140.2023.06.20.07.57.04; Tue, 20 Jun 2023 07:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jCixr9sU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbjFTOir (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233371AbjFTOi3 (ORCPT ); Tue, 20 Jun 2023 10:38:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 482B619B9 for ; Tue, 20 Jun 2023 07:38:22 -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 B61E7612CE for ; Tue, 20 Jun 2023 14:38:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C55D3C433CA; Tue, 20 Jun 2023 14:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271901; bh=SBqR0b/G7NdQJEKcKs88hL5JacXmXZMe/k0Egq41e/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCixr9sUu60TyJnN7hJpLHQfwGbO5RrBRSvaTfpbQr0FEMyN2FMIpubV3lU22NcxB fCjiOIwlmVzgzI1042LHWeFqT4Ai/NuaflTBjpph0LasJEW7TWjyWzrrHEWqRuczBM WqIb/DIk5OyhTswFudsvwmgkniZhcifeBMbFcHaE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Eli Billauer , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 9/9] char: xillybus: make xillybus_class a static const structure Date: Tue, 20 Jun 2023 16:38:00 +0200 Message-ID: <20230620143751.578239-18-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620143751.578239-10-gregkh@linuxfoundation.org> References: <20230620143751.578239-10-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2566; i=gregkh@linuxfoundation.org; h=from:subject; bh=LzwP0BkjV3W+sXqBaEm9wchHpeRuVoG6aFsdXlWGz6g=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx4o+vnvW0DA7hL7zQWfZumynZ2Wb/I8Mkj3S+3zE y7ltzhedcSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEPNgY5plpfJsT2HJ94rtZ Pe9Z+Uxda5afbWWYpy3W4CaVvriS1+r93+M7HPtXfNgtCwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769234014335514358?= X-GMAIL-MSGID: =?utf-8?q?1769234014335514358?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the xillybus_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: Eli Billauer Cc: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman Acked-by: Eli Billauer --- drivers/char/xillybus/xillybus_class.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/char/xillybus/xillybus_class.c b/drivers/char/xillybus/xillybus_class.c index 89926fe9d813..c92a628e389e 100644 --- a/drivers/char/xillybus/xillybus_class.c +++ b/drivers/char/xillybus/xillybus_class.c @@ -23,7 +23,9 @@ MODULE_LICENSE("GPL v2"); static DEFINE_MUTEX(unit_mutex); static LIST_HEAD(unit_list); -static struct class *xillybus_class; +static const struct class xillybus_class = { + .name = "xillybus", +}; #define UNITNAMELEN 16 @@ -121,7 +123,7 @@ int xillybus_init_chrdev(struct device *dev, len -= namelen + 1; idt += namelen + 1; - device = device_create(xillybus_class, + device = device_create(&xillybus_class, NULL, MKDEV(unit->major, i + unit->lowest_minor), @@ -152,7 +154,7 @@ int xillybus_init_chrdev(struct device *dev, unroll_device_create: for (i--; i >= 0; i--) - device_destroy(xillybus_class, MKDEV(unit->major, + device_destroy(&xillybus_class, MKDEV(unit->major, i + unit->lowest_minor)); cdev_del(unit->cdev); @@ -193,7 +195,7 @@ void xillybus_cleanup_chrdev(void *private_data, for (minor = unit->lowest_minor; minor < (unit->lowest_minor + unit->num_nodes); minor++) - device_destroy(xillybus_class, MKDEV(unit->major, minor)); + device_destroy(&xillybus_class, MKDEV(unit->major, minor)); cdev_del(unit->cdev); @@ -242,19 +244,12 @@ EXPORT_SYMBOL(xillybus_find_inode); static int __init xillybus_class_init(void) { - xillybus_class = class_create("xillybus"); - - if (IS_ERR(xillybus_class)) { - pr_warn("Failed to register xillybus class\n"); - - return PTR_ERR(xillybus_class); - } - return 0; + return class_register(&xillybus_class); } static void __exit xillybus_class_exit(void) { - class_destroy(xillybus_class); + class_unregister(&xillybus_class); } module_init(xillybus_class_init);