Received: by 10.223.176.5 with SMTP id f5csp1457165wra; Sun, 4 Feb 2018 04:35:08 -0800 (PST) X-Google-Smtp-Source: AH8x2250vaSa3iw+2FHb5ZmRG/96MpUZV9SW470JJfxf9G4z5ij6my2zv3vHPUANgQtRjt+aWW8r X-Received: by 2002:a17:902:221:: with SMTP id 30-v6mr41523569plc.134.1517747707945; Sun, 04 Feb 2018 04:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517747707; cv=none; d=google.com; s=arc-20160816; b=KbUo7SBjwqueILmhN500w1BM83RgLbGG5Bz3yjWFX7pg5vK8eYSkzGqqOzGj1MKTxJ FLU0mVt0LTEW0LpZSIuD1YfcHXFE2ZQX4pg9du4ZSzoGSvYs94Y+O+6g4rdsm2j3TF0w Igs33gq5Iv45bTCXMHZN2239k4oj5Q/bQPqjLjROObDksecUlwyFdxI01i4VGEflcb6d LB5ePoBDgeOWsjypHRZdatOxcZlnxHGqomhJF44ACFEqbOaK4AzkKc1iPbc2ZZvqh8s+ 6qO1FmEz4IsNQSORjbe2ci4ZThc/Rn+34IHFyITJhihKZMGwugQ9Hi/9I8LydO1J/swD WDVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:wdcipoutbound :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=1M13GQQCJ7qtuhXRLvZdQfiKjoMN6NStpnu/EoBxNo0=; b=nXRI2qSil+SbkEHa8Mdhuzt2WMurVwgM+RjQeNQYGmSEQHy/sUL2Kg9Y7NsCUIx3FV ++tZBmgVTAYbaxk8TJCPaYuCAsG0YA6s8S2B207H+KZQEDGaJDYvCokFqJyNYWVBa64H o8ef8X0uToBsahI9fR2IOw42KHKEWmCkpdF4hfMKOlLYl2Y77/bnCCn01Yh3wI/261Na bF0WOD1h+rDoM2btAud8oIaHXShac29W8+nyoWU+3FCvKsO42dot3g4zcPHXtvBqdNdN 4Kg74McphzolLKQfIDk3XhBD4vK4EGIqlgrXBSmzuG1peom+jSozyg0zL5WUxKuJIEgs WOCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=fWcoSCOw; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector1-wdc-com header.b=X17xUjX/; 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 g7si5258570pfj.60.2018.02.04.04.34.41; Sun, 04 Feb 2018 04:35:07 -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=fWcoSCOw; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector1-wdc-com header.b=X17xUjX/; 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 S1751835AbeBDM3W (ORCPT + 99 others); Sun, 4 Feb 2018 07:29:22 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:62613 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751261AbeBDM3O (ORCPT ); Sun, 4 Feb 2018 07:29:14 -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=1517747354; x=1549283354; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7DXkIt1ORT7Tqbxyr/moizdmL1iXOAekAtiYitt6ZvY=; b=fWcoSCOwjWy/fbAsNgkLMZ7f6Ew79fykgUyfHTjPFATncFnNfpoFkZ8X NOoc/+GsDt1jmwbp1hYZXouhwdgab+sAAJH96tbgIf1BnQX5XVBquqSqa l7Hmt5ugxYQ2WO5KZX9BO9z8S1/zNiowKyQWJrXNvbS7S8WEngHHrX4uu 62S+B6SqDYg+0yQpzw88eRLUvdefF8Y6D/SWL21NDY0i/zJ+CXRLRSOso aa5BNPj4TfwhjYOMDjRbEBAxaRIlKy67jDlT1f1ivz1bH++zF0LIu+BRa HUEVEYzBVYd8EUTXJR7/fS4k4UyVNqGR7pB5+CAmcnRLDxBzRP4iJJSXY Q==; X-IronPort-AV: E=Sophos;i="5.46,458,1511798400"; d="scan'208";a="70449169" Received: from mail-sn1nam01lp0113.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.113]) by ob1.hgst.iphmx.com with ESMTP; 04 Feb 2018 20:29:13 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1M13GQQCJ7qtuhXRLvZdQfiKjoMN6NStpnu/EoBxNo0=; b=X17xUjX/RUBli7pT5QZRqJq9aV6VHJbqzOoL6gLIbuS5PRQ6bzQekd11lN/pJAr3iSRiKiENf241Ieb/Y7nzIwvkFzsQL7cI7hn7pONsZ9+Z94AR/Pre0OsXsNQKXMmjkvIWs3fAQteiSkX7y5SFtcIDB890xAmjbmyb7KxGUo0= Received: from DM2PR0401MB0975.namprd04.prod.outlook.com (10.160.98.140) by DM2PR0401MB1038.namprd04.prod.outlook.com (10.160.98.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Sun, 4 Feb 2018 12:29:07 +0000 Received: from DM2PR0401MB0975.namprd04.prod.outlook.com ([fe80::bc62:c854:7dfd:7eb]) by DM2PR0401MB0975.namprd04.prod.outlook.com ([fe80::bc62:c854:7dfd:7eb%15]) with mapi id 15.20.0464.015; Sun, 4 Feb 2018 12:29:07 +0000 From: Stanislav Nijnikov To: Greg KH CC: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jaegeuk@kernel.org" , Alex Lemberg Subject: RE: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries. Thread-Topic: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries. Thread-Index: AQHTm3fxo1n5KlULckmz1QORVYth36OPxRSAgARmIJA= Date: Sun, 4 Feb 2018 12:29:06 +0000 Message-ID: References: <1517501746-19075-1-git-send-email-stanislav.nijnikov@wdc.com> <1517501746-19075-2-git-send-email-stanislav.nijnikov@wdc.com> <20180201165923.GA12838@kroah.com> In-Reply-To: <20180201165923.GA12838@kroah.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Stanislav.Nijnikov@wdc.com; x-originating-ip: [212.25.79.133] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM2PR0401MB1038;7:1rdvheBSgr7i40XteL/cYKV9k+rZiAnVaQHAY5v5w4W4OvmUx4j+is/NhdNKqSH11QOYZFvddFOAizo6aDcnIX5H1WJOCALdxlxzXUm/jcLS/gMJd6A210qI6RltoxMWw25RW8uVPUm4+OqqYDVHI0LnMYvUbeZjcxMjHfSRP0CJ8Val15Ii9zQqW8O/s2w5WJsK5n3wTR2g0GBGfpB4LeeI9n+T3AfmwSOrZE4TgBVyDAEt1ytbUI1W31sGQL6i;20:rtvqyH7749YuNr9RGTa8Wx272sAggcUlQeNpDc/WvXI9fpU/qzitOsI6CVgKPOX8KXCYDpGYgXvghidD28ONYv1/Nkj+d257H8lSsKVf0tkOf09Kv2g0LCFX01dMS5KTVXbriZcADDG7+bsbdporG3Y6Yp7cRAQ+PNqsbMAKcSM= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 24f7adf5-da21-44a1-428a-08d56bcae294 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020);SRVR:DM2PR0401MB1038; x-ms-traffictypediagnostic: DM2PR0401MB1038: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(6072148)(201708071742011);SRVR:DM2PR0401MB1038;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0401MB1038; x-forefront-prvs: 05739BA1B5 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(39380400002)(396003)(39860400002)(366004)(13464003)(189003)(199004)(316002)(74316002)(305945005)(66066001)(105586002)(6116002)(5660300001)(3846002)(106356001)(25786009)(7736002)(4326008)(102836004)(6506007)(8936002)(3280700002)(3660700001)(76176011)(7696005)(68736007)(72206003)(478600001)(81166006)(81156014)(59450400001)(53546011)(97736004)(6246003)(2950100002)(2906002)(14454004)(8676002)(54906003)(6916009)(5250100002)(6436002)(2900100001)(229853002)(53936002)(99286004)(33656002)(26005)(186003)(9686003)(55016002)(86362001)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0401MB1038;H:DM2PR0401MB0975.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:3;A:1;LANG:en; x-microsoft-antispam-message-info: 230RlVTzA/SudLfrESshYVg9oqXkqL/zMEoiA3ULJto+z/KIEoVwJ8s8S6+Uxj+YEiZKbT0TG/Cvis4F6pRXwQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24f7adf5-da21-44a1-428a-08d56bcae294 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2018 12:29:06.8444 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0401MB1038 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Greg KH [mailto:gregkh@linuxfoundation.org] > Sent: Thursday, February 1, 2018 6:59 PM > To: Stanislav Nijnikov > Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; > jaegeuk@kernel.org; Alex Lemberg > Subject: Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sy= sfs > entries. >=20 > On Thu, Feb 01, 2018 at 06:15:37PM +0200, Stanislav Nijnikov wrote: > > This patch introduces attribute group to show existing sysfs entries. > > > > Signed-off-by: Stanislav Nijnikov > > --- > > drivers/scsi/ufs/Makefile | 3 +- > > drivers/scsi/ufs/ufs-sysfs.c | 164 > > +++++++++++++++++++++++++++++++++++++++++++ > > drivers/scsi/ufs/ufs-sysfs.h | 22 ++++++ > > drivers/scsi/ufs/ufshcd.c | 156 ++---------------------------------= ----- > > drivers/scsi/ufs/ufshcd.h | 2 + > > 5 files changed, 194 insertions(+), 153 deletions(-) create mode > > 100644 drivers/scsi/ufs/ufs-sysfs.c create mode 100644 > > drivers/scsi/ufs/ufs-sysfs.h > > > > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile > > index 9310c6c..918f579 100644 > > --- a/drivers/scsi/ufs/Makefile > > +++ b/drivers/scsi/ufs/Makefile > > @@ -3,6 +3,7 @@ > > obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) +=3D tc-dwc-g210-pci.o ufshcd- > dwc.o > > tc-dwc-g210.o > > obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) +=3D tc-dwc-g210-pltfrm.o > > ufshcd-dwc.o tc-dwc-g210.o > > obj-$(CONFIG_SCSI_UFS_QCOM) +=3D ufs-qcom.o > > -obj-$(CONFIG_SCSI_UFSHCD) +=3D ufshcd.o > > +obj-$(CONFIG_SCSI_UFSHCD) +=3D ufshcd-core.o ufshcd-core-objs :=3D > > +ufshcd.o ufs-sysfs.o > > obj-$(CONFIG_SCSI_UFSHCD_PCI) +=3D ufshcd-pci.o > > obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) +=3D ufshcd-pltfrm.o diff --git > > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file > > mode 100644 index 0000000..cc68a90 > > --- /dev/null > > +++ b/drivers/scsi/ufs/ufs-sysfs.c > > @@ -0,0 +1,164 @@ > > +//SPDX-License-Identifier: GPL-2.0-only //Copyright (C) 2018 Western > > +Digital Corporation //This program is free software; you can > > +redistribute it and/or modify it //under the terms of the GNU General > > +Public License as published by the //Free Software Foundation; > > +version 2. > > +// > > +//This program is distributed in the hope that it will be useful, but > > +//WITHOUT ANY WARRANTY; without even the implied warranty of > > +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU > > +//General Public License for more details. >=20 > No need to put the whole "This program" crud in the file here if you have= the > SPDX line already. We are going through the kernel tree and removing all= of > the 700+ different ways we have this boilerplate code in the tree, please= do > not add new ones. >=20 > Also, please put a ' ' after "//", it just looks ugly like this, don't yo= u think so? >=20 > Please fix this for all of the files you add in this patch series. >=20 > > +#include > > +#include > > + > > +#include "ufs-sysfs.h" > > + > > +static const char *ufschd_uic_link_state_to_string( > > + enum uic_link_state state) > > +{ > > + switch (state) { > > + case UIC_LINK_OFF_STATE: return "OFF"; > > + case UIC_LINK_ACTIVE_STATE: return "ACTIVE"; > > + case UIC_LINK_HIBERN8_STATE: return "HIBERN8"; > > + default: return "UNKNOWN"; > > + } > > +} > > + > > +static const char *ufschd_ufs_dev_pwr_mode_to_string( > > + enum ufs_dev_pwr_mode state) > > +{ > > + switch (state) { > > + case UFS_ACTIVE_PWR_MODE: return "ACTIVE"; > > + case UFS_SLEEP_PWR_MODE: return "SLEEP"; > > + case UFS_POWERDOWN_PWR_MODE: return "POWERDOWN"; > > + default: return "UNKNOWN"; > > + } > > +} > > + > > +static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev, > > + struct device_attribute *attr, > > + const char *buf, size_t count, > > + bool rpm) > > +{ > > + struct ufs_hba *hba =3D dev_get_drvdata(dev); > > + unsigned long flags, value; > > + > > + if (kstrtoul(buf, 0, &value)) > > + return -EINVAL; > > + > > + if (value >=3D UFS_PM_LVL_MAX) > > + return -EINVAL; > > + > > + spin_lock_irqsave(hba->host->host_lock, flags); > > + if (rpm) > > + hba->rpm_lvl =3D value; > > + else > > + hba->spm_lvl =3D value; > > + spin_unlock_irqrestore(hba->host->host_lock, flags); > > + return count; > > +} > > + > > +static ssize_t rpm_lvl_show(struct device *dev, > > + struct device_attribute *attr, char *buf) { > > + struct ufs_hba *hba =3D dev_get_drvdata(dev); > > + int curr_len; > > + u8 lvl; > > + > > + curr_len =3D snprintf(buf, PAGE_SIZE, > > + "\nCurrent Runtime PM level [%d] =3D> dev_state > [%s] link_state [%s]\n", > > + hba->rpm_lvl, > > + ufschd_ufs_dev_pwr_mode_to_string( > > + ufs_pm_lvl_states[hba- > >rpm_lvl].dev_state), > > + ufschd_uic_link_state_to_string( > > + ufs_pm_lvl_states[hba- > >rpm_lvl].link_state)); > > + > > + curr_len +=3D snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > > + "\nAll available Runtime PM levels info:\n"); > > + for (lvl =3D UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) > > + curr_len +=3D snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > > + "\tRuntime PM level [%d] =3D> dev_state > [%s] link_state [%s]\n", > > + lvl, > > + ufschd_ufs_dev_pwr_mode_to_string( > > + ufs_pm_lvl_states[lvl].dev_state), > > + ufschd_uic_link_state_to_string( > > + ufs_pm_lvl_states[lvl].link_state)); > > + >=20 > sysfs if "one value per file", not "random text that someone has to parse= per > file" please. >=20 > Huge hint, if you ever care about checking the size of the sysfs buffer y= ou are > writing into, you are doing something really really wrong. >=20 Hi Greg It's the existing code, added by: commit 09690d5a6ae1b7e4cb5ac429c311b99d09352c12 Author: subhashj@codeaurora.org Date: Thu Dec 22 18:41:00 2016 -0800 scsi: ufs: provide sysfs attribute to select the PM level =20 This patch provides the sysfs attribute to choose the power management level for UFS runtime and system suspend. =20 Reviewed-by: Sujit Reddy Thumma Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen I just moved it to an another file and changed the sysfs entries creation b= y Jaegeuk Kim' request. At the moment the entry shows the PM level, the devic= e state, the link state and all possible PM levels. Do you want me to change = it? >=20 > > + return curr_len; > > +} > > + > > +static ssize_t rpm_lvl_store(struct device *dev, > > + struct device_attribute *attr, const char *buf, size_t count) { > > + return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, true); } > > + > > +static ssize_t spm_lvl_show(struct device *dev, > > + struct device_attribute *attr, char *buf) { > > + struct ufs_hba *hba =3D dev_get_drvdata(dev); > > + int curr_len; > > + u8 lvl; > > + > > + curr_len =3D snprintf(buf, PAGE_SIZE, > > + "\nCurrent System PM level [%d] =3D> dev_state > [%s] link_state [%s]\n", > > + hba->spm_lvl, > > + ufschd_ufs_dev_pwr_mode_to_string( > > + ufs_pm_lvl_states[hba- > >spm_lvl].dev_state), > > + ufschd_uic_link_state_to_string( > > + ufs_pm_lvl_states[hba- > >spm_lvl].link_state)); > > + > > + curr_len +=3D snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > > + "\nAll available System PM levels info:\n"); > > + for (lvl =3D UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) > > + curr_len +=3D snprintf((buf + curr_len), (PAGE_SIZE - curr_len), > > + "\tSystem PM level [%d] =3D> dev_state > [%s] link_state [%s]\n", > > + lvl, > > + ufschd_ufs_dev_pwr_mode_to_string( > > + ufs_pm_lvl_states[lvl].dev_state), > > + ufschd_uic_link_state_to_string( > > + ufs_pm_lvl_states[lvl].link_state)); > > + >=20 > Same here, this output is not ok. >=20 Same here. > > + return curr_len; > > +} > > + > > +static ssize_t spm_lvl_store(struct device *dev, > > + struct device_attribute *attr, const char *buf, size_t count) { > > + return ufs_sysfs_pm_lvl_store(dev, attr, buf, count, false); } > > + > > +static DEVICE_ATTR_RW(rpm_lvl); > > +static DEVICE_ATTR_RW(spm_lvl); > > + > > +static struct attribute *ufs_sysfs_ufshcd_attrs[] =3D { > > + &dev_attr_rpm_lvl.attr, > > + &dev_attr_spm_lvl.attr, > > + NULL > > +}; > > + > > +static const struct attribute_group ufs_sysfs_default_group =3D { > > + .attrs =3D ufs_sysfs_ufshcd_attrs, > > +}; > > + > > +static const struct attribute_group *ufs_sysfs_groups[] =3D { > > + &ufs_sysfs_default_group, > > + NULL, > > +}; >=20 > ATTRIBUTE_GROUPS() macro? >=20 > > +void ufs_sysfs_add_nodes(struct device *dev) { > > + int ret; > > + > > + ret =3D sysfs_create_groups(&dev->kobj, ufs_sysfs_groups); > > + if (ret) > > + dev_err(dev, > > + "%s: sysfs groups creation failed (err =3D %d)\n", > > + __func__, ret); >=20 > Why not return 'ret' so you can do something with it? The existing in the driver functions that create the sysfs entries do nothi= ng on failure, just error message. So I just keep the same logic. >=20 > thanks, >=20 > greg k-h Thank you. Stanislav