Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp843804rdg; Fri, 11 Aug 2023 01:16:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE49S4CnHRM8OvTEyBnJJJfGvsr1O5rX8YCHNWe+49ter4NtSjqTjdLHSwbfX8FrhxlGqs8 X-Received: by 2002:a17:906:13:b0:99b:5ba6:f2cf with SMTP id 19-20020a170906001300b0099b5ba6f2cfmr1053757eja.26.1691741763539; Fri, 11 Aug 2023 01:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691741763; cv=none; d=google.com; s=arc-20160816; b=YKV9VF/y6TJrKZsoQiTpK/qsHVFMmwdIKXibiwA7gupgufuYpR9Cx5LP0o7CZtAHWg A8C19Y7ihiddWLaruuDmUcvj4tr9rcQjsEWTlxO5Ky1+nm0ti5HOLz1AEBIDLzp1F1D9 fTVTmpehi9qoj8RnqhnJ5085PB+vq5d2NaLYQmQju9u7KCNXDyRw4fUEC+5MtyKT9K5c 5NFyS+RWhXaZ8mxX51ohTqssEBdeO45/aT5JwJks2IoKZNgtjhJsBey1NZeqGX1FkDwN Y2SRr0fMtg0qGQa7el1PjQ92FL33ss6BB4GuN8K3mDj+Rt/tg84kieLJ5YtbaX4sxdT2 6+Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=52RqNsWBGOEDTRChxk5rErDAk2mThr2SZ+FE8VBLvsY=; fh=fYXUQU3m0vkzIxlc0RwJeqrinysvy7Djv1PYI9QTecs=; b=HFA44G11Wu73vg5VZtJE0O8LM3Q6Y2fTJag8eHDgjnyW6OilPJ14y43jY94ZvdAYh0 z4tRakXvcuf8TRjiXQ5zIgOWvilea/EvlCCJ7Sy/36HpIcizXO20A7aiRKuwpoSTPXU1 pitS2YYYMX0QGTemV51ymoIo0taRaQEX71eyidA5BgLug4xwf2t8VsGAYq0y5jrDHKM5 QgGuLyThAsUPCLrJ7qXydy6vbK20yck0L28rWfcvHPu5bWO6dL1o+6dh5UoP1/ExQcAa eNKzWdLa2mSaCOeH2LvNBYdng13L/Ke06kib6EvsWeulIFnS580KeuknjP7aGNARGGpa AsjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QjqXFj12; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a170906338900b0099bcb8f4f00si2972501eja.409.2023.08.11.01.15.37; Fri, 11 Aug 2023 01:16:03 -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=@gmail.com header.s=20221208 header.b=QjqXFj12; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233893AbjHKHdN (ORCPT + 99 others); Fri, 11 Aug 2023 03:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbjHKHdM (ORCPT ); Fri, 11 Aug 2023 03:33:12 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0DC196; Fri, 11 Aug 2023 00:33:11 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fe4f3b5f25so2929395e9.0; Fri, 11 Aug 2023 00:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691739190; x=1692343990; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=52RqNsWBGOEDTRChxk5rErDAk2mThr2SZ+FE8VBLvsY=; b=QjqXFj12SQOPvXVa1OlJ1F+HNJid76tn2eHsIEgYpJJBxNzUiEjMRV1rFkLq9jZkeR 4KwspValcFZN5BPeK4ZOjzccxu4+4ZyJaAbm8QosdKXQD5FvcJuUz5A9Z6H6o59XN+jl AxuJEAyjwrq7eKrftOyFQIxmiDVe75xcnqvW+Cezui/g1zb1Ml4+UNeVruy8uxvKiCfT KOXck1ygLn9QOh0wmY6Fr78H19neHgRnDXDKEwocuUZFT11gxsVxSX6NDP/NwnlOAlgX UuHnqTdGU6UFCZZU8THsDDkdOHCyPzCarLv0rELl07ZKTtzNQOyjfUWU084PnWLe4eFk SCwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691739190; x=1692343990; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=52RqNsWBGOEDTRChxk5rErDAk2mThr2SZ+FE8VBLvsY=; b=UOZtyGO/PYsHB2xvT4Cxvj98PQVN9srU5LzX2k4MR6JJmHE6XDFoiBnAYafkMzUMuw XBdEa5KXcPnAs7kCv+HfoKwHWfYIL7ItZxkz5Q2LLDglNhwCg9o73b0mVNCr1ejUkyaF GfERFq3cNEHTTb7ssoupf5mLTmRbL0fAX9DicvfFDXSlUSKec36fgJsM+IskMNSXk36p 6tnCGMlZDmMiOxUCbHkRlcKromJ2Y73SdDAYBdO/RsGtTdn90+U9xwCsV9wypqlLf8Le dSJkpsqseQs0MurVbJN0vfM5Ekgb24tVOmIb8tuQb31wRu1t6MMuX3H6hvzhq0UxibsD 8ouw== X-Gm-Message-State: AOJu0YyvVvXq7SDcy3tYIBKtQyqwohG+Ou4J/yDbHg+d2WgA+7nMOIkt BUMinOAMfNhOkhFXLNDJyzmkQdCjzenpcFUI X-Received: by 2002:a05:600c:3509:b0:3fe:21a6:a18 with SMTP id h9-20020a05600c350900b003fe21a60a18mr1125778wmq.3.1691739189566; Fri, 11 Aug 2023 00:33:09 -0700 (PDT) Received: from [192.168.10.215] ([141.136.93.153]) by smtp.gmail.com with ESMTPSA id g5-20020adfe405000000b0031773a8e5c4sm4537740wrm.37.2023.08.11.00.33.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Aug 2023 00:33:09 -0700 (PDT) Message-ID: <4d41f54f-806c-9071-de68-6db69c3024da@gmail.com> Date: Fri, 11 Aug 2023 11:33:07 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2 1/3] fpga: bridge: make fpga_bridge_class a static const structure Content-Language: en-US To: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org References: <20230811073043.52808-1-ivan.orlov0322@gmail.com> From: Ivan Orlov In-Reply-To: <20230811073043.52808-1-ivan.orlov0322@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 On 8/11/23 11:30, Ivan Orlov wrote: > Now that the driver core allows for struct class to be in read-only > memory, move the fpga_bridge_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-bridge.c | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c > index a6c25dee9cc1..fe93549d051d 100644 > --- a/drivers/fpga/fpga-bridge.c > +++ b/drivers/fpga/fpga-bridge.c > @@ -14,7 +14,7 @@ > #include > > static DEFINE_IDA(fpga_bridge_ida); > -static struct class *fpga_bridge_class; > +static const struct class fpga_bridge_class; > > /* Lock for adding/removing bridges to linked lists*/ > static DEFINE_SPINLOCK(bridge_list_lock); > @@ -99,7 +99,7 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np, > { > struct device *dev; > > - dev = class_find_device_by_of_node(fpga_bridge_class, np); > + dev = class_find_device_by_of_node(&fpga_bridge_class, np); > if (!dev) > return ERR_PTR(-ENODEV); > > @@ -126,7 +126,7 @@ struct fpga_bridge *fpga_bridge_get(struct device *dev, > { > struct device *bridge_dev; > > - bridge_dev = class_find_device(fpga_bridge_class, NULL, dev, > + bridge_dev = class_find_device(&fpga_bridge_class, NULL, dev, > fpga_bridge_dev_match); > if (!bridge_dev) > return ERR_PTR(-ENODEV); > @@ -359,7 +359,7 @@ fpga_bridge_register(struct device *parent, const char *name, > bridge->priv = priv; > > bridge->dev.groups = br_ops->groups; > - bridge->dev.class = fpga_bridge_class; > + bridge->dev.class = &fpga_bridge_class; > bridge->dev.parent = parent; > bridge->dev.of_node = parent->of_node; > bridge->dev.id = id; > @@ -415,21 +415,20 @@ static void fpga_bridge_dev_release(struct device *dev) > kfree(bridge); > } > > +static const struct class fpga_bridge_class = { > + .name = "fpga_bridge", > + .dev_groups = fpga_bridge_groups, > + .dev_release = fpga_bridge_dev_release, > +}; > + > static int __init fpga_bridge_dev_init(void) > { > - fpga_bridge_class = class_create("fpga_bridge"); > - if (IS_ERR(fpga_bridge_class)) > - return PTR_ERR(fpga_bridge_class); > - > - fpga_bridge_class->dev_groups = fpga_bridge_groups; > - fpga_bridge_class->dev_release = fpga_bridge_dev_release; > - > - return 0; > + return class_register(&fpga_bridge_class); > } > > static void __exit fpga_bridge_dev_exit(void) > { > - class_destroy(fpga_bridge_class); > + class_unregister(&fpga_bridge_class); > ida_destroy(&fpga_bridge_ida); > } > And I forgot the changelog here. V1 -> V2: - Add forward declaration of fpga_bridge_class - Move definition of fpga_bridge_class to more logical place