From patchwork Tue Jun 20 14:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3722018vqr; Tue, 20 Jun 2023 07:52:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UxCoDFxEY263ILVPKeSKmYGyyJRPsjEWFi5DiuP89sEgCPg7+fEpkn+vdpltiEvlDm76n X-Received: by 2002:a05:6a00:a86:b0:652:a91c:55a0 with SMTP id b6-20020a056a000a8600b00652a91c55a0mr13434833pfl.25.1687272766951; Tue, 20 Jun 2023 07:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272766; cv=none; d=google.com; s=arc-20160816; b=MNKgmiVJdHaTJhYCmuCfpTuDhg/KmDwjnY3ms5h1dZbVN5jEr4Ln+PEhbuvH7V3Igw MbKTAduzcuqpTCNUlm65iiEWDCkpCbv8PimHV1KzKx5hkQpby6vlWCyreTukGM+Lk08o O5Glm9lnEtCm9FkHl7wG3tY2/rEO9EJq1O18Q2s0KhbJzRmDYu4AL9u0NggIaYjvdXWr LgqZCbRLY9pkEJ1Tg1zcq9pWnJrdWgbnnbJvBEByjfGSosYyTGQ1xCgo0iJ/9cbRB3KO jeM+eJJJ2KuIqzlPVmqGbLYe4bvZaD4xaNEhjZy1X3rIc7ojVRXOd9BWtl61lu46N4S1 CyVA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+1t0UKEm6E4w+2RG3m8BMklVLKgL2TBfk8ne6Nvcx5c=; b=s+hFVDAqIV7COymIIiLvilk9LRiuKIGyQo1O9tcbXLBH6p/rggKihcRnFEvsDmPBzk lFLsjrbajC55nsWPwg3Fxd/xjcUyTI2DFMCKPPx8VcXfMMBeXrBVQE1tyr76XSNKjjDc EL8QL8N693sSJyGza6tF5GPv3kg20Q9jE+0PmpsTNlxMd7o2P3juI2V0JnMirHISojba 0tlK/PHWcFLbOzCHg74W+IsCmxBmYe4NZLuCvyC5SwDN8ubRAR3Nd1fP8N+6KYzapbHe e3DdjX2qbOHZuIj7MZa7HcF4Zl1tplmaS2XD5iZpnxIdoMk0cs/q3D/Vy48mFdYf9S1h tAzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1G5CQ36V; 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 y15-20020aa79e0f000000b006556984fbf6si965140pfq.290.2023.06.20.07.52.31; Tue, 20 Jun 2023 07:52:46 -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=1G5CQ36V; 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 S233328AbjFTOiF (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233321AbjFTOiB (ORCPT ); Tue, 20 Jun 2023 10:38:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E39CE for ; Tue, 20 Jun 2023 07:38:00 -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 D7B836126D for ; Tue, 20 Jun 2023 14:37:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4725C433C0; Tue, 20 Jun 2023 14:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271879; bh=3fWYPMoqAonGHfIfPasWqIxbONyFbWO7titQ4tLBhMw=; h=From:To:Cc:Subject:Date:From; b=1G5CQ36VA5qcAjBTSQ37XBv0908Z/pZYRHtgMOdc5z5QdLyQzw0SQWLulkVVUd1Tv ntpKIMQ14JEOOlcbBrr4KjMA5agaZgTbbkUXE0NgyE8nr3Uj6IqHdkg4lqweViureo bcwhQk8iE50bbL1CEaLHURvR4OM5MmnwkMw0/blg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 1/9] bsr: make bsr_class a static const structure Date: Tue, 20 Jun 2023 16:37:52 +0200 Message-ID: <20230620143751.578239-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2513; i=gregkh@linuxfoundation.org; h=from:subject; bh=jBaioBMdJILdqbcL7HIiRWuT7uBmiwx111FL5lEuQq0=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTd+4PjlOf1PwmxE2u4xFn7WfNM/172q2+uIuLrvzyW CF7d65LRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEyEOZ1hwfljH/yPJ3k/nv9X 7p/vm/XHtxwwX8ww32mutlViZYbqBndbu856x7f+DO07AQ== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1769233728379693778?= X-GMAIL-MSGID: =?utf-8?q?1769233728379693778?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the bsr_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/bsr.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index ff429ba02fa4..0654f0e6b320 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c @@ -61,7 +61,6 @@ struct bsr_dev { static unsigned total_bsr_devs; static LIST_HEAD(bsr_devs); -static struct class *bsr_class; static int bsr_major; enum { @@ -108,6 +107,11 @@ static struct attribute *bsr_dev_attrs[] = { }; ATTRIBUTE_GROUPS(bsr_dev); +static const struct class bsr_class = { + .name = "bsr", + .dev_groups = bsr_dev_groups, +}; + static int bsr_mmap(struct file *filp, struct vm_area_struct *vma) { unsigned long size = vma->vm_end - vma->vm_start; @@ -244,7 +248,7 @@ static int bsr_add_node(struct device_node *bn) goto out_err; } - cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, + cur->bsr_device = device_create(&bsr_class, NULL, cur->bsr_dev, cur, "%s", cur->bsr_name); if (IS_ERR(cur->bsr_device)) { printk(KERN_ERR "device_create failed for %s\n", @@ -293,13 +297,9 @@ static int __init bsr_init(void) if (!np) goto out_err; - bsr_class = class_create("bsr"); - if (IS_ERR(bsr_class)) { - printk(KERN_ERR "class_create() failed for bsr_class\n"); - ret = PTR_ERR(bsr_class); + ret = class_register(&bsr_class); + if (err) goto out_err_1; - } - bsr_class->dev_groups = bsr_dev_groups; ret = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr"); bsr_major = MAJOR(bsr_dev); @@ -320,7 +320,7 @@ static int __init bsr_init(void) unregister_chrdev_region(bsr_dev, BSR_MAX_DEVS); out_err_2: - class_destroy(bsr_class); + class_unregister(&bsr_class); out_err_1: of_node_put(np); @@ -335,8 +335,7 @@ static void __exit bsr_exit(void) bsr_cleanup_devs(); - if (bsr_class) - class_destroy(bsr_class); + class_unregister(&bsr_class); if (bsr_major) unregister_chrdev_region(MKDEV(bsr_major, 0), BSR_MAX_DEVS); 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); From patchwork Tue Jun 20 14:37:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110537 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3716400vqr; Tue, 20 Jun 2023 07:44:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CozATQSOE1cW1x8WgEB5nzfkecIk7u6IygYzROW9BfSmPK7iCNC7d1h96xVN+umQiT77M X-Received: by 2002:a05:6a20:8f06:b0:122:a808:dbbe with SMTP id b6-20020a056a208f0600b00122a808dbbemr1966372pzk.29.1687272248985; Tue, 20 Jun 2023 07:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272248; cv=none; d=google.com; s=arc-20160816; b=hD7CwhAN5jyi1xP7aul8bc0+LPRs3+jSW8+tAa6ku0cqJ/q9lpIQGfqq5dcUQZOCcv gxB8PGlIwqOEHMEVA+t1RBZrE6YClOUgsCt13/m9i2Yr49hEdRI7M+qgny5pDue5pDvf sF8h9+KyAbXM+UL5y8YGcZMiKBDx4TOBGJwEyNbKvmpgOGZOMkw9lAL/t1rDV9XC9hFz Fu0KkaIuX8f8fh7Ck0u1ZvjBJ4PKjwUDd8WmoHgolgCHWQAmgHKW5Zpyg5RGzek04ZnS q0MIZfztnhzAs6QiC5mMc1EAUoAS6gQuB4LSLiVJdy2A4xMSkIiOk1NPbkPuAf5kPv7k DQ3g== 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=CYSkr5mnGvf13VDlMz1tr4N1uKAmkmlvou8f97lm168=; b=eYKz46HzPNil/N74kcC4HPYdS/P1F7q2JUi+o1bmJOd7LDiPnti45czRK0ubI6hr2+ NZcv1cMjs8wlRzu3a0yL5NBxgW5lzJmC9KsDKNgZeH2LsdbtqkOCBpwyaxyN90QckjU7 nYHva1cm08KHYqZDTSwn0cXxVpAO8qRcj/Ub8P6NV7NLtRIYAEM+Msm4rMSxKCarzSPq bCnX2XJ/IQ1nEL0Pc4yxwSmrnKOQmHCcRg0afx3RH4Og0FVpUWS2uLiecYnjXaZeMoFO P8EuKl+BA6CilrevRjSUy1ZMA1qhekScVfLlJPASWZ94ti8HTFhNvFdvV80OP1Q8jzdv qa7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHbhCU7a; 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 a24-20020aa794b8000000b0066881cb1b2fsi1761708pfl.346.2023.06.20.07.43.56; Tue, 20 Jun 2023 07:44:08 -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=zHbhCU7a; 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 S232941AbjFTOiM (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233122AbjFTOiG (ORCPT ); Tue, 20 Jun 2023 10:38:06 -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 1368C1709 for ; Tue, 20 Jun 2023 07:38:05 -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 9CD6A6127D for ; Tue, 20 Jun 2023 14:38:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AED7EC433C8; Tue, 20 Jun 2023 14:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271884; bh=aL+zPU+4ql5HlCKxKr8ENZd/vHFVLtnUtN7tBrGgRrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zHbhCU7a8ubHXxx2tXw676Qo8kSg0qM21ETCGWViK7U/G1YrVzaNBaAt6zkhBhwI6 VeA4gqzq5gxQO60/AoZWnYcp2/QcBpbZlim5i1/tVVYE2YlOfdcAJXpFwdNelhw7Th amGQth1g1gGTNis66+yJcveIYVfPSGpGNjDZu7tc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 3/9] char: lp: make lp_class a static const structure Date: Tue, 20 Jun 2023 16:37:54 +0200 Message-ID: <20230620143751.578239-12-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=2420; i=gregkh@linuxfoundation.org; h=from:subject; bh=d1GSl0pDYIsh4omT1MKF3Zrqgoaggl/D/FsxIzUumgQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTd+7fYH1le9033YBEy3vNh9Kqt7kKNRakvX6vWfJuv 8qs51XVHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRxQoM88ssC1fOmvLPe8aR dP9+a1nuXC+X7QwLmlb7Z6XMmXXaioXfke3DzwUi7x1fAgA= 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?1769233185924631221?= X-GMAIL-MSGID: =?utf-8?q?1769233185924631221?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the lp_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: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 70cfc5140c2c..2f171d14b9b5 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -145,7 +145,9 @@ static struct lp_struct lp_table[LP_NO]; static int port_num[LP_NO]; static unsigned int lp_count = 0; -static struct class *lp_class; +static const struct class lp_class = { + .name = "printer", +}; #ifdef CONFIG_LP_CONSOLE static struct parport *console_registered; @@ -932,7 +934,7 @@ static int lp_register(int nr, struct parport *port) if (reset) lp_reset(nr); - device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, + device_create(&lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, "lp%d", nr); printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, @@ -1004,7 +1006,7 @@ static void lp_detach(struct parport *port) if (port_num[n] == port->number) { port_num[n] = -1; lp_count--; - device_destroy(lp_class, MKDEV(LP_MAJOR, n)); + device_destroy(&lp_class, MKDEV(LP_MAJOR, n)); parport_unregister_device(lp_table[n].dev); } } @@ -1049,11 +1051,9 @@ static int __init lp_init(void) return -EIO; } - lp_class = class_create("printer"); - if (IS_ERR(lp_class)) { - err = PTR_ERR(lp_class); + err = class_register(&lp_class); + if (err) goto out_reg; - } if (parport_register_driver(&lp_driver)) { printk(KERN_ERR "lp: unable to register with parport\n"); @@ -1072,7 +1072,7 @@ static int __init lp_init(void) return 0; out_class: - class_destroy(lp_class); + class_unregister(&lp_class); out_reg: unregister_chrdev(LP_MAJOR, "lp"); return err; @@ -1115,7 +1115,7 @@ static void lp_cleanup_module(void) #endif unregister_chrdev(LP_MAJOR, "lp"); - class_destroy(lp_class); + class_unregister(&lp_class); } __setup("lp=", lp_setup); From patchwork Tue Jun 20 14:37:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3723049vqr; Tue, 20 Jun 2023 07:54:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OI5nCBgtZ3JfptSgZqD0ijooo4sbG3n9AxmhLOWVp5QosdfkHewGcCvZal9fzlHUq4uXe X-Received: by 2002:a17:902:f68a:b0:1b3:bd50:97dd with SMTP id l10-20020a170902f68a00b001b3bd5097ddmr3362105plg.18.1687272860638; Tue, 20 Jun 2023 07:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272860; cv=none; d=google.com; s=arc-20160816; b=zdKRM4YTGQlga/gtCcngXRC+IgycXXVTtZTLhb+hGIiBZaIbWw3O/gp7DDKBMMmnTq 0/TjnpPYA5TkXvck1WX9LZWdGtYFXnsh0+NSHQoR2V0TsY7jlmM+8pIbGC7g8qtm3faA 64NjHaQKttIFAvBES7aUQJ9G8AVMXy/91ndBt+/gVUBZ2RPq5OhiW91BVTI1shjMYbCV HW9b3N3/WVsbwXDq25TzhwIdf0oaGp6teodpFxDfuWgGdfoOgPkCY7XmOHxZtwP053Rb CXdQF30JVV+hsyFRtZGWIM8s15ohhNEdteqtYPtr7oEjRn45RJMrophJtqa6QFhXsLJ/ eYdg== 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=CYWT2xojrZc2r8MX8/kJmr9WIxQd5Q0QJ9miCVRqLAM=; b=XOsWhduR4SbTPKFMCNAfncy/vwaekO/D0oI4szBrJuZ/rhvh4tN48bKAaAUrv3Y24U phi0Mc33REktkCqDdpFoQvs2zZxjRb4C3ISnV3H4i7+azpHhqSlKgbc9+irjhlL2PrXn wSM6oPmxOX3mWKl8AoIIEln9bfSielxikD9yp/U+LtrkdWN5do/D9ziZzuqM2NWbBcXD HJwCxzvXhcEyRUfX8p3L8KVWmijWPgHau+fNXWrvOfsORjDzpIQA92QluhuZAXHxP8kI ROCUTHvYimDFnb7Hc5Ou1doiyDHgkvsZAt9EW3jL/sp820Y0A6eG9IZsGaQXA5xgMJb5 at0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZZ41ux87; 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 m11-20020a170902f20b00b001ab2a0e3163si1944488plc.598.2023.06.20.07.54.06; Tue, 20 Jun 2023 07:54: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=ZZ41ux87; 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 S233360AbjFTOiQ (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbjFTOiN (ORCPT ); Tue, 20 Jun 2023 10:38:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6576170F for ; Tue, 20 Jun 2023 07:38:07 -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 6637A6124C for ; Tue, 20 Jun 2023 14:38:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78BE0C433C0; Tue, 20 Jun 2023 14:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271886; bh=NNeBnpMh0VKltZp3X6U483e9x1db0PB3xLQaZRMH63g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZ41ux87hcYbKBEoQJRWGlh09O0QJ9Tv7sYNj/GDVwttzaawLeyUFHk3MpHDVLzwi AkazbBqxfDcb4h/Qel30sUKnpfroQk/wknIyjH+lH9yyFJ1O4Tt6aBvmkDF71H2mqv ch65RmdQLcI6SqqxVRgHLRqifdWTmaISOJGx9+Fs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 4/9] /dev/mem: make mem_class a static const structure Date: Tue, 20 Jun 2023 16:37:55 +0200 Message-ID: <20230620143751.578239-13-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=1765; i=gregkh@linuxfoundation.org; h=from:subject; bh=m32deV9O3pdxzflG4VVrQWKJ6v1wRrZW/H2pWLSYWM4=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTd+5/cGnfjBVPg9PezJxQW2L9JDywsy32zR+vBoG/w SfV7VkXd8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEtqUzLFjp8/2bc5/xP8UL egrz0i/P0VfcKsowT7fsqwlTact081mskY8sOaUYNvAKAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1769233826828421371?= X-GMAIL-MSGID: =?utf-8?q?1769233826828421371?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the mem_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: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/mem.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index f494d31f2b98..2f944522f18f 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -753,20 +753,23 @@ static char *mem_devnode(const struct device *dev, umode_t *mode) return NULL; } -static struct class *mem_class; +static const struct class mem_class = { + .name = "mem", + .devnode = mem_devnode, +}; static int __init chr_dev_init(void) { + int retval; int minor; if (register_chrdev(MEM_MAJOR, "mem", &memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); - mem_class = class_create("mem"); - if (IS_ERR(mem_class)) - return PTR_ERR(mem_class); + retval = class_register(&mem_class); + if (retval) + return retval; - mem_class->devnode = mem_devnode; for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { if (!devlist[minor].name) continue; @@ -777,7 +780,7 @@ static int __init chr_dev_init(void) if ((minor == DEVPORT_MINOR) && !arch_has_dev_port()) continue; - device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor), + device_create(&mem_class, NULL, MKDEV(MEM_MAJOR, minor), NULL, devlist[minor].name); } From patchwork Tue Jun 20 14:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3723265vqr; Tue, 20 Jun 2023 07:54:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Jyfz1rG+aoZNOVDrDpQklo1IBjOXGOIc0ns/pny6UQdkBUajw0iqMN9Vjf78bg0Prx3DZ X-Received: by 2002:a05:6358:9d8b:b0:130:df9d:3477 with SMTP id d11-20020a0563589d8b00b00130df9d3477mr3458496rwo.13.1687272881694; Tue, 20 Jun 2023 07:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272881; cv=none; d=google.com; s=arc-20160816; b=ZCSybMsbj8kKPJZx80mvuhhZ4jM6KfdaQQyY4WJp9JPFaKPEHiv2Ztyg549Krr0Mas XV2dY8KipzujIs4BKnzmQDXX0IvxBW64rqjMKmCiYwNa0813sGtxjiSrwg8C4+iKZNHW IZTfiZ4d4o+DcC16V1oWZVYN4o+QLnc5BYrTiveeBwX+ROU2cWkpyfGeqe8QZ2ZiTuHx oJfYjJWhmeOG9nC9QFvngw3SQXvzXUz6Mi7eTr1sWL15ZGTXplYIdTNjU0eE4QYOdmBi h7gtm04O/jGK+lMzSetm8N3ekQtt3npIA4Jw6G4rwqhcvUN7Jx8ovE8R9LahvL6zyxjP O2QA== 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=kvE3ob7XmcUp5Pyl2ZWg1NQtfTwMV0y7VDyyLGGhAe0=; b=rEnHIgGaO9sRf9peofiV9op7sHD58HTySMi5JBbVdUOC71382QCLQTMcRnkPrIUc1w ZTfFKhJoK2F0S3lVDnyXJ5XkLP5AnSGocMvAwDneJcFFWY4vZzJQ9hXh968LuRRJc5lM K6IFPc0keCre20rYkybYvNctHcuWJcDyPGAbaaOIyFicbBnUZU8SU1GjKVFUBFPrvxfI cH7iYKBo51C30eI2Vlcc1ZSnXwBsagpUI23VAShLJro+G5sYGPKARVqOjKlSPqaMCgzK JtMRtVjt2k1rGDXxdu87YmZaNRfhJVB5GN/VOkvh4Upog67dwBVK9lnlZfvdfRH3+aBb iHCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tst5jiLN; 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 t69-20020a638148000000b00553b512d1f0si1822450pgd.433.2023.06.20.07.54.28; Tue, 20 Jun 2023 07:54:41 -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=Tst5jiLN; 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 S233395AbjFTOi3 (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233341AbjFTOiO (ORCPT ); Tue, 20 Jun 2023 10:38:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7865173D for ; Tue, 20 Jun 2023 07:38:10 -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 4008F612B3 for ; Tue, 20 Jun 2023 14:38:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E2A2C433C8; Tue, 20 Jun 2023 14:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271889; bh=FaRHF/PB6BaxjUrk6iOOUUMOLqCwhxs44CVBkR4qXXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tst5jiLN6vj8fr8QPDWxGEklptuv3PDZpGxPZWiZxTJV69xLVRRxXjAdaTyXjwrfF Fuky1vpBLLPI1Qgp2BkXaSX1BMjyaJnFFA30S5vIVDHTGpjz5BxHZaFJ5CXgpjbXos bcrhRndB8TbQjBTY80OBbnfn4H/7ESf/wjxrM+TI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 5/9] char: misc: make misc_class a static const structure Date: Tue, 20 Jun 2023 16:37:56 +0200 Message-ID: <20230620143751.578239-14-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=2970; i=gregkh@linuxfoundation.org; h=from:subject; bh=Wq5JfVJAtqzIAMM6fxfToBhPJeNVfiJOSPUBrqoxF3Q=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx5448erO6+BjTVJwSjiq+1Ghr6Npd6bddPZRJ9Nu zWZdadtRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEwkWJNhfggbr8rlwOPqE1dU tLfuuSO4bc255QwLpn5bX+G+w2L+4WyvW/GJMVv1PJnsAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1769233848732580858?= X-GMAIL-MSGID: =?utf-8?q?1769233848732580858?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the misc_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: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/misc.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 1c44c29a666e..541edc26ec89 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -168,7 +168,21 @@ static int misc_open(struct inode *inode, struct file *file) return err; } -static struct class *misc_class; +static char *misc_devnode(const struct device *dev, umode_t *mode) +{ + const struct miscdevice *c = dev_get_drvdata(dev); + + if (mode && c->mode) + *mode = c->mode; + if (c->nodename) + return kstrdup(c->nodename, GFP_KERNEL); + return NULL; +} + +static const struct class misc_class = { + .name = "misc", + .devnode = misc_devnode, +}; static const struct file_operations misc_fops = { .owner = THIS_MODULE, @@ -226,7 +240,7 @@ int misc_register(struct miscdevice *misc) dev = MKDEV(MISC_MAJOR, misc->minor); misc->this_device = - device_create_with_groups(misc_class, misc->parent, dev, + device_create_with_groups(&misc_class, misc->parent, dev, misc, misc->groups, "%s", misc->name); if (IS_ERR(misc->this_device)) { if (is_dynamic) { @@ -263,43 +277,30 @@ void misc_deregister(struct miscdevice *misc) mutex_lock(&misc_mtx); list_del(&misc->list); - device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); + device_destroy(&misc_class, MKDEV(MISC_MAJOR, misc->minor)); misc_minor_free(misc->minor); mutex_unlock(&misc_mtx); } EXPORT_SYMBOL(misc_deregister); -static char *misc_devnode(const struct device *dev, umode_t *mode) -{ - const struct miscdevice *c = dev_get_drvdata(dev); - - if (mode && c->mode) - *mode = c->mode; - if (c->nodename) - return kstrdup(c->nodename, GFP_KERNEL); - return NULL; -} - static int __init misc_init(void) { int err; struct proc_dir_entry *ret; ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops); - misc_class = class_create("misc"); - err = PTR_ERR(misc_class); - if (IS_ERR(misc_class)) + err = class_register(&misc_class); + if (err) goto fail_remove; err = -EIO; if (register_chrdev(MISC_MAJOR, "misc", &misc_fops)) goto fail_printk; - misc_class->devnode = misc_devnode; return 0; fail_printk: pr_err("unable to get major %d for misc devices\n", MISC_MAJOR); - class_destroy(misc_class); + class_unregister(&misc_class); fail_remove: if (ret) remove_proc_entry("misc", NULL); From patchwork Tue Jun 20 14:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110539 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3719934vqr; Tue, 20 Jun 2023 07:49:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Cu0ZRGRXB/77zMdjpp2/FeJ6b3Z96FQzTcuqE7fETd+F3Z5ij2ukLQyIBIZISzUNZAufi X-Received: by 2002:a05:6a20:3cab:b0:106:c9b7:c932 with SMTP id b43-20020a056a203cab00b00106c9b7c932mr3751910pzj.1.1687272566026; Tue, 20 Jun 2023 07:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272565; cv=none; d=google.com; s=arc-20160816; b=f+Uf4Vczmh/nwZ0jHjtRCuNdiZFRP29Ycd9n7DhtS7kTDhUy1bj17yypLLx5Hjjq7h pp50NQPHirUleu92micOaGh2ghWXHmhHb8A9NuRmaajq6+hG10sFJf7u4ZimTsDHoAnz /+on/3saehGE68oinCfT3JyPFBjfbGafy4jxIMYttTWnZIsYcnH3226hkwaY340IB2Ya CtKlzsLGJs24qVtd+CAP9OOdoy8ryfafaO7Tmrj0abN146drb/X25tDHiubCgwgHgvJe ER2Y2YBP54+7TUoACBQKpJ/YzgVs3UMx++Ee4upGfPp/4JYww/dn6tyvjVHDvhinY1Aw l3cQ== 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=h0b0YIYB17R1CroWlAQnnsIlgczUoCqqJ5XRuaXukCs=; b=Rku52MIy8spTvYQcy1egS3cKHyoRb5v0WE/oMjP7RXhfQetO8cYpxwhnP9X5GvNoVQ EVi1KMwrRRUR8Z/CNp4lDp2GzvhDrq2f2wGiQONv0jUNdUZPOcRiY9gywoJym1zk32vH LKfLIAg3O/GJeVsDXsiBSBF0Pqo6+/SRX/fe4qPYOhZ7jOOW5QxbAI88DvfndmQT0FvH X130MeW63oPUwdxsD36i+286uB1S/t1LyMdeuWIn6L9XW/lwLH/TOg1GbteoFI0r3exX yelsnGt4RG4oQ6AiGfPqisyJiCHYyZayeGdX7FUwVmvHuisleCBYSnD/e4nB7ofi+5bH FwaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UqAnlJ9Q; 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 x8-20020aa78f08000000b0064d3e917a90si1859723pfr.180.2023.06.20.07.49.10; Tue, 20 Jun 2023 07:49:25 -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=UqAnlJ9Q; 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 S233341AbjFTOic (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbjFTOiV (ORCPT ); Tue, 20 Jun 2023 10:38:21 -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 0F1F9E9 for ; Tue, 20 Jun 2023 07:38:13 -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 63EDD612B3 for ; Tue, 20 Jun 2023 14:38:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E9DFC433C8; Tue, 20 Jun 2023 14:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271892; bh=tFkotdkhiC7Dc/uydpF48UD6by1VX5xbM1E1VxLhda0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UqAnlJ9QkMtCwDmB0JEbxrxHh3Qj6O86MGD6zjrUOyLLbHs2hxj3MFzVJ3nS+izzc ug0nB1Zy/JN3CuqZsYQ2jX2mA1W4UQLTcFFYRTIiYpbnx9U1sInk9iuXAFWeikXDR2 mcpxQm5Si1xgd30uHooD+sDpZ4Ju9KEwosYfVfMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Sudip Mukherjee , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 6/9] ppdev: make ppdev_class a static const structure Date: Tue, 20 Jun 2023 16:37:57 +0200 Message-ID: <20230620143751.578239-15-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=2563; i=gregkh@linuxfoundation.org; h=from:subject; bh=RScdqnuDgdDIu1FDdnJ5Y/jzLaX0n+VXhC5pKgEW+3U=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx6oTfUT8Z37627IZK5t2kcC29Y6Z1wyyzp8u9Tc4 8Crkq9XO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiZjwM87R3lF9zncQ3XSkx lWnzu2luJZ+uZTIsmLeSW+D4qfmCuS/3P/rLduFs+tercgA= 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?1769233518034584292?= X-GMAIL-MSGID: =?utf-8?q?1769233518034584292?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the ppdev_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: Sudip Mukherjee Cc: Arnd Bergmann Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/ppdev.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 81ed58157b15..4c188e9e477c 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -773,7 +773,9 @@ static __poll_t pp_poll(struct file *file, poll_table *wait) return mask; } -static struct class *ppdev_class; +static const struct class ppdev_class = { + .name = CHRDEV, +}; static const struct file_operations pp_fops = { .owner = THIS_MODULE, @@ -794,7 +796,7 @@ static void pp_attach(struct parport *port) if (devices[port->number]) return; - ret = device_create(ppdev_class, port->dev, + ret = device_create(&ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), NULL, "parport%d", port->number); if (IS_ERR(ret)) { @@ -810,7 +812,7 @@ static void pp_detach(struct parport *port) if (!devices[port->number]) return; - device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); + device_destroy(&ppdev_class, MKDEV(PP_MAJOR, port->number)); devices[port->number] = NULL; } @@ -841,11 +843,10 @@ static int __init ppdev_init(void) pr_warn(CHRDEV ": unable to get major %d\n", PP_MAJOR); return -EIO; } - ppdev_class = class_create(CHRDEV); - if (IS_ERR(ppdev_class)) { - err = PTR_ERR(ppdev_class); + err = class_register(&ppdev_class); + if (err) goto out_chrdev; - } + err = parport_register_driver(&pp_driver); if (err < 0) { pr_warn(CHRDEV ": unable to register with parport\n"); @@ -856,7 +857,7 @@ static int __init ppdev_init(void) goto out; out_class: - class_destroy(ppdev_class); + class_unregister(&ppdev_class); out_chrdev: unregister_chrdev(PP_MAJOR, CHRDEV); out: @@ -867,7 +868,7 @@ static void __exit ppdev_cleanup(void) { /* Clean up all parport stuff */ parport_unregister_driver(&pp_driver); - class_destroy(ppdev_class); + class_unregister(&ppdev_class); unregister_chrdev(PP_MAJOR, CHRDEV); } From patchwork Tue Jun 20 14:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110542 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3721949vqr; Tue, 20 Jun 2023 07:52:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tcJkYRmSvVpxELBT0Ml/0hP9fiIZKhv3Tiuf7dtNQV1rbY65b6I6l/KGdX4g9pg3GZfzh X-Received: by 2002:a05:6a20:9192:b0:10f:be0:4dce with SMTP id v18-20020a056a20919200b0010f0be04dcemr15993131pzd.8.1687272759204; Tue, 20 Jun 2023 07:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272759; cv=none; d=google.com; s=arc-20160816; b=FIDmnrYy3MeZbB5KEUlQ+JoQ9zmMXxGAaBFh44yNjgzENvAgoOAjIHW/Mj4UIjCXMt LZaMP6PwyVr92crPbvfG0UqRzMNQZc7wiAm40+7dlq7H0QK6AXHCgEBPV9ayfFvmkEDA revRbkJItW+kXT7GMf8aTeMBkrxUAXxN76II2qYDEZeolbus/8LXA2t8pYoJ9EMwgTuK Vsf0mc2pf42kOBjLYt7U5LPEia9ujLgOSKZBmWU1L5KTvh7wAXNF+H5v9UYyU87ekSi+ wDnXldACEaRErzKGyIyXy3B3ISkvMjUyJ5SLka4UsotiHEPcAi6IIQ5TC7Q/x7rZxYEj Z3hg== 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=wz0VFNqs9pB7oCFDgnYVKGkc4BSL+ghB6yoV7a1blOY=; b=wABz6ZCzlkGBCnuaL7Z0DlllE2G6PiW4ucqiKBo90bJ2X/8SMSTSDWbvs4Zsh4xmOD Zi+40xavtFTItsxMOHBplpDhujpLzs4o9TqMN3Klde1uFgz+Z1bCusA4LoEP4A6mQkCd RQZ+axcGAMPn5Q57XZaYH5tzGxXA9tYrzMdYUFEE4MBscYrwfUvTXFJ+AsIckEDPCnM+ +9MoUUgqvswo3gPrBbTTZFfmQkUEV886ANKycUaPTi//jZtDX9RrzyggFpKo6gURfNuB 2L23WPLJ7b/nO8nO0Hu9wSn2GZC34xfHiF5w21v3tmm81K0EPYdOoS5ZLBuD6zzf4uqd 8WDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1/VVDyNP"; 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 r7-20020a63e507000000b004fb8abdd188si1779017pgh.115.2023.06.20.07.52.26; Tue, 20 Jun 2023 07:52:39 -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="1/VVDyNP"; 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 S233384AbjFTOim (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233378AbjFTOi2 (ORCPT ); Tue, 20 Jun 2023 10:38:28 -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 992B8199B for ; Tue, 20 Jun 2023 07:38:16 -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 2A017612B1 for ; Tue, 20 Jun 2023 14:38:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A7E2C433C9; Tue, 20 Jun 2023 14:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271895; bh=PAixi759Cz1x+tiJzMc3suOwGcDgCCsJLx/WttsdMWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1/VVDyNPTy6shHFXNSyLza0tEw+ynXaKDdMVpC6amPiWtuJnqDJBoB4JMvwC/YQ2+ w8Xtdsc1KhRZsZi2y7msPOArg762c6WPHih7R9DgCoe13wWWGWNbc0CxlZvTDTVot5 r/A9C1JKzIBSzdIYBP77KaCXWYfT4eQpYrlgvqXc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Amit Shah , Arnd Bergmann , virtualization@lists.linux-foundation.org, Greg Kroah-Hartman Subject: [PATCH 7/9] virtio_console: make port class a static const structure Date: Tue, 20 Jun 2023 16:37:58 +0200 Message-ID: <20230620143751.578239-16-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=3508; i=gregkh@linuxfoundation.org; h=from:subject; bh=nRhWIu09KBDqvQssi6osu1p4RellAMun0YZOyYbob5w=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx4wjtUKP3DdcUau9qOZotND0y2UwqzCIjZG8D/R/ lgTUX6pI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZyKJdhvn/LtuVmYSmGPKqv znJs3T+Pg23RZ4b5+Z4m4We/c2obOEXz/K+WO7lbNfQaAA== 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?1769233720558216594?= X-GMAIL-MSGID: =?utf-8?q?1769233720558216594?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, remove the class field of the ports_driver_data structure and create the port_class static class structure declared at build time which places it into read-only memory, instead of having it to be dynamically allocated at load time. Cc: Amit Shah Cc: Arnd Bergmann Cc: virtualization@lists.linux-foundation.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/virtio_console.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index b65c809a4e97..1f8da0a71ce9 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -40,9 +40,6 @@ * across multiple devices and multiple ports per device. */ struct ports_driver_data { - /* Used for registering chardevs */ - struct class *class; - /* Used for exporting per-port information to debugfs */ struct dentry *debugfs_dir; @@ -55,6 +52,10 @@ struct ports_driver_data { static struct ports_driver_data pdrvdata; +static const struct class port_class = { + .name = "virtio-ports", +}; + static DEFINE_SPINLOCK(pdrvdata_lock); static DECLARE_COMPLETION(early_console_added); @@ -1399,7 +1400,7 @@ static int add_port(struct ports_device *portdev, u32 id) "Error %d adding cdev for port %u\n", err, id); goto free_cdev; } - port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, + port->dev = device_create(&port_class, &port->portdev->vdev->dev, devt, port, "vport%up%u", port->portdev->vdev->index, id); if (IS_ERR(port->dev)) { @@ -1465,7 +1466,7 @@ static int add_port(struct ports_device *portdev, u32 id) free_inbufs: free_device: - device_destroy(pdrvdata.class, port->dev->devt); + device_destroy(&port_class, port->dev->devt); free_cdev: cdev_del(port->cdev); free_port: @@ -1540,7 +1541,7 @@ static void unplug_port(struct port *port) port->portdev = NULL; sysfs_remove_group(&port->dev->kobj, &port_attribute_group); - device_destroy(pdrvdata.class, port->dev->devt); + device_destroy(&port_class, port->dev->devt); cdev_del(port->cdev); debugfs_remove(port->debugfs_file); @@ -2244,12 +2245,9 @@ static int __init virtio_console_init(void) { int err; - pdrvdata.class = class_create("virtio-ports"); - if (IS_ERR(pdrvdata.class)) { - err = PTR_ERR(pdrvdata.class); - pr_err("Error %d creating virtio-ports class\n", err); + err = class_register(&port_class); + if (err) return err; - } pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL); INIT_LIST_HEAD(&pdrvdata.consoles); @@ -2271,7 +2269,7 @@ static int __init virtio_console_init(void) unregister_virtio_driver(&virtio_console); free: debugfs_remove_recursive(pdrvdata.debugfs_dir); - class_destroy(pdrvdata.class); + class_unregister(&port_class); return err; } @@ -2282,7 +2280,7 @@ static void __exit virtio_console_fini(void) unregister_virtio_driver(&virtio_console); unregister_virtio_driver(&virtio_rproc_serial); - class_destroy(pdrvdata.class); + class_unregister(&port_class); debugfs_remove_recursive(pdrvdata.debugfs_dir); } module_init(virtio_console_init); From patchwork Tue Jun 20 14:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3723930vqr; Tue, 20 Jun 2023 07:55:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hsOiLNsSxuksKWatlkL8tzvC+hih3dn5SDVBaMMbL/V1HjsSUGb0pC82PiEw4ss8ZZ1h4 X-Received: by 2002:a17:902:e801:b0:1b5:4262:ec7b with SMTP id u1-20020a170902e80100b001b54262ec7bmr11639250plg.27.1687272950557; Tue, 20 Jun 2023 07:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272950; cv=none; d=google.com; s=arc-20160816; b=Z+/jc6VAKJrJb3PFYYSUo9YHWh9hDhD95apwp0QYCoaMQ2Db70kP8E1E+vs7RDE3gF FLRhyTDO4ruOyHxMNGuSq0WvBAhF3UU9BjvOAyUmltnLSo/sVAeNQknBoEQuCOH2xkPq ke4wvObnxo+tt8UYGUSbO6hCvfLQCrgNnDQfZ4TDCe28FxLJAHrzO4PdsVcHDW1s5c0f Ny4udpQ1GpeALlpmhQef/96usPXQHmRGBa7Yuq8IXxwQumjc7JcpdalFuFIKgd1b3DAD GnvGsKASuD7p3rWbOjzdUzG33nMnDYAZ66NJcdmJQFXZAG2cBULA7QHJ3Q3WnQx4eyTW u26g== 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=+7n2o4LWgFUHuOUo+J8sjjh0yt87M0Uw6YI1d3ritK4=; b=cKhy7qFY7S/Hlclg3zXTQ564pJvU8lbX7ApypAxW2j0N3S5kIarywYMUaWpJUyJEVU AhPwgHbaAZiBOaBks3kk50Zk/s7Dj7XdwaaeM3MXs5npeioVvoa8Qskh5Q6XAXJMz61G tDwasdnkfi3ufEeZn9sV8FnkCUVLyGgnHN8CyHP5FcBYMlVcEkeoc9KJfgu0mZcxJ3t1 Kkuv/Sb6zwW/B/DTnklTUJMr4JF92chQNtY1j85HprumTT/wTLb5435Zy3jcDXJL7g8u UVw3zfkcjTfrWb7NGzsp5ql/ZqPpSLEkboD58vo295bhR3JLB5q3VQTDe+zm/3y+Svg/ OjBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=svs41yi6; 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 y5-20020a170902700500b001afb1e9b2dfsi1923323plk.484.2023.06.20.07.55.37; Tue, 20 Jun 2023 07:55:50 -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=svs41yi6; 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 S233365AbjFTOio (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233392AbjFTOi2 (ORCPT ); Tue, 20 Jun 2023 10:38:28 -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 5FF0A172B for ; Tue, 20 Jun 2023 07:38:19 -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 E67616127D for ; Tue, 20 Jun 2023 14:38:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0506CC433C8; Tue, 20 Jun 2023 14:38:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271898; bh=r01Ce+uFN5l69uwQajJdVCAt0c3WpiUEnlsvOOYEMa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svs41yi6oaWZeeC6/Ryxenj1XnC0Rbb8E7tRjVu8pX2CXPcsnsojqjPZBSQo/Mgw5 vcW2pGhbZnxK0WlNw1xRKPSj6S06tVSHC0hwpOvwMYOIFo+8+5JguS8/myEPCi5E0t ZIr5zkDde4bYkzH4fdksU6ItLabxH0rtizCmUUSA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Michal Simek , Benjamin Tissoires , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman Subject: [PATCH 8/9] xilinx_hwicap: make icap_class a static const structure Date: Tue, 20 Jun 2023 16:37:59 +0200 Message-ID: <20230620143751.578239-17-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=2451; i=gregkh@linuxfoundation.org; h=from:subject; bh=/cyDMgy52LAJMOSZNEeNJ5NFiqDPHi3FK27Ni2u6me8=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx7gZzz158bZT2UKbaxJJ39ySizelqmeHXs0Uc+1r Vj1VMeejlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIXAfDgv32fOfZXk/smF+l 8PfjRgX38uN7LjEsuNlin+hw9/nb4CMPbzyTkDGp/HhNEwA= 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?1769233921345406632?= X-GMAIL-MSGID: =?utf-8?q?1769233921345406632?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the icap_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: Arnd Bergmann Cc: Michal Simek Cc: Benjamin Tissoires Cc: Ivan Orlov Cc: linux-arm-kernel@lists.infradead.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index a46f637da959..527153313a30 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -113,7 +113,9 @@ static DEFINE_MUTEX(hwicap_mutex); static bool probed_devices[HWICAP_DEVICES]; static struct mutex icap_sem; -static struct class *icap_class; +static const struct class icap_class = { + .name = "xilinx_config", +}; #define UNIMPLEMENTED 0xFFFF @@ -687,7 +689,7 @@ static int hwicap_setup(struct device *dev, int id, goto failed3; } - device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); + device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); return 0; /* success */ failed3: @@ -730,7 +732,7 @@ static int hwicap_remove(struct device *dev) if (!drvdata) return 0; - device_destroy(icap_class, drvdata->devt); + device_destroy(&icap_class, drvdata->devt); cdev_del(&drvdata->cdev); iounmap(drvdata->base_address); release_mem_region(drvdata->mem_start, drvdata->mem_size); @@ -856,7 +858,9 @@ static int __init hwicap_module_init(void) dev_t devt; int retval; - icap_class = class_create("xilinx_config"); + retval = class_register(&icap_class); + if (retval) + return retval; mutex_init(&icap_sem); devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); @@ -882,7 +886,7 @@ static void __exit hwicap_module_cleanup(void) { dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); - class_destroy(icap_class); + class_unregister(&icap_class); platform_driver_unregister(&hwicap_platform_driver); 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);