From patchwork Thu Aug 25 21:38:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12955242 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 BAB64ECAAA3 for ; Thu, 25 Aug 2022 21:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243883AbiHYVjL (ORCPT ); Thu, 25 Aug 2022 17:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243860AbiHYVjK (ORCPT ); Thu, 25 Aug 2022 17:39:10 -0400 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BDAC12F2; Thu, 25 Aug 2022 14:39:08 -0700 (PDT) Received: by mail-pg1-f170.google.com with SMTP id v4so18971217pgi.10; Thu, 25 Aug 2022 14:39:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=P6eG2fgSnszX6mm7Oj+kln5CQ0vjnqN/f0OMZD3yboY=; b=S0yD4qMNXUFcolohocFOM+Ra9VWr/2CFc/RxyIkQJufDcsp5UO5Gv5tDY6PqhmliRL vH2UdYrAEpWQ5JaOwPOibDZFhg3rUMV2ArxDG0XAty0s22z/ei4RI/IKuyEJZzP91VjO RTDnuScmkTjTgWAd1EiYijs6UGZNtX/WzGHFkDNeWrZ6jJa+FO/Nl4/oQbDOHruxGhNS xCaUHfQwpOgbqY4TIu4ugGH07QQOZPugIn2c/jvP5ufU25Ow84uh2WcrjXb9FFzliX+n +zPpzrGzoHoDuUBZ4494oP3IZg/3F3cSwcf/WZ9oqfclL/EHYCdec+a7C0pki3O4pxAw YThw== X-Gm-Message-State: ACgBeo2/WP3AoW8mXl/2bV48pXtticYIXxEmdY/CMPYaqFr5JthdMY2h /yxR3B9nTd6Xgjru8wg2VRs= X-Google-Smtp-Source: AA6agR63e/VVzO6XU+/GXv61MDMVPrw7uJyouu+s99OvGjLX7hAz0BSyG5aH5qlqOw/Oa8Kytc+Z/A== X-Received: by 2002:aa7:80d0:0:b0:52d:f9c6:bb14 with SMTP id a16-20020aa780d0000000b0052df9c6bb14mr992306pfn.57.1661463547210; Thu, 25 Aug 2022 14:39:07 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:349c:3078:d005:5a7e]) by smtp.gmail.com with ESMTPSA id n27-20020aa7985b000000b005379e480445sm111676pfq.94.2022.08.25.14.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 14:39:06 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , linux-rdma@vger.kernel.org, Bart Van Assche , stable@vger.kernel.org Subject: [PATCH 1/4] RDMA/srp: Rework the srp_add_port() error path Date: Thu, 25 Aug 2022 14:38:57 -0700 Message-Id: <20220825213900.864587-2-bvanassche@acm.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220825213900.864587-1-bvanassche@acm.org> References: <20220825213900.864587-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org device_register() always calls device_initialize() so calling device_del() is safe even if device_register() fails. Implement the following advice from the comment block above device_register(): "NOTE: _Never_ directly free @dev after calling this function, even if it returned an error! Always use put_device() to give up the reference initialized in this function instead." Keep the kfree() call in the error path since srp_release_dev() does not free the host. Cc: stable@vger.kernel.org Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 7720ea270ed8..8fd6a88f7a9c 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3909,20 +3909,19 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) port); if (device_register(&host->dev)) - goto free_host; + goto put_host; if (device_create_file(&host->dev, &dev_attr_add_target)) - goto err_class; + goto put_host; if (device_create_file(&host->dev, &dev_attr_ibdev)) - goto err_class; + goto put_host; if (device_create_file(&host->dev, &dev_attr_port)) - goto err_class; + goto put_host; return host; -err_class: - device_unregister(&host->dev); - -free_host: +put_host: + device_del(&host->dev); + put_device(&host->dev); kfree(host); return NULL; From patchwork Thu Aug 25 21:38:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12955243 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 61A94ECAAD6 for ; Thu, 25 Aug 2022 21:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243863AbiHYVjN (ORCPT ); Thu, 25 Aug 2022 17:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243874AbiHYVjL (ORCPT ); Thu, 25 Aug 2022 17:39:11 -0400 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0ACC2281; Thu, 25 Aug 2022 14:39:09 -0700 (PDT) Received: by mail-pl1-f182.google.com with SMTP id w2so1260971pld.0; Thu, 25 Aug 2022 14:39:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=/Q/uS8GwCxdU7Nza7iEXgsPKHajLn69NKbXTdP6aZp4=; b=boAreIpsbh27GE16yEr2Tdt8z/eB6cwC7+W98QaIZCs9tjHEQv+WQx+W3ri0LB7d1D su8yao4cPDJ548ATI4XacHEw2kY/HQOk+WbiMu8aIuX1c1XD9w6PvEM7a87sqbBzsKB4 fA42ZtSrLqbY7msN3ppeCK4K5c7CIt9TwKgAsDCME240hh3FQDKbgQEXjc0QIKIXwkZp JF/agLH5VVZYaBfv9yw42o53jtuxgTv/Kg/FHeOp32NTeqYu/9jVO6YtzNRLZW9pX2zP DT/Es5fD+5DYWe6Lnh2BPhaJsDWjnbRmRWGrmvoEYIHK/g6H5V5J/Jv4UTxBo+FVrohH kg6Q== X-Gm-Message-State: ACgBeo3OXkYi3AqEx+h05YlZlyeOUtRympgLVw9iaJB43omv/mebuEIl gjfmI+g7iQ+YrgyWY1ZCkA1h5+xauiw= X-Google-Smtp-Source: AA6agR4Mmlr+yIr2P0CBBQJP31VwCbS1NFgXnPtLO/2bQ4MMNIUJOYCTzfll7+w1y7qKMQOviKjhMA== X-Received: by 2002:a17:90b:3e8d:b0:1fa:facf:672f with SMTP id rj13-20020a17090b3e8d00b001fafacf672fmr1086730pjb.0.1661463549043; Thu, 25 Aug 2022 14:39:09 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:349c:3078:d005:5a7e]) by smtp.gmail.com with ESMTPSA id n27-20020aa7985b000000b005379e480445sm111676pfq.94.2022.08.25.14.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 14:39:08 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , linux-rdma@vger.kernel.org, Bart Van Assche , stable@vger.kernel.org Subject: [PATCH 2/4] RDMA/srp: Remove the srp_host.released completion Date: Thu, 25 Aug 2022 14:38:58 -0700 Message-Id: <20220825213900.864587-3-bvanassche@acm.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220825213900.864587-1-bvanassche@acm.org> References: <20220825213900.864587-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Move the kfree(host) calls into srp_release_dev(). Convert a device_unregister() call into a device_del() and a device_put() call. Remove the host->released completion object. This patch prepares for handling dev_set_name() failure in srp_add_port(). Cc: stable@vger.kernel.org Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 14 +++++--------- drivers/infiniband/ulp/srp/ib_srp.h | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 8fd6a88f7a9c..1d3a15e63732 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3178,7 +3178,7 @@ static void srp_release_dev(struct device *dev) struct srp_host *host = container_of(dev, struct srp_host, dev); - complete(&host->released); + kfree(host); } static struct class srp_class = { @@ -3898,7 +3898,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) INIT_LIST_HEAD(&host->target_list); spin_lock_init(&host->target_lock); - init_completion(&host->released); mutex_init(&host->add_target_mutex); host->srp_dev = device; host->port = port; @@ -3922,8 +3921,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) put_host: device_del(&host->dev); put_device(&host->dev); - kfree(host); - return NULL; } @@ -4029,12 +4026,11 @@ static void srp_remove_one(struct ib_device *device, void *client_data) srp_dev = client_data; list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { - device_unregister(&host->dev); /* - * Wait for the sysfs entry to go away, so that no new - * target ports can be created. + * Remove the add_target sysfs entry so that no new target ports + * can be created. */ - wait_for_completion(&host->released); + device_del(&host->dev); /* * Remove all target ports. @@ -4052,7 +4048,7 @@ static void srp_remove_one(struct ib_device *device, void *client_data) */ flush_workqueue(srp_remove_wq); - kfree(host); + put_device(&host->dev); } ib_dealloc_pd(srp_dev->pd); diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index 55a575e2cace..493e7fd1913e 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -124,7 +124,6 @@ struct srp_host { struct device dev; struct list_head target_list; spinlock_t target_lock; - struct completion released; struct list_head list; struct mutex add_target_mutex; }; From patchwork Thu Aug 25 21:38:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12955245 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 2EBD0ECAAD4 for ; Thu, 25 Aug 2022 21:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243919AbiHYVjQ (ORCPT ); Thu, 25 Aug 2022 17:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243811AbiHYVjM (ORCPT ); Thu, 25 Aug 2022 17:39:12 -0400 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0678C12F2 for ; Thu, 25 Aug 2022 14:39:11 -0700 (PDT) Received: by mail-pl1-f173.google.com with SMTP id io24so6326814plb.1 for ; Thu, 25 Aug 2022 14:39:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3Mw+ejviqqmcadHo47IKXdXfT8te6+F1g89OeLJKqhQ=; b=USwajTQQCECzH2hsq9AOWSwwTwBQhw/D8q9UCt1BypoDFZ5NPeALqzHiE9mFohSpJK 645HVQgxXAV11gbkha9GaljJI88Vx1dQbD8u92MT00TzdnveFkg5PFzXBlG8qaekQpAa 7CSbIU2bq2b7igLjRf6/YfHdEIzTSPpwc4leS82G8uuMIwmGIjBttSQVrGgjHa9qno5/ /f2ucfov2l4WRCm2lM0YMK+dSh8sQYznxv6tDuJ7r1Ug8YqfIHfLLhy2s3dpXGGUs8cF L+U4nlPSbiidr07nSzBeppCR3f3A65Fm/UZTtINgfpCE0tYrOp+sKATLjs1Ze3QGEhyA lW2g== X-Gm-Message-State: ACgBeo1AvYFo5XA2EcdgV4Pr2a3yLiE+nn9LWVeDqhyrbrmFAfZsg2R8 fczQsNQyAI0bZ5zIkvNw8rk= X-Google-Smtp-Source: AA6agR5G1MdhIsvYXww7Sl59YVvv96pFFbBnBKK5q+zCoTPP0yPTmOTYMwNjhuvSFkGyScGz9u85pA== X-Received: by 2002:a17:902:ca01:b0:172:bc42:be8e with SMTP id w1-20020a170902ca0100b00172bc42be8emr937786pld.47.1661463551072; Thu, 25 Aug 2022 14:39:11 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:349c:3078:d005:5a7e]) by smtp.gmail.com with ESMTPSA id n27-20020aa7985b000000b005379e480445sm111676pfq.94.2022.08.25.14.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 14:39:09 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , linux-rdma@vger.kernel.org, Bart Van Assche , Bo Liu Subject: [PATCH 3/4] RDMA/srp: Handle dev_set_name() failure Date: Thu, 25 Aug 2022 14:38:59 -0700 Message-Id: <20220825213900.864587-4-bvanassche@acm.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220825213900.864587-1-bvanassche@acm.org> References: <20220825213900.864587-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Instead of ignoring dev_set_name() failure, handle dev_set_name() failure. Convert a device_register() call into device_initialize() and device_add() calls. Reported-by: Bo Liu Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 1d3a15e63732..3f31a0eef1ef 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3902,12 +3902,13 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) host->srp_dev = device; host->port = port; + device_initialize(&host->dev); host->dev.class = &srp_class; host->dev.parent = device->dev->dev.parent; - dev_set_name(&host->dev, "srp-%s-%d", dev_name(&device->dev->dev), - port); - - if (device_register(&host->dev)) + if (dev_set_name(&host->dev, "srp-%s-%d", dev_name(&device->dev->dev), + port)) + goto put_host; + if (device_add(&host->dev)) goto put_host; if (device_create_file(&host->dev, &dev_attr_add_target)) goto put_host; From patchwork Thu Aug 25 21:39:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12955244 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 02739ECAAA3 for ; Thu, 25 Aug 2022 21:39:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243871AbiHYVjP (ORCPT ); Thu, 25 Aug 2022 17:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243860AbiHYVjN (ORCPT ); Thu, 25 Aug 2022 17:39:13 -0400 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B3B1C2282 for ; Thu, 25 Aug 2022 14:39:13 -0700 (PDT) Received: by mail-pj1-f54.google.com with SMTP id bg22so59125pjb.2 for ; Thu, 25 Aug 2022 14:39:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=JVFyLLiK90YZLe6E4ZKDxjpX8sjUAOTPT6vNVXEYaes=; b=M1y5Y8762baSxTB7OkbArxgRvgUFevRpPXxX1BveIK7Cgn0u609uY5VFoq3XHldT1i O0sREu2l2gLWlbRlpBUF9SM9m3b6srVLD8u3X7NnTputOZB9fRo8zoLe0PJHppLm7qGI XF6eLD2F7KtaKak2Othww60x9BhTfGSp5ulYkyHqByUWfemJDNblTO494GEPl/BBjBpK ThecHy2v/9yslZLxnCdzD0fazpa2FdhXkVkanNChDB9mOK7pux5a4SjvyZ0gs9kxx/BH wivQ+tNb/7PCQbgN4DiD0fMfczfUmO02PQBEK5x2aY6v2xE9IiSADeQTG5mRW+vB+/ax H6lw== X-Gm-Message-State: ACgBeo0Yq+I9ZMLfAV1Rbt87v+XWFm7uX9pfShFyUXUXMb246ZgqnmaL HgnJriRL96GUuTsj1LNnJ6U= X-Google-Smtp-Source: AA6agR411VjD05+u4SyVg9T6+hzRn3lnjzkpoh2bOHBNsuOIekxLPnq1aoPxvJr+MopFYp/puAzpUA== X-Received: by 2002:a17:90a:d585:b0:1f4:f9a5:22a9 with SMTP id v5-20020a17090ad58500b001f4f9a522a9mr1122564pju.49.1661463552645; Thu, 25 Aug 2022 14:39:12 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:349c:3078:d005:5a7e]) by smtp.gmail.com with ESMTPSA id n27-20020aa7985b000000b005379e480445sm111676pfq.94.2022.08.25.14.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 14:39:11 -0700 (PDT) From: Bart Van Assche To: Jason Gunthorpe Cc: Leon Romanovsky , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH 4/4] RDMA/srp: Use the attribute group mechanism for sysfs attributes Date: Thu, 25 Aug 2022 14:39:00 -0700 Message-Id: <20220825213900.864587-5-bvanassche@acm.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220825213900.864587-1-bvanassche@acm.org> References: <20220825213900.864587-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Simplify the SRP driver by using the attribute group mechanism instead of calling device_create_file() explicitly. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 3f31a0eef1ef..1e777b2043d6 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3181,8 +3181,13 @@ static void srp_release_dev(struct device *dev) kfree(host); } +static struct attribute *srp_class_attrs[]; + +ATTRIBUTE_GROUPS(srp_class); + static struct class srp_class = { .name = "infiniband_srp", + .dev_groups = srp_class_groups, .dev_release = srp_release_dev }; @@ -3888,6 +3893,13 @@ static ssize_t port_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(port); +static struct attribute *srp_class_attrs[] = { + &dev_attr_add_target.attr, + &dev_attr_ibdev.attr, + &dev_attr_port.attr, + NULL +}; + static struct srp_host *srp_add_port(struct srp_device *device, u8 port) { struct srp_host *host; @@ -3910,12 +3922,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) goto put_host; if (device_add(&host->dev)) goto put_host; - if (device_create_file(&host->dev, &dev_attr_add_target)) - goto put_host; - if (device_create_file(&host->dev, &dev_attr_ibdev)) - goto put_host; - if (device_create_file(&host->dev, &dev_attr_port)) - goto put_host; return host;