From patchwork Fri Aug 11 07:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13350226 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECDDBEB64DD for ; Fri, 11 Aug 2023 07:32:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233670AbjHKHax (ORCPT ); Fri, 11 Aug 2023 03:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233642AbjHKHax (ORCPT ); Fri, 11 Aug 2023 03:30:53 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 761FD26AB; Fri, 11 Aug 2023 00:30:52 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fe5c552dd0so3336615e9.0; Fri, 11 Aug 2023 00:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691739051; x=1692343851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qDYVwSVB6NZ2unwDki7gCfr1BW56LAuUdkJUooc7tzg=; b=NZeUjpKtHs7KtIaGLddTphxLla2HHFwXcf2ZVG/9hwDqf2yqybFFdhiYQL00WBpbKK YnN6iRxHFCBfXrS7GnX6v1nD/i3smaPnuRLUBQkniuKw8Pz0tK4f3OHHPM0zP6QVYQF2 EMJmWSRTNSvq9Y/pyvNEz/gsFE41YHacHSwD4EZe4pbBJfJUyr+Y5O3BLFYR678tzMCS CsFdqSxV0wC3xAL0lTExP9T9nsTD0eoF6lugad21aw368ekZeC/kOCEEDGNobHa2deJS UlBsV/xOr719HjaQEpOvPn+PF3PP003iJ77eyn9ervYKnXDaeTeRyjY4HSiEH+RhoIDj pm9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691739051; x=1692343851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qDYVwSVB6NZ2unwDki7gCfr1BW56LAuUdkJUooc7tzg=; b=VQg97Ok0L45jJuB2QGW5+rZ9QF6XXkSaT7i3+XWGPmrkvRBqoHwgpBof4GppBa4ief iI3FuJaR0QbyI/QOtO+FUYtTw/S1zAaEl6Z0QFlnKTdH3WZzi87Q+mMz2RffcKU4J2Oe AwA6F+MeFuLtKX0keJ6k5dahobnRV186pJKvUjhAHgDwg2KTdb2Do9soJeO7uTE5XJk0 3prFu0px73QPw9Kv6hzM0fSotJpch9+MYofgL2HhDYsy3uAZDhyoL9mg8bLivF8rYf/C FO9SeW52G5wHxZLGFPOfGlOeqtKpNXfn+lGrrlcZhoMFjAWreQuoTFCaNo4mfK/PCkXL PKyA== X-Gm-Message-State: AOJu0YxdU5/3cDNQBusSABEpaGIXz1pJlENb7FOtXuJc1gFkTCpbYGON iS1ljKkrkJwlGVEneCBBqKs= X-Google-Smtp-Source: AGHT+IH9uaa6k5ZXUcXSkHCA7jIh5J4NDAAiPXLOPJnXtc0SigJsqD9YUIMse2W9KQRlVU387auhnA== X-Received: by 2002:adf:fe0b:0:b0:317:3d36:b2c1 with SMTP id n11-20020adffe0b000000b003173d36b2c1mr625690wrr.7.1691739050965; Fri, 11 Aug 2023 00:30:50 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([141.136.93.153]) by smtp.gmail.com with ESMTPSA id q4-20020adff944000000b003143c9beeaesm4510166wrr.44.2023.08.11.00.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 00:30:50 -0700 (PDT) From: Ivan Orlov To: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com Cc: Ivan Orlov , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v2 3/3] fpga: region: make fpga_region_class a static const structure Date: Fri, 11 Aug 2023 11:30:43 +0400 Message-Id: <20230811073043.52808-3-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230811073043.52808-1-ivan.orlov0322@gmail.com> References: <20230811073043.52808-1-ivan.orlov0322@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org Now that the driver core allows for struct class to be in read-only memory, move the fpga_region_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov --- drivers/fpga/fpga-region.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index ccf6fdab1360..6abd8a154047 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -16,7 +16,7 @@ #include static DEFINE_IDA(fpga_region_ida); -static struct class *fpga_region_class; +static const struct class fpga_region_class; struct fpga_region * fpga_region_class_find(struct device *start, const void *data, @@ -24,7 +24,7 @@ fpga_region_class_find(struct device *start, const void *data, { struct device *dev; - dev = class_find_device(fpga_region_class, start, data, match); + dev = class_find_device(&fpga_region_class, start, data, match); if (!dev) return NULL; @@ -216,7 +216,7 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info * mutex_init(®ion->mutex); INIT_LIST_HEAD(®ion->bridge_list); - region->dev.class = fpga_region_class; + region->dev.class = &fpga_region_class; region->dev.parent = parent; region->dev.of_node = parent->of_node; region->dev.id = id; @@ -287,25 +287,24 @@ static void fpga_region_dev_release(struct device *dev) kfree(region); } +static const struct class fpga_region_class = { + .name = "fpga_region", + .dev_groups = fpga_region_groups, + .dev_release = fpga_region_dev_release, +}; + /** * fpga_region_init - init function for fpga_region class * Creates the fpga_region class and registers a reconfig notifier. */ static int __init fpga_region_init(void) { - fpga_region_class = class_create("fpga_region"); - if (IS_ERR(fpga_region_class)) - return PTR_ERR(fpga_region_class); - - fpga_region_class->dev_groups = fpga_region_groups; - fpga_region_class->dev_release = fpga_region_dev_release; - - return 0; + return class_register(&fpga_region_class); } static void __exit fpga_region_exit(void) { - class_destroy(fpga_region_class); + class_unregister(&fpga_region_class); ida_destroy(&fpga_region_ida); }