From patchwork Tue Oct 24 11:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 157396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1882237vqx; Tue, 24 Oct 2023 04:49:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYViAe6As4UXVAWhEh7CbNVZxNhuVuvWULmLXmL76SVrm8u/okkyKgAKeiVs5MeRFeeRi3 X-Received: by 2002:a05:6870:3b11:b0:1e9:c86f:4d72 with SMTP id gh17-20020a0568703b1100b001e9c86f4d72mr15206700oab.45.1698148163928; Tue, 24 Oct 2023 04:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148163; cv=none; d=google.com; s=arc-20160816; b=ydmo8cvMf6/pHnY7PkKC+/GgtOpIoTNqQvrVaqAJNiOui2zVvjRvU4GyVM8mXzFVhw w1XDu1YEZvD73prHWcbD0emTHBIoQwd1MY1jnpAW6MBNuTXUyPueHDbuowXzsllCHZMt YQI88OXxohRPePyHM+N13rg7I1W38MUBOIXQ4QaCcrCzoZ49kzs2XlyOmdZMzUVnQ3bP y7g8TnPiOEXqMhyOdBGaNvzKLADZtNYqcKltQo+G6WiVhR9Nk/MY1Hi5hiDdg8vGtW9o eo7Iv9eDLQA51V2VJ+f/M6MIkTHJlzYEb9xXtE6AgxeCZh/hTNlH8dwueJ0Si+BwhzSo 9DDg== 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=pUKew86cYNWvUpLZ0bGMFDHjsHQJIhobQ+tLb3s5S/Y=; fh=YKRbR53MwEIx2ucp3xxJRvecHW/1KfQ8x6RVk6NHtDM=; b=konabYFSQpbXdFNQMf3UXdDN4X/Ha4RliweqhuycFqObajkJ3RiMwMQFv6U20cs+Vi p41YdTDpo6pa/wj3o2UPf0th8iEw9w/G9L6tvfeCvXNw8NHaCWtp9g7zJeI8vQuJ8A4X jsAX6Rr6yqDdLHDGC2CrqP/y44h8H6HBP7PUcdxR250GJw0fT9ibF3219blMv2TeCD2B r7+qIcjg9qN4omNpMC4zM4lTB9q6LvRs0KHsA+n3wHdOcJ4OtEb58huN5P5zeZADNJlm qF+s5zostAUAsGVKXwBmmosiNDi4US6PgzSZXbruPxge48aM+JIbWZ0NecpYAPRWfqe+ XcfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G7VO1jY9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ck28-20020a056a02091c00b005b869e53b1csi8119766pgb.797.2023.10.24.04.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G7VO1jY9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 A996E809C19F; Tue, 24 Oct 2023 04:49:21 -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 S232340AbjJXLtN (ORCPT + 26 others); Tue, 24 Oct 2023 07:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjJXLtN (ORCPT ); Tue, 24 Oct 2023 07:49:13 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562C5E8 for ; Tue, 24 Oct 2023 04:49:11 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9814BC433C7; Tue, 24 Oct 2023 11:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698148151; bh=uh6RlcQOJqCtwoPx6bpVBQRNY8pg0lrU9IJZFhh7PEw=; h=From:To:Cc:Subject:Date:From; b=G7VO1jY9L7EzpqVKAqjNTgM/s3KzuvR3NII5/ARtXJ01+rQjwseAjGBJHl2d/2CMo VP7Wh5w6oIF5VM26sja1Py01hRiJCr/KYolxi6HY67qLj8manZmTra7FilufaisCqz ZaFXVSoKP2xRdERtmO7+v7wTeXNfmigj+i1FkcY8= From: Greg Kroah-Hartman To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann Subject: [PATCH] ocxl: make ocxl_class constant Date: Tue, 24 Oct 2023 13:49:04 +0200 Message-ID: <2023102403-squirt-defraud-6c0c@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 91 X-Developer-Signature: v=1; a=openpgp-sha256; l=2567; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=uh6RlcQOJqCtwoPx6bpVBQRNY8pg0lrU9IJZFhh7PEw=; b=owGbwMvMwCRo6H6F97bub03G02pJDKnm6/V9V2cmnqvPEg3YH/AuOlh0hcCi02eXp/POWp9ks i/edoZdRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEyEbS3DgsVvJlccXNnz64ee /YOVX+1SGCNX3mWYySgjU3RdRfXNoSI/zblcm/f/MuVvBwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 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:49:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780637408836590004 X-GMAIL-MSGID: 1780637408836590004 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: Frederic Barrat Cc: Andrew Donnellan Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Greg Kroah-Hartman Acked-by: Frederic Barrat --- drivers/misc/ocxl/file.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index 6e63f060e4cc..ac69b7f361f5 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -14,7 +14,6 @@ #define OCXL_NUM_MINORS 256 /* Total to reserve */ static dev_t ocxl_dev; -static struct class *ocxl_class; static DEFINE_MUTEX(minors_idr_lock); static struct idr minors_idr; @@ -509,6 +508,16 @@ static void ocxl_file_make_invisible(struct ocxl_file_info *info) cdev_del(&info->cdev); } +static char *ocxl_devnode(const struct device *dev, umode_t *mode) +{ + return kasprintf(GFP_KERNEL, "ocxl/%s", dev_name(dev)); +} + +static const struct class ocxl_class = { + .name = "ocxl", + .devnode = ocxl_devnode, +}; + int ocxl_file_register_afu(struct ocxl_afu *afu) { int minor; @@ -529,7 +538,7 @@ int ocxl_file_register_afu(struct ocxl_afu *afu) info->dev.parent = &fn->dev; info->dev.devt = MKDEV(MAJOR(ocxl_dev), minor); - info->dev.class = ocxl_class; + info->dev.class = &ocxl_class; info->dev.release = info_release; info->afu = afu; @@ -584,11 +593,6 @@ void ocxl_file_unregister_afu(struct ocxl_afu *afu) device_unregister(&info->dev); } -static char *ocxl_devnode(const struct device *dev, umode_t *mode) -{ - return kasprintf(GFP_KERNEL, "ocxl/%s", dev_name(dev)); -} - int ocxl_file_init(void) { int rc; @@ -601,20 +605,19 @@ int ocxl_file_init(void) return rc; } - ocxl_class = class_create("ocxl"); - if (IS_ERR(ocxl_class)) { + rc = class_register(&ocxl_class); + if (rc) { pr_err("Unable to create ocxl class\n"); unregister_chrdev_region(ocxl_dev, OCXL_NUM_MINORS); - return PTR_ERR(ocxl_class); + return rc; } - ocxl_class->devnode = ocxl_devnode; return 0; } void ocxl_file_exit(void) { - class_destroy(ocxl_class); + class_unregister(&ocxl_class); unregister_chrdev_region(ocxl_dev, OCXL_NUM_MINORS); idr_destroy(&minors_idr); }