From patchwork Thu Jan 7 16:02:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 12004383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7803EC433E0 for ; Thu, 7 Jan 2021 16:04:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47FA723428 for ; Thu, 7 Jan 2021 16:04:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728468AbhAGQE2 (ORCPT ); Thu, 7 Jan 2021 11:04:28 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:65310 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbhAGQE2 (ORCPT ); Thu, 7 Jan 2021 11:04:28 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 107G2Cqd099376; Thu, 7 Jan 2021 11:03:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id; s=pp1; bh=yFFxWZ2zRBx6cdljP0LZkpQw/jzFJ1iylyRzDuu7h+I=; b=gPsL+5cR7iUzSytpM6c7tgrq6XjoDFwxmooVd5kyBrhD5df+QTHjHNiYRCsvhGDZKbuG dHJtkrcmcdddrvmxCRC9xkHx2f2nqkikCP2tXTajNs0hiE3sFs/UF2xPLUx9K9jZ9b44 5cAE4lxRhlWOcoqJ1r8OspKqhdRiSbThZAzAoU17iaTUZgTMBaevRpcQ+yxTO35PmYlv Vw81UDX1wrfZxN5+L/rNq8zSVgkxJS3C3j53kW4GQ6kXSGnrxTx6afR5HsOst4a4JL/W jnuC712Ux6x9BTuvMn1ihMbCSjv1r8iGdAT47JJqOZA1FdROqalqWLe1Zsu7Y2dH5xTB fQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x58w0c9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:03:39 -0500 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 107G2goK101149; Thu, 7 Jan 2021 11:03:14 -0500 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x58w0bt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:03:14 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 107FXlPf018840; Thu, 7 Jan 2021 16:02:42 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 35tg3hd1kh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 16:02:42 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 107G2aGK31195508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Jan 2021 16:02:36 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC3584C044; Thu, 7 Jan 2021 16:02:39 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 860834C040; Thu, 7 Jan 2021 16:02:39 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 7 Jan 2021 16:02:39 +0000 (GMT) From: Julian Wiedmann To: "Martin K. Petersen" , "James E.J. Bottomley" Cc: linux-scsi , Julian Wiedmann , Lee Duncan , Chris Leech Subject: [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes Date: Thu, 7 Jan 2021 17:02:29 +0100 Message-Id: <20210107160231.101243-1-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-07_07:2021-01-07,2021-01-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070097 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have device_register() create the attributes for us automatically, before the KOBJ_ADD uevent is raised. Cc: Lee Duncan Cc: Chris Leech Signed-off-by: Julian Wiedmann --- drivers/scsi/scsi_transport_iscsi.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2e68c0a87698..c18d01e178b2 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -174,11 +174,6 @@ static void iscsi_endpoint_release(struct device *dev) kfree(ep); } -static struct class iscsi_endpoint_class = { - .name = "iscsi_endpoint", - .dev_release = iscsi_endpoint_release, -}; - static ssize_t show_ep_handle(struct device *dev, struct device_attribute *attr, char *buf) { @@ -192,8 +187,12 @@ static struct attribute *iscsi_endpoint_attrs[] = { NULL, }; -static struct attribute_group iscsi_endpoint_group = { - .attrs = iscsi_endpoint_attrs, +ATTRIBUTE_GROUPS(iscsi_endpoint); + +static struct class iscsi_endpoint_class = { + .name = "iscsi_endpoint", + .dev_groups = iscsi_endpoint_groups, + .dev_release = iscsi_endpoint_release, }; #define ISCSI_MAX_EPID -1 @@ -239,18 +238,10 @@ iscsi_create_endpoint(int dd_size) if (err) goto free_ep; - err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group); - if (err) - goto unregister_dev; - if (dd_size) ep->dd_data = &ep[1]; return ep; -unregister_dev: - device_unregister(&ep->dev); - return NULL; - free_ep: kfree(ep); return NULL; @@ -259,7 +250,6 @@ EXPORT_SYMBOL_GPL(iscsi_create_endpoint); void iscsi_destroy_endpoint(struct iscsi_endpoint *ep) { - sysfs_remove_group(&ep->dev.kobj, &iscsi_endpoint_group); device_unregister(&ep->dev); } EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint); From patchwork Thu Jan 7 16:02:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 12004387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CE47C433E0 for ; Thu, 7 Jan 2021 16:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E89F623403 for ; Thu, 7 Jan 2021 16:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbhAGQGo (ORCPT ); Thu, 7 Jan 2021 11:06:44 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:15326 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbhAGQGo (ORCPT ); Thu, 7 Jan 2021 11:06:44 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 107G5PHu003354; Thu, 7 Jan 2021 11:05:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=rwr3p9Gi9zaZG9OZ5de6+AhAlq5C8aS9GEEax1yHiI8=; b=IRkISkCSTUqafEf/A8eAXRt/JAxulWGBniE2txla4mzfV8ZruI0nZaz3RDhZPZzxDX2g u9ng9RYGUrQgVaK7OPE/5PhxXtAl1lmw3/6Qgg6i7ib2OQppOWDNEM002Wt1pqVtKs5f D11hfj9Niw7Rze6XczQSF3sJfXUwhZhrtMbG+OpaexLlhHfdfMr/PU4ZiShcrEVEGVpx CRshAGuxswyG7h48Tp/TpdF/m99XOweQ95CzYgIdCxF7qemXCNMvw1seJKrSQmhwgHUK sMnFrlCllFktlMmSbLoCJcSi8pTDClvdhWdksXeaBjMY/wqoU5yU4W7z97+YgVFYKvTi +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x4r89k45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:05:57 -0500 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 107G5ZNs004043; Thu, 7 Jan 2021 11:05:35 -0500 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x4r89jc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:05:32 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 107FVpx1023202; Thu, 7 Jan 2021 16:02:43 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 35tgf8jktt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 16:02:43 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 107G2eLi38273530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Jan 2021 16:02:40 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08B7C4C044; Thu, 7 Jan 2021 16:02:40 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C72E04C046; Thu, 7 Jan 2021 16:02:39 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 7 Jan 2021 16:02:39 +0000 (GMT) From: Julian Wiedmann To: "Martin K. Petersen" , "James E.J. Bottomley" Cc: linux-scsi , Julian Wiedmann , Lee Duncan , Chris Leech Subject: [PATCH 2/3] scsi: iscsi: let transport class declare its sysfs attributes Date: Thu, 7 Jan 2021 17:02:30 +0100 Message-Id: <20210107160231.101243-2-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210107160231.101243-1-jwi@linux.ibm.com> References: <20210107160231.101243-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-07_07:2021-01-07,2021-01-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070097 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have device_register() create the attributes for us automatically, before the KOBJ_ADD uevent is raised. Cc: Lee Duncan Cc: Chris Leech Signed-off-by: Julian Wiedmann --- drivers/scsi/scsi_transport_iscsi.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index c18d01e178b2..e3d57ba7ca19 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -118,15 +118,6 @@ static void iscsi_transport_release(struct device *dev) kfree(priv); } -/* - * iscsi_transport_class represents the iscsi_transports that are - * registered. - */ -static struct class iscsi_transport_class = { - .name = "iscsi_transport", - .dev_release = iscsi_transport_release, -}; - static ssize_t show_transport_handle(struct device *dev, struct device_attribute *attr, char *buf) @@ -154,8 +145,16 @@ static struct attribute *iscsi_transport_attrs[] = { NULL, }; -static struct attribute_group iscsi_transport_group = { - .attrs = iscsi_transport_attrs, +ATTRIBUTE_GROUPS(iscsi_transport); + +/* + * iscsi_transport_class represents the iscsi_transports that are + * registered. + */ +static struct class iscsi_transport_class = { + .name = "iscsi_transport", + .dev_groups = iscsi_transport_groups, + .dev_release = iscsi_transport_release, }; /* @@ -4622,10 +4621,6 @@ iscsi_register_transport(struct iscsi_transport *tt) if (err) goto free_priv; - err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group); - if (err) - goto unregister_dev; - /* host parameters */ priv->t.host_attrs.ac.class = &iscsi_host_class.class; priv->t.host_attrs.ac.match = iscsi_host_match; @@ -4652,9 +4647,6 @@ iscsi_register_transport(struct iscsi_transport *tt) printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); return &priv->t; -unregister_dev: - device_unregister(&priv->dev); - return NULL; free_priv: kfree(priv); return NULL; @@ -4681,7 +4673,6 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) transport_container_unregister(&priv->session_cont); transport_container_unregister(&priv->t.host_attrs); - sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group); device_unregister(&priv->dev); mutex_unlock(&rx_queue_mutex); From patchwork Thu Jan 7 16:02:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 12004385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CEFCC433DB for ; Thu, 7 Jan 2021 16:04:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3219F23118 for ; Thu, 7 Jan 2021 16:04:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728205AbhAGQE0 (ORCPT ); Thu, 7 Jan 2021 11:04:26 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35204 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbhAGQE0 (ORCPT ); Thu, 7 Jan 2021 11:04:26 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 107G2CQT099371; Thu, 7 Jan 2021 11:03:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=bRszvytTtodPF9wRkj+mNSdoQGns39vakbpD3IFIyVo=; b=ggzhjZpBqc7JZYIKRqhw4aD9wOECvz5iom+LeviFEF15tTiCa2R2uMbId9c74dE8oGlU u8r3yx7RTecQEJymSIWE+Ta9dw8QFEjnp9JukDyg/a4oVjvjJpRMUuLLxrMNCJLhNBs7 9ZOLnINxqK92tqoKVH8fLb/3ffRmCtdE0CDHg1lABfZt9HCK5+OjXHVAcPoVwAnDKxu1 PtMoH9nw2ZIy4PkG4wke2esmSgTOObPK6+rkTuoShWVze83RIUmCIDkpTntSsXJsjbEr WkauKI3f9x9apVL4Cheeccr1A7FporZKvwTzhRxVrSAjFjJSoPHO5drN5WD5ctdzUdKM 2w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x58w0c95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:03:39 -0500 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 107G2goH101149; Thu, 7 Jan 2021 11:03:13 -0500 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 35x58w0btg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 11:03:08 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 107FXe27022042; Thu, 7 Jan 2021 16:02:43 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 35wd379581-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Jan 2021 16:02:43 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 107G2e6x41288080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Jan 2021 16:02:40 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4901A4C052; Thu, 7 Jan 2021 16:02:40 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13C034C050; Thu, 7 Jan 2021 16:02:40 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 7 Jan 2021 16:02:40 +0000 (GMT) From: Julian Wiedmann To: "Martin K. Petersen" , "James E.J. Bottomley" Cc: linux-scsi , Julian Wiedmann , Lee Duncan , Chris Leech Subject: [PATCH 3/3] scsi: iscsi: let iface class declare its sysfs attributes Date: Thu, 7 Jan 2021 17:02:31 +0100 Message-Id: <20210107160231.101243-3-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210107160231.101243-1-jwi@linux.ibm.com> References: <20210107160231.101243-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-07_07:2021-01-07,2021-01-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1011 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070097 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Have device_register() create the attributes for us automatically, before the KOBJ_ADD uevent is raised. Cc: Lee Duncan Cc: Chris Leech Signed-off-by: Julian Wiedmann --- drivers/scsi/scsi_transport_iscsi.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index e3d57ba7ca19..d467ae3e46ee 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -286,12 +286,6 @@ static void iscsi_iface_release(struct device *dev) put_device(parent); } - -static struct class iscsi_iface_class = { - .name = "iscsi_iface", - .dev_release = iscsi_iface_release, -}; - #define ISCSI_IFACE_ATTR(_prefix, _name, _mode, _show, _store) \ struct device_attribute dev_attr_##_prefix##_##_name = \ __ATTR(_name, _mode, _show, _store) @@ -689,6 +683,14 @@ static struct attribute_group iscsi_iface_group = { .is_visible = iscsi_iface_attr_is_visible, }; +__ATTRIBUTE_GROUPS(iscsi_iface); + +static struct class iscsi_iface_class = { + .name = "iscsi_iface", + .dev_groups = iscsi_iface_groups, + .dev_release = iscsi_iface_release, +}; + /* convert iscsi_ipaddress_state values to ascii string name */ static const struct { enum iscsi_ipaddress_state value; @@ -773,18 +775,10 @@ iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *transport, if (err) goto free_iface; - err = sysfs_create_group(&iface->dev.kobj, &iscsi_iface_group); - if (err) - goto unreg_iface; - if (dd_size) iface->dd_data = &iface[1]; return iface; -unreg_iface: - device_unregister(&iface->dev); - return NULL; - free_iface: put_device(iface->dev.parent); kfree(iface); @@ -794,7 +788,6 @@ EXPORT_SYMBOL_GPL(iscsi_create_iface); void iscsi_destroy_iface(struct iscsi_iface *iface) { - sysfs_remove_group(&iface->dev.kobj, &iscsi_iface_group); device_unregister(&iface->dev); } EXPORT_SYMBOL_GPL(iscsi_destroy_iface);