Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1828115rda; Tue, 24 Oct 2023 04:50:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFcKsX7KlIxu28+f7xPbEWG6VbZnPqzgDp83IUkqJCSeiTfFeK0qWQbMgBzoIiCNLhz6jj X-Received: by 2002:a05:6a21:6d86:b0:14d:5580:8ff0 with SMTP id wl6-20020a056a216d8600b0014d55808ff0mr2439208pzb.25.1698148203493; Tue, 24 Oct 2023 04:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148203; cv=none; d=google.com; s=arc-20160816; b=wPP9xC69LwpQ/8oK37ZmGWVyFBY/cSKY5btdjqQV5yfyzPyscqLVz+xCAfbcoKEPT6 zRBbVdZ7egRoekVRu6o8EFKMXpseGVQuRvBvKha7m0VGINvzc5rYocf9tEAb7ImJPIsF ZGuz+mvR21CpjvTZ2Ml+z8Ka92Z8rbPB3QVv7e35FFw4ImB7BwJyn6qEk2dq2z0RLKKk W6JH5hu8KFV7tMp4zaqQCSHxBEyQMXud0HAy+4Cjw3tpT+yUE69/Dga9oWGMsxrHzyaU 8Iq/D56th88DHQo9bchG4qpDJ7XgwIpL34NrpO3x7fRSvBMfWzcqvtbmEKt6Iew0ff+T EMcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:lines:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=b2hsyeEhTA+PjveKiVcnDOVGI4DRwdncQZwS6Wph/9g=; fh=ffktVE3f7gpfLmazsX4+LtdeLqmW8gBIZfiEFwOC+Ys=; b=XqKvUQR4jkNiIOBmMvhGzjWl7ejcrabHKA9sb5PJLl/FQ+2hMdjVl6APBH0MJnZnXN p4tSOl75KEiTJm3qGe/bzIuSxVFvdFWgJVpMUq4rgK4a8wgtacNvJsOlxOuvgNJe0rJD iC7Hbawpvf6S0JDFA1DhcwdP71ds8+y0KYqq7lCF27EZHx80FjwaggikJLHtD3RYNyRt kKIldOnT5oTGBd6fYBgylBNy5vvvp5/pKn8GL6nyX8wzoAXRqy5oxsXQjgLvFER/lyjr 3B8LCFITtr1Aj2fiZPNQDgeBQxO8jbft5DQ2fNDdvrTeOMooON+wWun3Att5yivvIAHj qw7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oUl50Rln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y7-20020a056a00180700b0068fb8fa1e71si8273743pfa.207.2023.10.24.04.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oUl50Rln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 12F768031D01; Tue, 24 Oct 2023 04:50:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232868AbjJXLtp (ORCPT + 99 others); Tue, 24 Oct 2023 07:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbjJXLtm (ORCPT ); Tue, 24 Oct 2023 07:49:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A33BD68 for ; Tue, 24 Oct 2023 04:49:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68D36C433C9; Tue, 24 Oct 2023 11:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698148179; bh=RFEW0IrG/GLK3zFE/JBiSjLyYrjcUnQ1ctTkDI+K4iY=; h=From:To:Cc:Subject:Date:From; b=oUl50Rln5rMrhOE94PtHwoanPSVlhfV+Tx8KKTdV1Sk8Xp7pPZW77C9WX/xzaXCcO fFc9dvJoPltC3tpRP2pQI3nBPu41rsUmKpA4fX951kU80jT6yNESNpJc/bHt3CLDio WMFUL39TsXdkgPZatWMRh2eV8ZrE370rodMvqqWg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Arnd Bergmann Subject: [PATCH] misc: phantom: make phantom_class constant Date: Tue, 24 Oct 2023 13:49:35 +0200 Message-ID: <2023102434-font-feast-98e3@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 90 X-Developer-Signature: v=1; a=openpgp-sha256; l=2998; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=RFEW0IrG/GLK3zFE/JBiSjLyYrjcUnQ1ctTkDI+K4iY=; b=owGbwMvMwCRo6H6F97bub03G02pJDKnm6/24Lu6uM9EVnvjtxiyF/6pv4w7dYHgxu7x6GR/Hg 9gCXZMvHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRlCCG+Zkejut+T75eUxCh 3nB8A6dixe2ZEgzzk3Q98q55tp77/XpO858zT+787hayAAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 04:50:01 -0700 (PDT) Now that the driver core allows for struct class to be in read-only memory, we should make all 'class' structures declared at build time placing them into read-only memory, instead of having to be dynamically allocated at runtime. Cc: Jiri Slaby Cc: Arnd Bergmann igned-off-by: Greg Kroah-Hartman --- drivers/misc/phantom.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 7966a6b8b5b3..30bd7c39c261 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c @@ -35,9 +35,12 @@ #define PHB_NOT_OH 2 static DEFINE_MUTEX(phantom_mutex); -static struct class *phantom_class; static int phantom_major; +static const struct class phantom_class = { + .name = "phantom", +}; + struct phantom_device { unsigned int opened; void __iomem *caddr; @@ -403,7 +406,7 @@ static int phantom_probe(struct pci_dev *pdev, goto err_irq; } - if (IS_ERR(device_create(phantom_class, &pdev->dev, + if (IS_ERR(device_create(&phantom_class, &pdev->dev, MKDEV(phantom_major, minor), NULL, "phantom%u", minor))) dev_err(&pdev->dev, "can't create device\n"); @@ -436,7 +439,7 @@ static void phantom_remove(struct pci_dev *pdev) struct phantom_device *pht = pci_get_drvdata(pdev); unsigned int minor = MINOR(pht->cdev.dev); - device_destroy(phantom_class, MKDEV(phantom_major, minor)); + device_destroy(&phantom_class, MKDEV(phantom_major, minor)); cdev_del(&pht->cdev); @@ -503,13 +506,12 @@ static int __init phantom_init(void) int retval; dev_t dev; - phantom_class = class_create("phantom"); - if (IS_ERR(phantom_class)) { - retval = PTR_ERR(phantom_class); + retval = class_register(&phantom_class); + if (retval) { printk(KERN_ERR "phantom: can't register phantom class\n"); goto err; } - retval = class_create_file(phantom_class, &class_attr_version.attr); + retval = class_create_file(&phantom_class, &class_attr_version.attr); if (retval) { printk(KERN_ERR "phantom: can't create sysfs version file\n"); goto err_class; @@ -535,9 +537,9 @@ static int __init phantom_init(void) err_unchr: unregister_chrdev_region(dev, PHANTOM_MAX_MINORS); err_attr: - class_remove_file(phantom_class, &class_attr_version.attr); + class_remove_file(&phantom_class, &class_attr_version.attr); err_class: - class_destroy(phantom_class); + class_unregister(&phantom_class); err: return retval; } @@ -548,8 +550,8 @@ static void __exit phantom_exit(void) unregister_chrdev_region(MKDEV(phantom_major, 0), PHANTOM_MAX_MINORS); - class_remove_file(phantom_class, &class_attr_version.attr); - class_destroy(phantom_class); + class_remove_file(&phantom_class, &class_attr_version.attr); + class_unregister(&phantom_class); pr_debug("phantom: module successfully removed\n"); } -- 2.42.0