From patchwork Thu Oct 5 13:48:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 148816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp390889vqb; Thu, 5 Oct 2023 08:49:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPfV8LVYpnnsst1V1oDcfk24BYaUrJal0ng9lUB9m1vIJ2A81oJ6pzjlfkQ7W+b4Czxea/ X-Received: by 2002:a05:6a20:8419:b0:161:2389:e34b with SMTP id c25-20020a056a20841900b001612389e34bmr7112282pzd.13.1696520980919; Thu, 05 Oct 2023 08:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696520980; cv=none; d=google.com; s=arc-20160816; b=BzsK2lktWpeQgo2RF4bzO0smertlNQ+mbcPK3NPwnXFLX+gwt5nRIixfcYsk9TZRim 1TV5HpYJWmxkuObu3qFXZf01pi+JrC4H+fIXjcIRLGLk1u88rJSANrt52HaWuGnONBM7 /dlKGtpXF9zaDwugvcCnc38kxnFtsYIVzqyK1Ptwey/51F7F5fTgZVV6JSZy4dSQX65A rhdXDdr6VqSdCI12IGp7EWDPiyE8V2jzYsSOsvK5DGfHtqjX8PqCgyBv4gdK0sEf+8nZ eG/C9vYlovJfIaF6k70dWdzPwf9NGPsvlnKBwwNuQCsQKcjylW3xwLeAktzUMm7tXeO5 fAig== 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=Xeuac6N8hOPQSurmeouiAUAwHWThtTIvyA2HgjZz5Nw=; fh=QUHXZmb6Jp0OmFlHz0ejxu3TcFROAX6yUVJCHHll3NI=; b=Sif9aqmRQpU/5VnZyRw+dNk5d0Dg7w1u16KosSzMNQ47EGVEdtdu+3I2qRGuyBwjs2 4H5SILGEIi29RdZlWKB0D7gln5G48oZ9ZKZ80WiXTcYC+hZmBbh9M+0xp4Hr/6p3zE1H /QWo9zGIrSVvtWvm6f0xYEbrVis9QqisZiB1WtRpx578oA6U2JRJsKHrLxiXRO6tT2nv pY9SaOAAp6emKxoQ1jX6nBfYqOzerXHdClLjcq5ClUEEH8hEbDJeMbK+1meInKhJX7qM q7X8ESYwF06K5ZkS6jRuUctbOe+spQ+ewGEQMCa00fHucYAzIh815qmvG0a2upi3WR7T y+jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NZ902NtZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o4-20020a170902d4c400b001c58401354dsi1839683plg.565.2023.10.05.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:49:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NZ902NtZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 00BF98260C1A; Thu, 5 Oct 2023 08:49:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbjJEPtC (ORCPT + 19 others); Thu, 5 Oct 2023 11:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbjJEPsH (ORCPT ); Thu, 5 Oct 2023 11:48:07 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E128E5 for ; Thu, 5 Oct 2023 06:48:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A5A9C4AF7D; Thu, 5 Oct 2023 13:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696513695; bh=YNPCSFK5hnyZDO7MvaXjiiobmN82ObhVxMuqrZ9wupw=; h=From:To:Cc:Subject:Date:From; b=NZ902NtZEofXAiUY+kOfYtSJY3FDmqXdy6GRZTV0s1p4NtutDCwrJoRtPdh/dVnfD mZ2C48GnS1nJk0bb7eqHIuGHiNAjNkHkwY+TIInXM8RcDfW1w4gzFk4D8Rq7/57cr0 jKNOCneQBNCfwLVKSuSz1RvEPerQy8EQNE5IsxtQ= From: Greg Kroah-Hartman To: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH] staging: pi433: make pi433_class constant Date: Thu, 5 Oct 2023 15:48:12 +0200 Message-ID: <2023100512-basically-pedometer-9ed9@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 87 X-Developer-Signature: v=1; a=openpgp-sha256; l=2882; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=YNPCSFK5hnyZDO7MvaXjiiobmN82ObhVxMuqrZ9wupw=; b=owGbwMvMwCRo6H6F97bub03G02pJDKly++ZceFP1LGLWymkXVksu1+Azjyl7HRBve7HwWKv51 Ykz/fL6O2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiS8sZ5tn8f/S+LmNBzcHX 1RIbK6QeB7nq3mZYMMGrX9Rmoe+cnnt1WosX7urZM/PHJwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-0.8 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:49:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778931183666215637 X-GMAIL-MSGID: 1778931183666215637 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 --- 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..11982bf398be 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_destroy(&pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); debugfs_remove(root_dir); }