From patchwork Thu Oct 5 13:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 148828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp395978vqb; Thu, 5 Oct 2023 08:58:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsFrfQrATELt7R4LVkA8ZbKsriLSi2y+57nr02FTtqJEnExZNeKZ+lk+Zr7RZywmaayr9C X-Received: by 2002:a17:90b:3810:b0:26f:ac36:623a with SMTP id mq16-20020a17090b381000b0026fac36623amr2542762pjb.3.1696521512442; Thu, 05 Oct 2023 08:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521512; cv=none; d=google.com; s=arc-20160816; b=uZkEuYuEShBDZ0cmyrfQKSo0DNMFA2w2ALDYDDI2zFRWrWqTXtfPF89Oq64ZCJc9u0 5t/H/imQoU25Gxu1c1Nh0ASclCmAY0tNRXK47+BOjRgK7zle9Y0ELi3LLTcvpsMM42hr iyk57MUatrioLcLcXU1BfIFOXhNoj1c0k7WkYiqfwB230D4K1SxE6rYWD5D+VBWn/F/I seSA4U+UVhO/duEasMvgg/pIkStfsf50P33EX23gQgg3ayms7l+56ZEu+6nPIs8HlZUO XHcCsdAbgI5fYCBCV2H6eL2pac9dc5DisWaNYI/coFxkauGwF4HmGDbFpYGD4xVJ86xL Z2Jg== 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=ski9ghXyPiH5wIXHq2UGDpnPyl3GHP/KZ7HjCsBmkr4=; fh=QUHXZmb6Jp0OmFlHz0ejxu3TcFROAX6yUVJCHHll3NI=; b=Rs5JX/cQHTqSnyOphm/w6HPWHJCnz+6WUAWg2hRnCTi2mAGu5PXo7IPczUX+HsoHNe LRTkrTGFHT+gvQrZixywSrTs+UKOwkzROs9owgWDrZNc1jwKIsGqY85GsLGqURNtSC7H qrWsVbKZhbPFrbpvPLADESA4jUtAIGx4HMNFCvW9ZMddrV7dSJIJWSm8O/JJZJH4QF/E yWwW3mlw78KVZJ7hGYI0ZC1fmInwTPnkXJfCZElSR2eZtGWi2WI2piWA1YBFWfmrjcLm S1M+hxj1/gwSnTljN6Zokh//ZK/Wh6g6WzfaWleWtyQ0YzLmLvd/FTC7dmkTy6+u6BTB GiRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PgDD5hPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bs125-20020a632883000000b00585463c36fbsi1698440pgb.44.2023.10.05.08.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PgDD5hPk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 1870282E53E9; Thu, 5 Oct 2023 08:58:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237915AbjJEP6D (ORCPT + 19 others); Thu, 5 Oct 2023 11:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233133AbjJEP4l (ORCPT ); Thu, 5 Oct 2023 11:56:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300F265AD for ; Thu, 5 Oct 2023 06:55:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760D8C43215; Thu, 5 Oct 2023 13:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696514116; bh=FPF7KAEMlwIOVvDpPTd1/Wuts/J4Yv4RkMVq/HLq2eY=; h=From:To:Cc:Subject:Date:From; b=PgDD5hPkbG9WNVHPRTbjh23Grnci0W6b2O4zsqUjNsNTzs+jonusi/zh2/rJtjj4G KZtZ2wJYNYDn6ED8wyEqrVfRnNuPnl4hxlZF5XX+e+lknot1Hs6wKH/XiLus1tZ3OQ NOY+Nnx2idcb61kytiF9b84O+0eTCTGKH2m3f3Pc= From: Greg Kroah-Hartman To: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH v2] staging: pi433: make pi433_class constant Date: Thu, 5 Oct 2023 15:55:13 +0200 Message-ID: <2023100512-sweat-abruptly-2445@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 89 X-Developer-Signature: v=1; a=openpgp-sha256; l=2941; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=FPF7KAEMlwIOVvDpPTd1/Wuts/J4Yv4RkMVq/HLq2eY=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlyBxy3zuDL5GhjjokNbUzOT/sie8G4YJ//q1fBup7+h rddnjZ0xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwEQeP2GYX1z9ifV6QZbIlzdf jioWnaif9rayjWF+uNhaiW9+wvqP+0KOrlfdfb7C4shhAA== 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,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:58:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778931183666215637 X-GMAIL-MSGID: 1778931740980585074 Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Signed-off-by: Greg Kroah-Hartman --- v2 : properly call class_unregister() in module exit drivers/staging/pi433/pi433_if.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 58887619b83f..0ec3130225db 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -56,7 +56,10 @@ static DEFINE_IDR(pi433_idr); static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ static struct dentry *root_dir; /* debugfs root directory for the driver */ -static struct class *pi433_class; /* mainly for udev to create /dev/pi433 */ +/* mainly for udev to create /dev/pi433 */ +static const struct class pi433_class = { + .name = "pi433", +}; /* * tx config is instance specific @@ -1259,7 +1262,7 @@ static int pi433_probe(struct spi_device *spi) /* create device */ device->devt = MKDEV(MAJOR(pi433_dev), device->minor); - device->dev = device_create(pi433_class, + device->dev = device_create(&pi433_class, &spi->dev, device->devt, device, @@ -1315,7 +1318,7 @@ static int pi433_probe(struct spi_device *spi) cdev_failed: kthread_stop(device->tx_task_struct); send_thread_failed: - device_destroy(pi433_class, device->devt); + device_destroy(&pi433_class, device->devt); device_create_failed: pi433_free_minor(device); minor_failed: @@ -1342,7 +1345,7 @@ static void pi433_remove(struct spi_device *spi) kthread_stop(device->tx_task_struct); - device_destroy(pi433_class, device->devt); + device_destroy(&pi433_class, device->devt); cdev_del(device->cdev); @@ -1398,18 +1401,18 @@ static int __init pi433_init(void) if (status < 0) return status; - pi433_class = class_create("pi433"); - if (IS_ERR(pi433_class)) { + status = class_register(&pi433_class); + if (status) { unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); - return PTR_ERR(pi433_class); + return status; } root_dir = debugfs_create_dir(KBUILD_MODNAME, NULL); status = spi_register_driver(&pi433_spi_driver); if (status < 0) { - class_destroy(pi433_class); + class_unregister(&pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); } @@ -1422,7 +1425,7 @@ module_init(pi433_init); static void __exit pi433_exit(void) { spi_unregister_driver(&pi433_spi_driver); - class_destroy(pi433_class); + class_unregister(&pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); debugfs_remove(root_dir); }