From patchwork Tue Jun 20 14:37:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3715929vqr; Tue, 20 Jun 2023 07:43:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zWxUIo18Fs0bAPmBbXYc1E4eQ7D7+EyKn32niJ8K8zkV8vKteqBRXl3NLH2RstwoK1GGE X-Received: by 2002:a17:902:d2cd:b0:1b6:770f:e837 with SMTP id n13-20020a170902d2cd00b001b6770fe837mr4792843plc.31.1687272200903; Tue, 20 Jun 2023 07:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272200; cv=none; d=google.com; s=arc-20160816; b=EgWlx/v352g2r28kXVZ60l2P7orObS6DtrJREOMQ8WURA8mdRsZFH8u+7f0ttL5k2u WzauthJ8Vk/UUZqyMUK7IJZIG6iLz5yUjifP6D6AJZe/pcKgyn282SBF+16OGtitHYww 1+PpL6vtgqQJmFcFDPSYekOCZjVUYvdLUfRK6Viad7XoT7AgFp+ei/TEgNW+GNEz8HwI TrekuxisP3iGbHeCKANaiPomgEpQSuwtB0zjvvueBAS8bxqukF1aLa/4PSbwFlveSGr0 45K5ZM68m0CCKDXoDfdB4FhqZ2kZ9Qftobl8dWmxC5t5s6F0PEmnWg9pBJqHbueFtQra pdyQ== 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=TQa1dMlsM+zU0dwx9nkPZldqKPs+K9lCQvJjWrKa1uA=; b=F2a7eEmX8UADv3MwzUGxB3CabYI96FSQa4OhJF6WuvdwwD0LYjmXxqUBQy/rMUTick n85k9YYk6YB9OexBU0B1hGJc03jM2j24e4AN0V32MHBv7CfbW+hAY9ILaasgeiYA1qhj YSZYWqPU9BVyJ3HQKAlphGntYUIsWZG7/dW71GMTE0J+IzMi3Ykk5VOq9mjByvRbo7oK Qu+34M61XKnfpiKFgb9JmOuwKC1wuQ4fvj/izljY7gVNKHGnajs6xJo+xiZhQYpjARcu Hg2Du8m/TQ/e3zU+UcZAR0QMbCBY+EumnTgDT4w9iIqFWSxy464HXThfFw+5yHBPsOb0 M3xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PSBem03D; 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 lf5-20020a170902fb4500b001ae4c3bbb0dsi1847960plb.145.2023.06.20.07.43.08; Tue, 20 Jun 2023 07:43:20 -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=PSBem03D; 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 S233316AbjFTOh7 (ORCPT + 99 others); Tue, 20 Jun 2023 10:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjFTOh6 (ORCPT ); Tue, 20 Jun 2023 10:37:58 -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 6D76595 for ; Tue, 20 Jun 2023 07:37:57 -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 030926126D for ; Tue, 20 Jun 2023 14:37:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 075CAC433C0; Tue, 20 Jun 2023 14:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271876; bh=YE9m+nJJxh6aOa03h/WHgHWu9OpOX6QmULhfRkMKaCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSBem03Ddue+jvEKN2DbbsjQDXD4szBbGdpInvvIfNsny2r1ZP0rQVoxudmxTgEYn Y3CTO1mfIzHRky5iVK5Z0O0wbu78eYKyQC/UO8IjSI57NPBxO3l20cibVHggJ/zPjN l7rE2Xuh8hRikViB0U5C0Hg5VWF3m2uvneqRepmo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 2/9] dsp56k: make dsp56k_class a static const structure Date: Tue, 20 Jun 2023 16:37:53 +0200 Message-ID: <20230620143751.578239-11-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=2151; i=gregkh@linuxfoundation.org; h=from:subject; bh=eDeV6EZT0WbX/n0zteTSKFxR5yU/pGMS0Gd2MNY4l2g=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTd+4/sFjwv/+6ugn/eHVMkvlMPPJa/vodf7T9WqT7V cX7Fh8CO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiu1YxzHebcq6D5WzUtnXB 7ikPnToqyy9uYWeYn6Oim7y/dtHtiUr7NCynZ3G+DvwhBAA= 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?1769233135289133890?= X-GMAIL-MSGID: =?utf-8?q?1769233135289133890?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the dsp56k_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/dsp56k.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index b3eaf3e5ef2e..bda27e595da1 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -101,7 +101,9 @@ static struct dsp56k_device { int tx_wsize, rx_wsize; } dsp56k; -static struct class *dsp56k_class; +static const struct class dsp56k_class = { + .name = "dsp56k", +}; static int dsp56k_reset(void) { @@ -493,7 +495,7 @@ static const char banner[] __initconst = KERN_INFO "DSP56k driver installed\n"; static int __init dsp56k_init_driver(void) { - int err = 0; + int err; if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) { printk("DSP56k driver: Hardware not present\n"); @@ -504,12 +506,10 @@ static int __init dsp56k_init_driver(void) printk("DSP56k driver: Unable to register driver\n"); return -ENODEV; } - dsp56k_class = class_create("dsp56k"); - if (IS_ERR(dsp56k_class)) { - err = PTR_ERR(dsp56k_class); + err = class_register(&dsp56k_class); + if (err) goto out_chrdev; - } - device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, + device_create(&dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); printk(banner); @@ -524,8 +524,8 @@ module_init(dsp56k_init_driver); static void __exit dsp56k_cleanup_driver(void) { - device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); - class_destroy(dsp56k_class); + device_destroy(&dsp56k_class, MKDEV(DSP56K_MAJOR, 0)); + class_unregister(&dsp56k_class); unregister_chrdev(DSP56K_MAJOR, "dsp56k"); } module_exit(dsp56k_cleanup_driver);