All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Tomas Winkler <tomas.winkler@intel.com>
Cc: "Ulf Hansson" <ulf.hansson@linaro.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Vinayak Holikatti" <vinholikatti@gmail.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Michael Ryleev" <gmar@google.com>,
	"Joao Pinto" <Joao.Pinto@synopsys.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Yaniv Gardi" <ygardi@codeaurora.org>,
	linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 3/8] char: rpmb: add device attributes
Date: Wed, 31 Aug 2016 12:56:34 +0200	[thread overview]
Message-ID: <20160831105634.GC10180@kroah.com> (raw)
In-Reply-To: <1468873673-21776-4-git-send-email-tomas.winkler@intel.com>

On Mon, Jul 18, 2016 at 11:27:48PM +0300, Tomas Winkler wrote:
> Add attribute type that displays underlay storage type technology
> EMMC, UFS, and attribute id, that displays underlay storage device id.
> For EMMC this would be content of CID and for UFS serial number from
> the device descriptor.
> 
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
> V2: resend
> V3: set kernel version to 4.7
> V4: update target date to Maj
> V5: adjust date and kernel version
>  Documentation/ABI/testing/sysfs-class-rpmb | 24 ++++++++++++
>  drivers/char/rpmb/core.c                   | 63 ++++++++++++++++++++++++++++++
>  2 files changed, 87 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-rpmb b/Documentation/ABI/testing/sysfs-class-rpmb
> index 3ffcd2d1f683..7ca97d86bd97 100644
> --- a/Documentation/ABI/testing/sysfs-class-rpmb
> +++ b/Documentation/ABI/testing/sysfs-class-rpmb
> @@ -18,3 +18,27 @@ Contact:	Tomas Winkler <tomas.winkler@intel.com>
>  Description:
>  		The /sys/class/rpmb/rpmbN directory is created for
>  		each RPMB registered device
> +
> +What:		/sys/class/rpmb/rpmbN/id
> +Date:		Aug 2016
> +KernelVersion:	4.8
> +Contact:	Tomas Winkler <tomas.winkler@intel.com>
> +Description:
> +		The /sys/class/rpmb/rpmbN/id file contains device id
> +		in a binary form

Oops, missed that you added these in a later patch, sorry about comment
on patch 2.

binary attribute?  Why?

> +
> +What:		/sys/class/rpmb/rpmbN/type
> +Date:		Aug 2016
> +KernelVersion:	4.8
> +Contact:	Tomas Winkler <tomas.winkler@intel.com>
> +Description:
> +		The /sys/class/rpmb/rpmbN/type file contains device
> +		underlay storage type technology: EMMC, UFS
> +

What is this used for?

> +What:		/sys/class/rpmb/rpmbN/reliable_wr_cnt
> +Date:		Aug 2016
> +KernelVersion:	4.8
> +Contact:	Tomas Winkler <tomas.winkler@intel.com>
> +Description:
> +		The /sys/class/rpmb/rpmbN/reliable_wr_cnt file contains
> +		number of blocks that can be written in a single request

Why is this needed?  Shouldn't the normal block device export this type
of information?


