RE: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-04 Thread Stanislav Nijnikov


> -Original Message-
> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> Sent: Wednesday, January 3, 2018 3:44 AM
> To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> gre...@linuxfoundation.org; Alex Lemberg <alex.lemb...@wdc.com>
> Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> 
> On 01/02, Stanislav Nijnikov wrote:
> >
> >
> > > -Original Message-
> > > From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> > > Sent: Thursday, December 28, 2017 9:37 PM
> > > To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> > > gre...@linuxfoundation.org; Alex Lemberg <alex.lemb...@wdc.com>
> > > Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> > >
> > > On 12/28, Stanislav Nijnikov wrote:
> > > > This patch introduces a sysfs group entry for the UFS device
> > > > descriptor parameters. The group adds "device_descriptor" folder
> > > > under the UFS driver sysfs entry
> > > > (/sys/bus/platform/drivers/ufshcd/*). The parameters are shown as
> > > > hexadecimal numbers. The full information about the parameters could
> be found at UFS specifications 2.1.
> > > >
> > > > Signed-off-by: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > > > ---
> > > >  Documentation/ABI/testing/sysfs-driver-ufs | 223
> > > +
> > > >  drivers/scsi/ufs/Makefile  |   3 +-
> > > >  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
> > > >  drivers/scsi/ufs/ufs-sysfs.h   |  25 
> > > >  drivers/scsi/ufs/ufs.h |   8 ++
> > > >  drivers/scsi/ufs/ufshcd.c  |  12 +-
> > > >  drivers/scsi/ufs/ufshcd.h  |   4 +
> > > >  7 files changed, 439 insertions(+), 6 deletions(-)  create mode
> > > > 100644 Documentation/ABI/testing/sysfs-driver-ufs
> > > >  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode
> > > > 100644 drivers/scsi/ufs/ufs-sysfs.h
> > > >
> > > > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> > > > b/Documentation/ABI/testing/sysfs-driver-ufs
> > > > new file mode 100644
> > > > index 000..17cc4aa
> > > > --- /dev/null
> > > > +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> > >
> > > [snip]
> > >
> > > > 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) += tc-dwc-g210-pci.o ufshcd-
> > > dwc.o
> > > > tc-dwc-g210.o
> > > >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-
> pltfrm.o
> > > > ufshcd-dwc.o tc-dwc-g210.o
> > > >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > > > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > > > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > > > +ufshcd.o ufs-sysfs.o
> > >
> > > Why not just adding ufs-sysfs.o in the existing configuration?
> >
> > The kernel build robot compiles the UFS driver as a separate module.
> > The existing configuration doesn't allow to add a new file to be
> > compiled as a part of this module. The line like "
> > obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o ufs-sysfs.o" in the makefile will
> actually create 2 modules.
> > This was the reason why I used EXPORT_SYMBOL in the first version.
> 
> Is there a reason to drop the first version?
> 
It was updated according to Greg Kroah-Hartman' notes (one of them was what is
a reason to use EXPORT_SYMBOL if functions are used only in one module).
> >
> > >
> > > >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> > > >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > > > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new
> > > > file mode 100644 index 000..1c685f3
> > > > --- /dev/null
> > > > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > > > @@ -0,0 +1,170 @@
> > > > +/*
> > > > +* UFS Device Management sysfs
> > > > +*
> > > > +* Copyright (C) 2017 Western Digital Corpo

Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Jaegeuk Kim
On 01/02, Stanislav Nijnikov wrote:
> 
> 
> > -Original Message-
> > From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> > Sent: Thursday, December 28, 2017 9:37 PM
> > To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> > gre...@linuxfoundation.org; Alex Lemberg <alex.lemb...@wdc.com>
> > Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> > 
> > On 12/28, Stanislav Nijnikov wrote:
> > > This patch introduces a sysfs group entry for the UFS device
> > > descriptor parameters. The group adds "device_descriptor" folder under
> > > the UFS driver sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The
> > > parameters are shown as hexadecimal numbers. The full information
> > > about the parameters could be found at UFS specifications 2.1.
> > >
> > > Signed-off-by: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > > ---
> > >  Documentation/ABI/testing/sysfs-driver-ufs | 223
> > +
> > >  drivers/scsi/ufs/Makefile  |   3 +-
> > >  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
> > >  drivers/scsi/ufs/ufs-sysfs.h   |  25 
> > >  drivers/scsi/ufs/ufs.h |   8 ++
> > >  drivers/scsi/ufs/ufshcd.c  |  12 +-
> > >  drivers/scsi/ufs/ufshcd.h  |   4 +
> > >  7 files changed, 439 insertions(+), 6 deletions(-)  create mode
> > > 100644 Documentation/ABI/testing/sysfs-driver-ufs
> > >  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode 100644
> > > drivers/scsi/ufs/ufs-sysfs.h
> > >
> > > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> > > b/Documentation/ABI/testing/sysfs-driver-ufs
> > > new file mode 100644
> > > index 000..17cc4aa
> > > --- /dev/null
> > > +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> > 
> > [snip]
> > 
> > > 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) += tc-dwc-g210-pci.o ufshcd-
> > dwc.o
> > > tc-dwc-g210.o
> > >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> > > ufshcd-dwc.o tc-dwc-g210.o
> > >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > > +ufshcd.o ufs-sysfs.o
> > 
> > Why not just adding ufs-sysfs.o in the existing configuration?
> 
> The kernel build robot compiles the UFS driver as a separate module. 
> The existing configuration doesn't allow to add a new file to be compiled 
> as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
> ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
> This was the reason why I used EXPORT_SYMBOL in the first version.

Is there a reason to drop the first version?

> 
> > 
> > >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> > >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file
> > > mode 100644 index 000..1c685f3
> > > --- /dev/null
> > > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > > @@ -0,0 +1,170 @@
> > > +/*
> > > +* UFS Device Management sysfs
> > > +*
> > > +* Copyright (C) 2017 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 version
> > > +* 2 as published by the Free Software Foundation.
> > > +*
> > > +* 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.
> > > +*
> > > +*/
> > > +
> > > +#include 
> > > +#include 
> > > +
> > > +#include "ufs.h"
> > > +#include "ufs-sysfs.h"
> > > +/* collision between the device descriptor parameter and the
> > > +definition */ #undef DEVICE_CLASS
> > 
> > Does this 

Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Bart Van Assche
On Tue, 2018-01-02 at 13:54 +, Stanislav Nijnikov wrote:
> The existing configuration doesn't allow to add a new file to be compiled 
> as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
> ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
> This was the reason why I used EXPORT_SYMBOL in the first version.

There are plenty of kernel modules that consist of multiple source files, e.g.
the SCSI core. Please make yourself familiar with how to do this.

Thanks,

Bart.

Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Greg KH
On Tue, Jan 02, 2018 at 02:04:39PM +, Stanislav Nijnikov wrote:
> 
> 
> > -Original Message-
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Friday, December 29, 2017 11:23 AM
> > To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org; Alex Lemberg
> > <alex.lemb...@wdc.com>
> > Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> > 
> > On Thu, Dec 28, 2017 at 03:29:06PM +0200, Stanislav Nijnikov wrote:
> > > --- /dev/null
> > > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > > @@ -0,0 +1,170 @@
> > > +/*
> > > +* UFS Device Management sysfs
> > > +*
> > > +* Copyright (C) 2017 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 version
> > > +* 2 as published by the Free Software Foundation.
> > > +*
> > > +* 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.
> > 
> > Please use the SPDX format for all of this, like I asked last time :(
> > 
> > thanks,
> > 
> > greg k-h
>  
> Hi Greg.
> Sorry about this.
> Is this the proper legal header?

First off, don't as a developer legal questions, ask your lawyers :)

> 
> /*
> * UFS Device Management sysfs
> *
> *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.
> *
> *You should have received a copy of the GNU General Public License along
> *with this program; if not, write to the Free Software Foundation, Inc.,
> *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA.
> */
> 
> It was taken from <https://spdx.org/licenses/GPL-2.0-only.html#licenseText>
> 
> Thanks and Happy New Year!

Nope, sorry, see the email thread on lkml from Thomas where he documents
how to properly set the SPDX line and why you don't want any of the
"boiler plate" text in there at all.

thanks,

greg k-h


RE: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Stanislav Nijnikov


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Friday, December 29, 2017 11:23 AM
> To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org; Alex Lemberg
> <alex.lemb...@wdc.com>
> Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> 
> On Thu, Dec 28, 2017 at 03:29:06PM +0200, Stanislav Nijnikov wrote:
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -0,0 +1,170 @@
> > +/*
> > +* UFS Device Management sysfs
> > +*
> > +* Copyright (C) 2017 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 version
> > +* 2 as published by the Free Software Foundation.
> > +*
> > +* 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.
> 
> Please use the SPDX format for all of this, like I asked last time :(
> 
> thanks,
> 
> greg k-h
 
Hi Greg.
Sorry about this.
Is this the proper legal header?

/*
* UFS Device Management sysfs
*
*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.
*
*You should have received a copy of the GNU General Public License along
*with this program; if not, write to the Free Software Foundation, Inc.,
*51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA.
*/

It was taken from <https://spdx.org/licenses/GPL-2.0-only.html#licenseText>

Thanks and Happy New Year!




RE: [PATCH v3 1/9] ufs: sysfs: device descriptor

2018-01-02 Thread Stanislav Nijnikov


> -Original Message-
> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> Sent: Thursday, December 28, 2017 9:37 PM
> To: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> gre...@linuxfoundation.org; Alex Lemberg <alex.lemb...@wdc.com>
> Subject: Re: [PATCH v3 1/9] ufs: sysfs: device descriptor
> 
> On 12/28, Stanislav Nijnikov wrote:
> > This patch introduces a sysfs group entry for the UFS device
> > descriptor parameters. The group adds "device_descriptor" folder under
> > the UFS driver sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The
> > parameters are shown as hexadecimal numbers. The full information
> > about the parameters could be found at UFS specifications 2.1.
> >
> > Signed-off-by: Stanislav Nijnikov <stanislav.nijni...@wdc.com>
> > ---
> >  Documentation/ABI/testing/sysfs-driver-ufs | 223
> +
> >  drivers/scsi/ufs/Makefile  |   3 +-
> >  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
> >  drivers/scsi/ufs/ufs-sysfs.h   |  25 
> >  drivers/scsi/ufs/ufs.h |   8 ++
> >  drivers/scsi/ufs/ufshcd.c  |  12 +-
> >  drivers/scsi/ufs/ufshcd.h  |   4 +
> >  7 files changed, 439 insertions(+), 6 deletions(-)  create mode
> > 100644 Documentation/ABI/testing/sysfs-driver-ufs
> >  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode 100644
> > drivers/scsi/ufs/ufs-sysfs.h
> >
> > diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> > b/Documentation/ABI/testing/sysfs-driver-ufs
> > new file mode 100644
> > index 000..17cc4aa
> > --- /dev/null
> > +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> 
> [snip]
> 
> > 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) += tc-dwc-g210-pci.o ufshcd-
> dwc.o
> > tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> > ufshcd-dwc.o tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > +ufshcd.o ufs-sysfs.o
> 
> Why not just adding ufs-sysfs.o in the existing configuration?

