From patchwork Fri Aug 11 07:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13350228 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 17F01C41513 for ; Fri, 11 Aug 2023 07:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233301AbjHKHav (ORCPT ); Fri, 11 Aug 2023 03:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjHKHau (ORCPT ); Fri, 11 Aug 2023 03:30:50 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A459A26AB; Fri, 11 Aug 2023 00:30:49 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3177675d6dfso232262f8f.0; Fri, 11 Aug 2023 00:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691739048; x=1692343848; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=P/p+iPwYe2JcsVYf19+FHtuDOIGC0SjQh2VjFbfMGuk=; b=cCGVr9qDA5Kf+x3gZsLncBKiX0wzi/DoLgBQezbww+qiIAdKGUIDkShnJnKCGYUJD2 P43xuNjTqEk89sJSdAmz990jqPLAmUYIvCw2P1Ji9qXJkmEprycvIKuk2Vra7ASHAJ7w 6RkjX58Dh25nrJ6QOWfTcM6gKd2dlQjn8GsXN5X/w0Q/W7teo74viQf7yVq4zyHveZxy AI3em/5OySHaGMZbVFVGO+Vi+Gjx2ERSbxAJN6E92Jl0J2eZpSSlKDCODmbQfLx8+Sh3 8yOxmCo7LwVg7vW43EDx+1U3d/TGzqGNlcgYeCG8LoxopdeC4HfOROxb6znzxPlRxyZx 5LdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691739048; x=1692343848; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P/p+iPwYe2JcsVYf19+FHtuDOIGC0SjQh2VjFbfMGuk=; b=JAfCP3AILWbmFfD0YI3xTFaVgh2810WQFYddK/smxd+N+MAUDKSoekf0eDLek0s1i2 bwxrORB+M9hSc+zNZfYsc+xdklMQ+WZRiV9v0BIMoc491wc6T0Gf69SyjX+2ypUON+PI fH2hNGwvbvasEjNKEpc1mdBR8L8c49gcRuYUguJimXWVQP675OEIL80LKZ6VeUQMDVBK ks3yP3KAVXnbRrofz0FhMOhUU+1WaI4017z1S27oOv4nxwE51Zpc7dcQwA12rOuJj2fA J8DtmU4VHpqwrOpmM7UMPmyWMFUYvhEZZb8PKJGYX3umZdNbYUGQE3T5OXCRqfOjE5Ah Xc8w== X-Gm-Message-State: AOJu0YxqTDdZM8XJuLka5sY7IGX5/cH8GzdsfcEDN91xtSSOab73pUrG E5dEQ48ead2pyiFrDkgIQyk= X-Google-Smtp-Source: AGHT+IFpxZFZTSOG3rZOxMqASSeI9N+oN/Su6uFC1zRg29GqiqKCrLCyZHuBGLs9E3G6ZJX202ynEg== X-Received: by 2002:a5d:6142:0:b0:317:e9c9:5951 with SMTP id y2-20020a5d6142000000b00317e9c95951mr733247wrt.7.1691739047825; Fri, 11 Aug 2023 00:30:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 00:30:47 -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 1/3] fpga: bridge: make fpga_bridge_class a static const structure Date: Fri, 11 Aug 2023 11:30:41 +0400 Message-Id: <20230811073043.52808-1-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 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_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 Acked-by: Xu Yilun --- 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); } From patchwork Fri Aug 11 07:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13350227 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 091C7C04A6A for ; Fri, 11 Aug 2023 07:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbjHKHaw (ORCPT ); Fri, 11 Aug 2023 03:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233551AbjHKHav (ORCPT ); Fri, 11 Aug 2023 03:30:51 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0497726AB; Fri, 11 Aug 2023 00:30:51 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3177b6bd875so341690f8f.0; Fri, 11 Aug 2023 00:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691739049; x=1692343849; 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=MEv32t7KuKnu76Su3ZwHlZ7/4J+m/5lEE/A/fA+qZ2A=; b=WoikOm6gDp+Ujph37rerOPX3aCCabmlsmOt0bCgYsi/2MOMm3R2H8Ush0vUy5pHBz+ IMHvpp1p/HTLky0laHymHDBcAi789kAKtyimYdH9W1LEIzHCwq3ZL6GjtflxIPBEKpjp 0jUYUBF80ydmUh4PzHUys5UvTkXNTHpEBZQW2NnVph+0pFBFbKmRrLEftNntQxKII624 PUEQw/vmhpMRSxi6zuzXsJAGT/VFQi3io050YBo4/kKAXTewZT6xek2SxNze8yCEfRha gHNXWnGhV9bwsPwkJ6fcOdIfEksECpVrkjlCtDTc4CLW7TychIK3DFTJZ2j6ZcUmbGfh AR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691739049; x=1692343849; 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=MEv32t7KuKnu76Su3ZwHlZ7/4J+m/5lEE/A/fA+qZ2A=; b=ERFf5UmcT11uV3cEBMvnEpqwKLIFr5tH2LZdjY6KfWapkwAoeGcbN0epnjMEQjvKVJ lACggzcFsjn/NN8bZflrS1LqOVoQra2VNk+W2geVwxVVLPnuxEjt7/W+Ab2Zl9b7QI5x ELu/Mc0696oK1jVv0qn7UU/t23eC2natIEwhSqfdQeebOh69BkxZq32pcfavImaFt6jB 7K+0m87lMXF/AJdTkWB5cteQNM1o5quoiOtsJDzduc3h6kmA/fbPQYNZRiYBqkaNdRsH piwpl+u2/zlbzR0GDaHThGLPjPM+eVB0Y73vchObLlIhuHdz6+5tkPl42ETDDxVqQ6ny NJKw== X-Gm-Message-State: AOJu0Yy0EPtusmbtW6uv1oh+TeBdX1BL4HdDMG0ZG/mesziZCSeiH3iq YUntxJ9LvyLiefaN54EELBo= X-Google-Smtp-Source: AGHT+IHa3EN/O3/q/fpx0gijThR+U/oOfEpqtBFXq8Ryw8OyDO9VM94WW+yZOIXKae/vKSBahROtYA== X-Received: by 2002:a5d:4391:0:b0:317:5de0:8ba8 with SMTP id i17-20020a5d4391000000b003175de08ba8mr722915wrq.1.1691739049449; Fri, 11 Aug 2023 00:30:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 00:30:49 -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 2/3] fpga: fpga-mgr: make fpga_mgr_class a static const structure Date: Fri, 11 Aug 2023 11:30:42 +0400 Message-Id: <20230811073043.52808-2-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_mgr_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-mgr.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index eb583f86a0b9..06651389c592 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -19,7 +19,7 @@ #include static DEFINE_IDA(fpga_mgr_ida); -static struct class *fpga_mgr_class; +static const struct class fpga_mgr_class; struct fpga_mgr_devres { struct fpga_manager *mgr; @@ -693,7 +693,7 @@ static int fpga_mgr_dev_match(struct device *dev, const void *data) */ struct fpga_manager *fpga_mgr_get(struct device *dev) { - struct device *mgr_dev = class_find_device(fpga_mgr_class, NULL, dev, + struct device *mgr_dev = class_find_device(&fpga_mgr_class, NULL, dev, fpga_mgr_dev_match); if (!mgr_dev) return ERR_PTR(-ENODEV); @@ -713,7 +713,7 @@ struct fpga_manager *of_fpga_mgr_get(struct device_node *node) { struct device *dev; - dev = class_find_device_by_of_node(fpga_mgr_class, node); + dev = class_find_device_by_of_node(&fpga_mgr_class, node); if (!dev) return ERR_PTR(-ENODEV); @@ -809,7 +809,7 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in mgr->priv = info->priv; mgr->compat_id = info->compat_id; - mgr->dev.class = fpga_mgr_class; + mgr->dev.class = &fpga_mgr_class; mgr->dev.groups = mops->groups; mgr->dev.parent = parent; mgr->dev.of_node = parent->of_node; @@ -967,23 +967,22 @@ static void fpga_mgr_dev_release(struct device *dev) kfree(mgr); } +static const struct class fpga_mgr_class = { + .name = "fpga_manager", + .dev_groups = fpga_mgr_groups, + .dev_release = fpga_mgr_dev_release, +}; + static int __init fpga_mgr_class_init(void) { pr_info("FPGA manager framework\n"); - fpga_mgr_class = class_create("fpga_manager"); - if (IS_ERR(fpga_mgr_class)) - return PTR_ERR(fpga_mgr_class); - - fpga_mgr_class->dev_groups = fpga_mgr_groups; - fpga_mgr_class->dev_release = fpga_mgr_dev_release; - - return 0; + return class_register(&fpga_mgr_class); } static void __exit fpga_mgr_class_exit(void) { - class_destroy(fpga_mgr_class); + class_unregister(&fpga_mgr_class); ida_destroy(&fpga_mgr_ida); } 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); }