> diff --git a/drivers/char/rpmb/core.c b/drivers/char/rpmb/core.c
> index ff10cbb7b644..63271c7ed072 100644
> --- a/drivers/char/rpmb/core.c
> +++ b/drivers/char/rpmb/core.c
> @@ -308,6 +308,67 @@ struct rpmb_dev *rpmb_dev_find_by_device(struct device *parent)
>  }
>  EXPORT_SYMBOL_GPL(rpmb_dev_find_by_device);
>  
> +static ssize_t type_show(struct device *dev,
> +			 struct device_attribute *attr, char *buf)
> +{
> +	struct rpmb_dev *rdev = to_rpmb_dev(dev);
> +	ssize_t ret;
> +
> +	switch (rdev->ops->type) {
> +	case RPMB_TYPE_EMMC:
> +		ret = scnprintf(buf, PAGE_SIZE, "EMMC\n");

It's a sysfs file, no need for scnprintf() crap, just use sprintf()
please.

> +		break;

And the code can be made smaller by just doing:
		return sprintf(buf, "EMMC\n");

:)

> +	case RPMB_TYPE_UFS:
> +		ret = scnprintf(buf, PAGE_SIZE, "UFS\n");
> +		break;
> +	default:
> +		ret = scnprintf(buf, PAGE_SIZE, "UNKNOWN\n");
> +		break;
> +	}
> +
> +	return ret;
> +}
> +static DEVICE_ATTR_RO(type);
> +
> +static ssize_t id_show(struct device *dev,
> +		       struct device_attribute *attr, char *buf)
> +{
> +	struct rpmb_dev *rdev = to_rpmb_dev(dev);
> +	size_t sz = min_t(size_t, rdev->ops->dev_id_len, PAGE_SIZE);
> +
> +	if (!rdev->ops->dev_id)
> +		return 0;
> +
> +	memcpy(buf, rdev->ops->dev_id, sz);
>

Hm, no.  That's not how a binary attribute works.  If you want a binary
attribute, use that type, don't put binary data in a "normal" sysfs
file.

> +	return sz;
> +}
> +static DEVICE_ATTR_RO(id);
> +
> +static ssize_t reliable_wr_cnt_show(struct device *dev,
> +				    struct device_attribute *attr, char *buf)
> +{
> +	struct rpmb_dev *rdev = to_rpmb_dev(dev);
> +
> +	return scnprintf(buf, PAGE_SIZE, "%u\n", rdev->ops->reliable_wr_cnt);
> +}
> +static DEVICE_ATTR_RO(reliable_wr_cnt);
> +
> +static struct attribute *rpmb_attrs[] = {
> +	&dev_attr_type.attr,
> +	&dev_attr_id.attr,
> +	&dev_attr_reliable_wr_cnt.attr,
> +	NULL,
> +};
> +
> +static struct attribute_group rpmb_attr_group = {
> +	.attrs = rpmb_attrs,
> +};
> +
> +static const struct attribute_group *rpmb_attr_groups[] = {
> +	&rpmb_attr_group,
> +	NULL
> +};
> +
>  /**
>   * rpmb_dev_unregister - unregister RPMB partition from the RPMB subsystem
>   *
> @@ -377,6 +438,8 @@ struct rpmb_dev *rpmb_dev_register(struct device *dev,
>  	dev_set_name(&rdev->dev, "rpmb%d", id);
>  	rdev->dev.class = &rpmb_class;
>  	rdev->dev.parent = dev;
> +	rdev->dev.groups = rpmb_attr_groups;

Nice job with the group, thanks for doing that.

greg k-h

  reply	other threads:[~2016-08-31 10:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 20:27 [PATCH v5 0/8] Replay Protected Memory Block (RPMB) subsystem Tomas Winkler
2016-07-18 20:27 ` [PATCH v5 1/8] rpmb: add " Tomas Winkler
2016-07-18 20:27 ` [PATCH v5 2/8] char: rpmb: add sysfs-class ABI documentation Tomas Winkler
2016-08-31 10:53   ` Greg Kroah-Hartman
2016-07-18 20:27 ` [PATCH v5 3/8] char: rpmb: add device attributes Tomas Winkler
2016-08-31 10:56   ` Greg Kroah-Hartman [this message]
2016-09-01 20:21     ` Winkler, Tomas
2016-07-18 20:27 ` [PATCH v5 4/8] char: rpmb: provide a user space interface Tomas Winkler
2016-07-18 22:15   ` Paul Gortmaker
2016-07-20  9:02     ` Winkler, Tomas
2016-07-20 14:21       ` Paul Gortmaker
2016-08-05 20:08   ` Pavel Machek
2016-08-07  9:44     ` Winkler, Tomas
2016-08-31 10:49       ` Greg Kroah-Hartman
2016-09-01 20:05         ` Winkler, Tomas
2016-09-01 20:46           ` Greg Kroah-Hartman
2016-09-04 11:35             ` Winkler, Tomas
2016-09-04 20:20               ` Pavel Machek
2016-09-04 20:56                 ` Winkler, Tomas
2016-07-18 20:27 ` [PATCH v5 5/8] char: rpmb: add RPMB simulation device Tomas Winkler
2016-08-31 10:57   ` Greg Kroah-Hartman
2016-08-31 10:58   ` Greg Kroah-Hartman
2016-09-01 20:25     ` Winkler, Tomas
2016-09-01 20:45       ` Greg Kroah-Hartman
2016-07-18 20:27 ` [PATCH v5 6/8] tools rpmb: add RPBM access tool Tomas Winkler
2016-07-18 20:27 ` [PATCH v5 7/8] mmc: block: register RPMB partition with the RPMB subsystem Tomas Winkler
2016-07-18 20:27 ` [PATCH v5 8/8] scsi: ufs: connect to " Tomas Winkler
2016-07-23  7:44 ` [PATCH v5 0/8] Replay Protected Memory Block (RPMB) subsystem Winkler, Tomas
2016-08-05 20:06 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160831105634.GC10180@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=adrian.hunter@intel.com \
    --cc=arve@android.com \
    --cc=gmar@google.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tomas.winkler@intel.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vinholikatti@gmail.com \
    --cc=ygardi@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.