Received: by 10.223.185.116 with SMTP id b49csp1946663wrg; Thu, 15 Feb 2018 04:17:03 -0800 (PST) X-Google-Smtp-Source: AH8x227/SkqWgtroA2nevoMsQR9+fvhicB59YCCwzLGPxOTvNbe0oT/XOHzs8pOx6QszrTlzPKfj X-Received: by 2002:a17:902:9343:: with SMTP id g3-v6mr2406230plp.319.1518697023372; Thu, 15 Feb 2018 04:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518697023; cv=none; d=google.com; s=arc-20160816; b=RtR/WJYi/fuSEciLSQxlyrH9mF0sagHNaIHFygDUejPVgJVltpfuZa3OSRz5lYpVrs mjWrG1Qp9RnNGUwdCmOTF+iiQNnYKJqg0Dl9H0m/h0ZI9bnz1rVe9IbAICx9jPjlZRfm sd7z2yi2t8UtllXFU2LoGP999h05Bl4TOaqb6lXktAs3HvVyNr+Z3qEYvrFz0+bCoClK TT/JosUVzYhYrI43KeqpeL1+ogvWeWcbeXn8xXL4wSdlbEtGI8oEqhlteDJ+4ohLYTPi y1lrTJgXNfBbK5Epeo6mk8R8vIM5kxqUce+VoCJTo1AgXr0tkklWgENhiZDp1pne5lI1 IaKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tsZLctGcPE4egIrwUY+9geg/9/1On4JtHla/AL/Adi0=; b=yG4lDE/CjRJqqYlhQ+RbL7xPnkffzVd41SuyRgLYhO3v6+ao7w26BGoFIic2GT2icb N7JwPr5RaksGSRFuvwU6wDGu9OnX24ug2V3hJpQdE1OvFtUZji+o8dwmnobfYcSvAm+H 78ra1tqqx2lxwMuB8r2GcU0RxcAUUXT7HkiT8856U1XGDS/7gc0Dldz3vZpui1ef9cpl dZqUE2JDC7JM86wZ4KSJ4vCpBwMQUiUz7OZobgKniDAMW4NECkysVJsIEJUyoSttej9n NbdTPGx3V68dBJcMS4fH0iIdZaj+8TsemOjbriK3eIAop2+wNJyf7DTLhgGFtv2aHl89 hj5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=pkguWhMB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w61-v6si4255504plb.412.2018.02.15.04.16.48; Thu, 15 Feb 2018 04:17:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=pkguWhMB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968032AbeBOMOl (ORCPT + 99 others); Thu, 15 Feb 2018 07:14:41 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:14834 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967980AbeBOMOh (ORCPT ); Thu, 15 Feb 2018 07:14:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1518696878; x=1550232878; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LNgmaJ2NvweFOx3VeHEGw3+84ePJnbnOKgBFrirzjA8=; b=pkguWhMB4HIW/AWB1uIJzk8iy9FjQTjNAgdTXCj4yk6wAgriLDk4+2Lq 2iTFAxCpBY1IesviaO7xV4dHoVqxyOtsMUazjD0Nm7x1Qo5g/QEo4mX4j jXq5ruJHkTa4pupp6CFKWV7B8eeAE8z93Cy5QvLKMqkV8nfc18TvMmzxF MpmG2jYgo56zXc5plJgnxsFGXRRjdw4X2Ip2emN8dI47i1d5TSx2Hntti nr5hXcbdabauz2qMMqIQRwHZEjdb25ks2I+6LuABKL1Xco4vFlLUt85zj OYqjaZqGBvzpto4yIisu2giVsKyT3e0mnwbA4R1CYJnMxvvfywn0QV+gV g==; X-IronPort-AV: E=Sophos;i="5.46,517,1511798400"; d="scan'208";a="71975468" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2018 20:14:37 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 15 Feb 2018 04:08:39 -0800 Received: from ilb000042.sdcorp.global.sandisk.com ([10.0.231.79]) by uls-op-cesaip02.wdc.com with ESMTP; 15 Feb 2018 04:14:34 -0800 From: Stanislav Nijnikov To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jaegeuk@kernel.org, Bart.VanAssche@wdc.com Cc: alex.lemberg@wdc.com, Stanislav Nijnikov Subject: [PATCH v6 08/11] scsi: host template attribute groups Date: Thu, 15 Feb 2018 14:14:08 +0200 Message-Id: <1518696851-6730-9-git-send-email-stanislav.nijnikov@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518696851-6730-1-git-send-email-stanislav.nijnikov@wdc.com> References: <1518696851-6730-1-git-send-email-stanislav.nijnikov@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch introduces an additional field in the scsi_host_template structure - struct attribute_group **sdev_group. This field allows to define groups of attributes. It will provide an ability to use binary attributes as well as device attributes and to group them under subfolders if necessary. Signed-off-by: Stanislav Nijnikov Reviewed-by: Greg Kroah-Hartman --- drivers/scsi/scsi_sysfs.c | 12 ++++++++++++ include/scsi/scsi_host.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index cbc0fe2..d608759 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1309,6 +1309,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) } } + if (sdev->host->hostt->sdev_groups) { + error = sysfs_create_groups(&sdev->sdev_gendev.kobj, + sdev->host->hostt->sdev_groups); + if (error) + return error; + } + scsi_autopm_put_device(sdev); return error; } @@ -1326,6 +1333,7 @@ void __scsi_remove_device(struct scsi_device *sdev) if (sdev->sdev_state == SDEV_DEL) return; + if (sdev->is_visible) { /* * If scsi_internal_target_block() is running concurrently, @@ -1348,6 +1356,10 @@ void __scsi_remove_device(struct scsi_device *sdev) if (res != 0) return; + if (sdev->host->hostt->sdev_groups) + sysfs_remove_groups(&sdev->sdev_gendev.kobj, + sdev->host->hostt->sdev_groups); + bsg_unregister_queue(sdev->request_queue); device_unregister(&sdev->sdev_dev); transport_remove_device(dev); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 1a1df0d..1931758 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -477,6 +477,12 @@ struct scsi_host_template { struct device_attribute **sdev_attrs; /* + * Pointer to the SCSI device attribute groups for this host, + * NULL terminated. + */ + const struct attribute_group **sdev_groups; + + /* * List of hosts per template. * * This is only for use by scsi_module.c for legacy templates. -- 2.7.4