From patchwork Tue Jun 20 18:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3872420vqr; Tue, 20 Jun 2023 11:56:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46skfM49IQ1laecAR+MGVVaOwQcEjOPyBffORPzJbZ5dPHXCNhtbFq8h7EqNb6/oIJsg0G X-Received: by 2002:a05:6808:1303:b0:3a0:3495:c8d4 with SMTP id y3-20020a056808130300b003a03495c8d4mr4975930oiv.28.1687287365591; Tue, 20 Jun 2023 11:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687287365; cv=none; d=google.com; s=arc-20160816; b=RAqgB24TxMfMGK2StKWBTCEq+CzXmSkBz868mtnigPoeAETABueG61yQzSmo6NCHii w+vhIC31cdo5nBzk3Loe511PrQ+7IBP7IPrra6abL6B8AWwDd1eDtR7/m2zIxWWdUuK9 D+lD6Dkk1AiV/R641MXPlegHb4yGNfQEYoSmRofndJy2I/XWmqje2bwI7V218x7dYcPk 26vr6RgztFOPvU4pUQYXWvTmDuOB6GdKYtta7m0brkVyL1+vA0A0epJMElH89a5QElaK Qum5CsADXxHNQCAclZQM2gUPV67Pbvf9o3l7gbIvaqGmi21fNKpa42KwZdtCJkPM8M8Y H+0g== 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=/UU3B+W20Rq2Rkpx6T5ZLRi2HDgZorqHKWIX7XrOG7I=; b=U9qSt9zTgVwMckDnAcujI4DxX7Nvfda1OQVnmAbb4rs85q3DGwHT2SwQb9gROgQA9Z ugMms4c02dXKqP492ZhVMKBLaco7FCqoU7MiHmjdG28aK3StJXVE/3GcE8zjZiOgjdjW QVDpB8Jq0ZRxXtH2NqoWtpDH1Hp08ieVHCFfuHQDUa9H77LjpOrFE0GcW+w2jeiGNDjU vOoVEpZB3fOZaGfCMiMrjDkoOdOXVyi5OQxg3Qw7K/jYTLzZB2i6VPGt1tqUaalYBsFX 1AEA6uENPfPo/suCZ232pKF+IhNSoTRUoVH/jPdnZ0UzgTrys0SpIuxOljXuCOpOkrLt NY3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1PLSkGkI; 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 d30-20020a63735e000000b0055392732f62si2485519pgn.495.2023.06.20.11.55.51; Tue, 20 Jun 2023 11:56:05 -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=1PLSkGkI; 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 S229971AbjFTSe5 (ORCPT + 99 others); Tue, 20 Jun 2023 14:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbjFTSex (ORCPT ); Tue, 20 Jun 2023 14:34:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F89610E2; Tue, 20 Jun 2023 11:34:51 -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 9D53361376; Tue, 20 Jun 2023 18:34:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A43D9C433C8; Tue, 20 Jun 2023 18:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687286090; bh=YOzPATmO8wGxwInPsNJVCNLX4H1Ef7rZzowHevjjD/s=; h=From:To:Cc:Subject:Date:From; b=1PLSkGkIsZPxpmUHXeKhKsPySfKl8A/ptcE9hebeInjOUIy3rHWsvPBJuqZFg1vUC gEYjlxlCn3fKyaBlDDyExTW37J8QGIYxqszhKuI5zuYGyBivS5DT8sFa3SJ50VHdun OXHHb+Et160zUAD4d2MXqwAE1RgLasXPi6NkPtzk= From: Greg Kroah-Hartman To: sparclinux@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ivan Orlov , "David S. Miller" , Andrew Morton , Jonathan Corbet , Benjamin Tissoires , "Mike Rapoport (IBM)" , Suren Baghdasaryan , Greg Kroah-Hartman Subject: [PATCH] oradax: make 'cl' a static const structure Date: Tue, 20 Jun 2023 20:34:47 +0200 Message-ID: <20230620183446.684061-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2449; i=gregkh@linuxfoundation.org; h=from:subject; bh=iMcb7lPwqLnwJII9WdVDNBIv4TpcWL4faC5ec2Wi5h8=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTP7o9D5+0ouLTn66PoYd+SuYv1j26WX7Z2qUuHlfMx Ccs+lPs2BHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATcehiWHDgu/t3+3VzPVes 9baYEsd16EL0FTmGBUcsjwgfSZj+e92uJzJzmmcaXs6+2AcA 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?1769249036336057719?= X-GMAIL-MSGID: =?utf-8?q?1769249036336057719?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the 'cl' structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: "David S. Miller" Cc: Andrew Morton Cc: Jonathan Corbet Cc: Benjamin Tissoires Cc: "Mike Rapoport (IBM)" Cc: Suren Baghdasaryan Cc: Ivan Orlov Cc: sparclinux@vger.kernel.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman Acked-by: Sam Ravnborg --- drivers/sbus/char/oradax.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c index aafce8d00000..a536dd6f4f7c 100644 --- a/drivers/sbus/char/oradax.c +++ b/drivers/sbus/char/oradax.c @@ -226,8 +226,10 @@ static int dax_ccb_info(u64 ca, struct ccb_info_result *info); static int dax_ccb_kill(u64 ca, u16 *kill_res); static struct cdev c_dev; -static struct class *cl; static dev_t first; +static const struct class cl = { + .name = DAX_NAME, +}; static int max_ccb_version; static int dax_debug; @@ -323,14 +325,11 @@ static int __init dax_attach(void) goto done; } - cl = class_create(DAX_NAME); - if (IS_ERR(cl)) { - dax_err("class_create failed"); - ret = PTR_ERR(cl); + ret = class_register(&cl); + if (ret) goto class_error; - } - if (device_create(cl, NULL, first, NULL, dax_name) == NULL) { + if (device_create(&cl, NULL, first, NULL, dax_name) == NULL) { dax_err("device_create failed"); ret = -ENXIO; goto device_error; @@ -347,9 +346,9 @@ static int __init dax_attach(void) goto done; cdev_error: - device_destroy(cl, first); + device_destroy(&cl, first); device_error: - class_destroy(cl); + class_unregister(&cl); class_error: unregister_chrdev_region(first, 1); done: @@ -362,8 +361,8 @@ static void __exit dax_detach(void) { pr_info("Cleaning up DAX module\n"); cdev_del(&c_dev); - device_destroy(cl, first); - class_destroy(cl); + device_destroy(&cl, first); + class_unregister(&cl); unregister_chrdev_region(first, 1); } module_exit(dax_detach);