Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7919636rwd; Tue, 20 Jun 2023 07:56:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zIfhQgyhzdKu8qZ45eaTw1U/jf1vgu5oTkAEyaQ6MazDeSJ3WnJH1PimydI0WOwFYW78s X-Received: by 2002:a17:902:e548:b0:1b6:788a:551d with SMTP id n8-20020a170902e54800b001b6788a551dmr3071477plf.44.1687272991998; Tue, 20 Jun 2023 07:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687272991; cv=none; d=google.com; s=arc-20160816; b=Cbqokir5r6HURuZayzrGZ7KyoO+215sT57M2AW0XEf/aom4UJc+70WVm487KUtXqnX OhZfW+iHz6QFrbhmg6o4+ujoFXrej8q5R8skLStLOkr6oqXvnBn3jkZKXiWr5Te24ssl DgoGaRnoLggJd7PquJa7mGGp0LjeqEfqa6B1zEJbZlrm0CnZwUMDl0Ab9r1m1oVXzrmR mrw9V8/VOuJpchPE10AKzNNVkbw7/DuuRrZtb7aAoK5fXAegdNxgM8q/0UbSi2gfo0vc /fZ7iK+diijzKyZqkgKe0c3O/XWKKcePBKPa8NELzxVA4ddzMRlLfJYbCWY3RWAHAJV+ byZA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a17090340c200b001b19ceca240si2029999pld.169.2023.06.20.07.56.19; Tue, 20 Jun 2023 07:56:31 -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 S233348AbjFTOiP (ORCPT + 99 others); Tue, 20 Jun 2023 10:38:15 -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 Content-Transfer-Encoding: 8bit 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 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); } -- 2.41.0