The kernel build robot compiles the UFS driver as a separate module. 
The existing configuration doesn't allow to add a new file to be compiled 
as a part of this module. The line like " obj-$(CONFIG_SCSI_UFSHCD) += 
ufshcd.o ufs-sysfs.o" in the makefile will actually create 2 modules.
This was the reason why I used EXPORT_SYMBOL in the first version.

> 
> >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file
> > mode 100644 index 000..1c685f3
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -0,0 +1,170 @@
> > +/*
> > +* UFS Device Management sysfs
> > +*
> > +* Copyright (C) 2017 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 version
> > +* 2 as published by the Free Software Foundation.
> > +*
> > +* 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.
> > +*
> > +*/
> > +
> > +#include 
> > +#include 
> > +
> > +#include "ufs.h"
> > +#include "ufs-sysfs.h"
> > +/* collision between the device descriptor parameter and the
> > +definition */ #undef DEVICE_CLASS
> 
> Does this make sense? How about attaching "_" for all the macro like
> _DEVICE_CLASS below?
> 

It's not just changing the one line that uses "DEVICE_CLASS" to use 
"_DEVICE_CLASS". It's will be necessary to add "_" to all descriptor
parameters macros in all patches.

> > +
> > +enum ufs_desc_param_size {
> > +   UFS_PARAM_BYTE_SIZE = 1,
> > +   UFS_PARAM_WORD_SIZE = 2,
> > +   UFS_PARAM_DWORD_SIZE= 4,
> > +   UFS_PARAM_QWORD_SIZE= 8,
> > +};
> > +
> > +static inlin

Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2017-12-29 Thread Greg KH
On Thu, Dec 28, 2017 at 03:29:06PM +0200, Stanislav Nijnikov wrote:
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -0,0 +1,170 @@
> +/*
> +* UFS Device Management sysfs
> +*
> +* Copyright (C) 2017 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 version
> +* 2 as published by the Free Software Foundation.
> +*
> +* 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.

Please use the SPDX format for all of this, like I asked last time :(

thanks,

greg k-h


Re: [PATCH v3 1/9] ufs: sysfs: device descriptor

2017-12-28 Thread Jaegeuk Kim
On 12/28, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS device descriptor
> parameters. The group adds "device_descriptor" folder under the UFS driver
> sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The parameters are shown
> as hexadecimal numbers. The full information about the parameters could be
> found at UFS specifications 2.1.
> 
> Signed-off-by: Stanislav Nijnikov 
> ---
>  Documentation/ABI/testing/sysfs-driver-ufs | 223 
> +
>  drivers/scsi/ufs/Makefile  |   3 +-
>  drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
>  drivers/scsi/ufs/ufs-sysfs.h   |  25 
>  drivers/scsi/ufs/ufs.h |   8 ++
>  drivers/scsi/ufs/ufshcd.c  |  12 +-
>  drivers/scsi/ufs/ufshcd.h  |   4 +
>  7 files changed, 439 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-driver-ufs
>  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
>  create mode 100644 drivers/scsi/ufs/ufs-sysfs.h
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
> b/Documentation/ABI/testing/sysfs-driver-ufs
> new file mode 100644
> index 000..17cc4aa
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-ufs

[snip]

> 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) += tc-dwc-g210-pci.o ufshcd-dwc.o 
> tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
> tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
> +ufshcd-core-objs := ufshcd.o ufs-sysfs.o

Why not just adding ufs-sysfs.o in the existing configuration?

>  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
>  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> new file mode 100644
> index 000..1c685f3
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -0,0 +1,170 @@
> +/*
> +* UFS Device Management sysfs
> +*
> +* Copyright (C) 2017 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 version
> +* 2 as published by the Free Software Foundation.
> +*
> +* 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.
> +*
> +*/
> +
> +#include 
> +#include 
> +
> +#include "ufs.h"
> +#include "ufs-sysfs.h"
> +/* collision between the device descriptor parameter and the definition */
> +#undef DEVICE_CLASS

