From patchwork Tue Jun 20 14:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13285985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B38E3EB64D7 for ; Tue, 20 Jun 2023 14:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AN28z9uw1LBSdvkKEr/YrNcjyimtClR5oEXQIfnIq2I=; b=lTamF7nvyTzwSb lvv59igrwtBtWRa/b3huOn9aGCRBq8w51kSdJ2lG5R1t0MxSiKvF9xrRJAXtXebwI0ktON0m8ButF lx4eK+4itGlv4GM5ul9JrisolgaIB0cFQrUvKwLU7BexVCUOeXuukkSEjdPoA/ilLWFtw3ZbgW1UD fbjb8pOsLn9lLQxNpY+pREbqiyRnvPBXt2VPNff3TfaGkymCuEn1NElUb/+JtOu/XEnKamNmv9d2+ LjMc8/K8MQmiuCsWgOr4XD8mIWCt62qkMkq+Z3mn2JCs03EPc0h77lgNoWQW1JV2N/uRzb+CcrXEO SLudkpuFrctbSF6AOk7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBcUw-00BYAQ-03; Tue, 20 Jun 2023 14:38:22 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBcUt-00BY9U-1U for linux-arm-kernel@lists.infradead.org; Tue, 20 Jun 2023 14:38:20 +0000 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 E9ABD612B3; Tue, 20 Jun 2023 14:38:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0506CC433C8; Tue, 20 Jun 2023 14:38:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687271898; bh=r01Ce+uFN5l69uwQajJdVCAt0c3WpiUEnlsvOOYEMa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svs41yi6oaWZeeC6/Ryxenj1XnC0Rbb8E7tRjVu8pX2CXPcsnsojqjPZBSQo/Mgw5 vcW2pGhbZnxK0WlNw1xRKPSj6S06tVSHC0hwpOvwMYOIFo+8+5JguS8/myEPCi5E0t ZIr5zkDde4bYkzH4fdksU6ItLabxH0rtizCmUUSA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Ivan Orlov , Arnd Bergmann , Michal Simek , Benjamin Tissoires , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman Subject: [PATCH 8/9] xilinx_hwicap: make icap_class a static const structure Date: Tue, 20 Jun 2023 16:37:59 +0200 Message-ID: <20230620143751.578239-17-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620143751.578239-10-gregkh@linuxfoundation.org> References: <20230620143751.578239-10-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2451; i=gregkh@linuxfoundation.org; h=from:subject; bh=/cyDMgy52LAJMOSZNEeNJ5NFiqDPHi3FK27Ni2u6me8=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTdx7gZzz158bZT2UKbaxJJ39ySizelqmeHXs0Uc+1r Vj1VMeejlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIXAfDgv32fOfZXk/smF+l 8PfjRgX38uN7LjEsuNlin+hw9/nb4CMPbzyTkDGp/HhNEwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230620_073819_585016_F99FB258 X-CRM114-Status: GOOD ( 14.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the icap_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: Arnd Bergmann Cc: Michal Simek Cc: Benjamin Tissoires Cc: Ivan Orlov Cc: linux-arm-kernel@lists.infradead.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index a46f637da959..527153313a30 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -113,7 +113,9 @@ static DEFINE_MUTEX(hwicap_mutex); static bool probed_devices[HWICAP_DEVICES]; static struct mutex icap_sem; -static struct class *icap_class; +static const struct class icap_class = { + .name = "xilinx_config", +}; #define UNIMPLEMENTED 0xFFFF @@ -687,7 +689,7 @@ static int hwicap_setup(struct device *dev, int id, goto failed3; } - device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); + device_create(&icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); return 0; /* success */ failed3: @@ -730,7 +732,7 @@ static int hwicap_remove(struct device *dev) if (!drvdata) return 0; - device_destroy(icap_class, drvdata->devt); + device_destroy(&icap_class, drvdata->devt); cdev_del(&drvdata->cdev); iounmap(drvdata->base_address); release_mem_region(drvdata->mem_start, drvdata->mem_size); @@ -856,7 +858,9 @@ static int __init hwicap_module_init(void) dev_t devt; int retval; - icap_class = class_create("xilinx_config"); + retval = class_register(&icap_class); + if (retval) + return retval; mutex_init(&icap_sem); devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); @@ -882,7 +886,7 @@ static void __exit hwicap_module_cleanup(void) { dev_t devt = MKDEV(XHWICAP_MAJOR, XHWICAP_MINOR); - class_destroy(icap_class); + class_unregister(&icap_class); platform_driver_unregister(&hwicap_platform_driver);