Received: by 10.223.176.5 with SMTP id f5csp837713wra; Tue, 6 Feb 2018 08:11:26 -0800 (PST) X-Google-Smtp-Source: AH8x226MC6n0TN/oagW7jzzRcsbWIX+W/EN7uEWzVVjV2+UrWlhZtRtgxNNDfdwfAjQR/5E4JGPJ X-Received: by 2002:a17:902:8307:: with SMTP id bd7-v6mr2817869plb.369.1517933486813; Tue, 06 Feb 2018 08:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517933486; cv=none; d=google.com; s=arc-20160816; b=mM5ar9PG4Q0sF9djTIkBzKn4Rq3huRw5NB4DNIsQzmuyw6t/ZdmU5P9AUvZAfwIfYJ GKxBfa+oimA9LqdL+/Ajdsr/t7lMMMZ3VniuRF6ao+fC50fzsZhvQ40VeIR+DGcXFj+F PJyolKKHTNiQQlKQg5v2hbzU7ZlXSh2hRuwhSLAGs+Q6QuwE8KXH00gygLWFjMF32tC8 oWJ99MAf+XR6sKSh45t9olaHCvcw8fv73bbIm4vMDRvdhdQcEe3/9wfjqBVbUX+rvcb1 CL+SfsV7pvJbQ8DZo+yaItuTQ0w6x+WVmLF97XzW8LNQztNQN0aqZ4yMvR+tIHuo/z1n dlnA== 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=4cU88MDpoPBtSIMcWlHT7f0S5PIvGlj2rhzhUAdS0mk=; b=dowytuwOKJqU/uGypUJH+o4uuPFT0k4IRAlbnWpjKAHJVPZd3Nw0ATJW/lyE2r2g9k /UU8sD4R48MzsUSRMvgxCRgBY3VpFGXP+imX5si8dyxK0A++lgbwl8yt+LxBy+2ADRK3 SSa6Jx3Kpn2DbjYF6gxTi1/lGYE3e/C57AZKhNMtMSdarZOFn8/iaGaYKcD4jOmsDbA9 PMTicuNpiJNUUe4V3Q02DYj2MUFDVncjT+2sXLumrf1HmN0HFEgNKhoqqaZ6XengntVC 5CHkdbVytq3XFI/bHIyCrucjVx7BLEZ9gxVrvkD8auuIo6aH6SOAY2WVtO5h1f4lz/vh JWCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Ng41fAl7; 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 q9-v6si1995706plk.730.2018.02.06.08.11.13; Tue, 06 Feb 2018 08:11:26 -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=Ng41fAl7; 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 S1752632AbeBFQJ7 (ORCPT + 99 others); Tue, 6 Feb 2018 11:09:59 -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-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..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. -- 2.7.4