Does this make sense? How about attaching "_" for all the macro like
_DEVICE_CLASS below?

> +
> +enum ufs_desc_param_size {
> + UFS_PARAM_BYTE_SIZE = 1,
> + UFS_PARAM_WORD_SIZE = 2,
> + UFS_PARAM_DWORD_SIZE= 4,
> + UFS_PARAM_QWORD_SIZE= 8,
> +};
> +
> +static inline ssize_t ufs_sysfs_read_desc_param(
> + struct ufs_hba *hba, u8 desc_idn, u8 index, char *buf, u8 off,
> + enum ufs_desc_param_size param_size)
> +{
> + int desc_len;
> + int ret;
> + u8 *desc_buf;
> +
> + if (ufshcd_map_desc_id_to_length(hba, desc_idn, _len) ||
> + off >= desc_len)
> + return -EINVAL;
> + desc_buf = kzalloc(desc_len, GFP_ATOMIC);
> + if (!desc_buf)
> + return -ENOMEM;
> + ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC,
> + desc_idn, index, 0, desc_buf, _len);
> + if (ret)

Should free desc_buf here.

> + return -EINVAL;
> + switch (param_size) {
> + case UFS_PARAM_BYTE_SIZE:
> + ret = sprintf(buf, "0x%02X\n", desc_buf[off]);
> + break;
> + case UFS_PARAM_WORD_SIZE:
> + ret = sprintf(buf, "0x%04X\n",
> + be16_to_cpu(*((u16 *)(desc_buf + off;
> + break;
> + case UFS_PARAM_DWORD_SIZE:
> + ret = sprintf(buf, "0x%08X\n",
> + be32_to_cpu(*((u32 *)(desc_buf + off;
> + break;
> + case UFS_PARAM_QWORD_SIZE:
> + ret = sprintf(buf, "0x%016llX\n",
> + be64_to_cpu(*((u64 *)(desc_buf + off;
> + break;
> + }
> + kfree(desc_buf);
> +
> + return ret;
> +}
> +
> +#define ufs_sysfs_desc_param_show(_name, _puname, _duname, _size)
>  \
> +static ssize_t _name##_show(struct device *dev,  
>  \
> + struct device_attribute *attr, char *buf) \
> +{ 

[PATCH v3 1/9] ufs: sysfs: device descriptor

2017-12-28 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS device descriptor
parameters. The group adds "device_descriptor" folder under the UFS driver
sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The parameters are shown
as hexadecimal numbers. The full information about the parameters could be
found at UFS specifications 2.1.

Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 223 +
 drivers/scsi/ufs/Makefile  |   3 +-
 drivers/scsi/ufs/ufs-sysfs.c   | 170 ++
 drivers/scsi/ufs/ufs-sysfs.h   |  25 
 drivers/scsi/ufs/ufs.h |   8 ++
 drivers/scsi/ufs/ufshcd.c  |  12 +-
 drivers/scsi/ufs/ufshcd.h  |   4 +
 7 files changed, 439 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ufs
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.h

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
new file mode 100644
index 000..17cc4aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -0,0 +1,223 @@
+What:  /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_type
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the device type. This is one of the UFS
+   device descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_class
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the device class. This is one of the UFS
+   device descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_sub_class
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the UFS storage subclass. This is one of
+   the UFS device descriptor parameters. The full information
+   about the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/device_descriptor/protocol
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the protocol supported by an UFS device.
+   This is one of the UFS device descriptor parameters.
+   The full information about the descriptor could be found
+   at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/device_descriptor/number_of_luns
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows number of logical units. This is one of
+   the UFS device descriptor parameters. The full information
+   about the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/device_descriptor/number_of_wluns
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows number of well known logical units.
+   This is one of the UFS device descriptor parameters.
+   The full information about the descriptor could be found
+   at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/device_descriptor/boot_enable
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows value that indicates whether the device is
+   enabled for boot. This is one of the UFS device descriptor
+   parameters. The full information about the descriptor could
+   be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/device_descriptor/descriptor_access_enable
+Date:  December 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows value that indicates whether the device
+   descriptor could be read after partial initialization phase
+   of the boot sequence. This is one of the UFS device descriptor
+   parameters. The full information about the descriptor could
+   be found at UFS