From patchwork Tue Feb 6 16:06:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Nijnikov X-Patchwork-Id: 10203299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 765D560247 for ; Tue, 6 Feb 2018 16:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF0428C9A for ; Tue, 6 Feb 2018 16:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A3BC28CDA; Tue, 6 Feb 2018 16:10:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E294328CE2 for ; Tue, 6 Feb 2018 16:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752814AbeBFQJp (ORCPT ); Tue, 6 Feb 2018 11:09:45 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:37127 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752236AbeBFQHC (ORCPT ); Tue, 6 Feb 2018 11:07:02 -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=1517933222; x=1549469222; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=4NZh5Yd2vlpltk9J5Oa0DJMHlTg+ahJ41GMJ1y7Kqqk=; b=Ng41fAl7DrQdBWNa3NlCt//WleWqsyzgq7L5Bqx8T6OJV7oFgOy2EtAE kbSCMyWFe6yeuWg8RfEt8YNGQ8m29+ZpV08QgKoe4zn98HFD4CWIPeQsJ M6sinkvKwGCgeFCohlPmUSpoiP7NufBnthNKpGyp23DtDj/wjywNxZrcs 7aLeJq9bJdkrT+5i0NK7Lzo6Ayv1tU6Wu4HFxF8Yaab6EOkNeXPmiASBi +AUp23SsQCM8ZcH7s3gIQmKz7VBi1yPFpNtOJisqfTjZoMuA0qgTXoYNX Nwby/I9y6sdHLCDKErw6j2H5xLNSrYMxLG4sIOzCH7/MCp+bi60YFmsMb g==; X-IronPort-AV: E=Sophos;i="5.46,469,1511798400"; d="scan'208";a="71267320" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Feb 2018 00:06:47 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 06 Feb 2018 08:01:37 -0800 Received: from ilb000042.sdcorp.global.sandisk.com ([10.0.231.79]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Feb 2018 08:06:46 -0800 From: Stanislav Nijnikov To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jaegeuk@kernel.org Cc: alex.lemberg@wdc.com, Stanislav Nijnikov Subject: [PATCH v5 08/11] scsi: host template attribute groups Date: Tue, 6 Feb 2018 18:06:20 +0200 Message-Id: <1517933183-30892-9-git-send-email-stanislav.nijnikov@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517933183-30892-1-git-send-email-stanislav.nijnikov@wdc.com> References: <1517933183-30892-1-git-send-email-stanislav.nijnikov@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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..fe5d1cb 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,11 @@ void __scsi_remove_device(struct scsi_device *sdev) if (sdev->sdev_state == SDEV_DEL) return; + if (sdev->host->hostt->sdev_groups) { + sysfs_remove_groups(&sdev->sdev_gendev.kobj, + sdev->host->hostt->sdev_groups); + } + if (sdev->is_visible) { /* * If scsi_internal_target_block() is running concurrently, 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.