2019-11-16 11:38:03

by Tomas Winkler

[permalink] [raw]
Subject: [char-misc-next] mei: bus: add more client attributes to sysfs

From: Alexander Usyskin <[email protected]>

Export more client attributes via sysfs that are usually obtained
upon connection. In some cases, for example a monitoring application
may wish to know the attributes without actually performing the connection.
Added attributes:
max number of connections, fixed address, max message length.

Signed-off-by: Alexander Usyskin <[email protected]>
Signed-off-by: Tomas Winkler <[email protected]>
---
Documentation/ABI/testing/sysfs-bus-mei | 21 +++++++++++++++
drivers/misc/mei/bus.c | 33 +++++++++++++++++++++++
drivers/misc/mei/client.h | 36 +++++++++++++++++++++++++
3 files changed, 90 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-mei b/Documentation/ABI/testing/sysfs-bus-mei
index 3f8701e8fa24..3d37e2796d5a 100644
--- a/Documentation/ABI/testing/sysfs-bus-mei
+++ b/Documentation/ABI/testing/sysfs-bus-mei
@@ -26,3 +26,24 @@ KernelVersion: 4.3
Contact: Tomas Winkler <[email protected]>
Description: Stores mei client protocol version
Format: %d
+
+What: /sys/bus/mei/devices/.../max_conn
+Date: Nov 2019
+KernelVersion: 5.5
+Contact: Tomas Winkler <[email protected]>
+Description: Stores mei client maximum number of connections
+ Format: %d
+
+What: /sys/bus/mei/devices/.../fixed
+Date: Nov 2019
+KernelVersion: 5.5
+Contact: Tomas Winkler <[email protected]>
+Description: Stores mei client fixed address, if any
+ Format: %d
+
+What: /sys/bus/mei/devices/.../max_len
+Date: Nov 2019
+KernelVersion: 5.5
+Contact: Tomas Winkler <[email protected]>
+Description: Stores mei client maximum message length
+ Format: %d
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 53bb394ccba6..a0a495c95e3c 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -791,11 +791,44 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
}
static DEVICE_ATTR_RO(modalias);

+static ssize_t max_conn_show(struct device *dev, struct device_attribute *a,
+ char *buf)
+{
+ struct mei_cl_device *cldev = to_mei_cl_device(dev);
+ u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
+
+ return scnprintf(buf, PAGE_SIZE, "%d", maxconn);
+}
+static DEVICE_ATTR_RO(max_conn);
+
+static ssize_t fixed_show(struct device *dev, struct device_attribute *a,
+ char *buf)
+{
+ struct mei_cl_device *cldev = to_mei_cl_device(dev);
+ u8 fixed = mei_me_cl_fixed(cldev->me_cl);
+
+ return scnprintf(buf, PAGE_SIZE, "%d", fixed);
+}
+static DEVICE_ATTR_RO(fixed);
+
+static ssize_t max_len_show(struct device *dev, struct device_attribute *a,
+ char *buf)
+{
+ struct mei_cl_device *cldev = to_mei_cl_device(dev);
+ u32 maxlen = mei_me_cl_max_len(cldev->me_cl);
+
+ return scnprintf(buf, PAGE_SIZE, "%u", maxlen);
+}
+static DEVICE_ATTR_RO(max_len);
+
static struct attribute *mei_cldev_attrs[] = {
&dev_attr_name.attr,
&dev_attr_uuid.attr,
&dev_attr_version.attr,
&dev_attr_modalias.attr,
+ &dev_attr_max_conn.attr,
+ &dev_attr_fixed.attr,
+ &dev_attr_max_len.attr,
NULL,
};
ATTRIBUTE_GROUPS(mei_cldev);
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index c1f9e810cf81..2f8954def591 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -69,6 +69,42 @@ static inline u8 mei_me_cl_ver(const struct mei_me_client *me_cl)
return me_cl->props.protocol_version;
}

+/**
+ * mei_me_cl_max_conn - return me client max number of connections
+ *
+ * @me_cl: me client
+ *
+ * Return: me client max number of connections
+ */
+static inline u8 mei_me_cl_max_conn(const struct mei_me_client *me_cl)
+{
+ return me_cl->props.max_number_of_connections;
+}
+
+/**
+ * mei_me_cl_fixed - return me client fixed address, if any
+ *
+ * @me_cl: me client
+ *
+ * Return: me client fixed address
+ */
+static inline u8 mei_me_cl_fixed(const struct mei_me_client *me_cl)
+{
+ return me_cl->props.fixed_address;
+}
+
+/**
+ * mei_me_cl_max_len - return me client max msg length
+ *
+ * @me_cl: me client
+ *
+ * Return: me client max msg length
+ */
+static inline u32 mei_me_cl_max_len(const struct mei_me_client *me_cl)
+{
+ return me_cl->props.max_msg_length;
+}
+
/*
* MEI IO Functions
*/
--
2.21.0


2019-11-16 12:02:14

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [char-misc-next] mei: bus: add more client attributes to sysfs

On Sat, Nov 16, 2019 at 04:21:36PM +0200, Tomas Winkler wrote:
> From: Alexander Usyskin <[email protected]>
>
> Export more client attributes via sysfs that are usually obtained
> upon connection. In some cases, for example a monitoring application
> may wish to know the attributes without actually performing the connection.
> Added attributes:
> max number of connections, fixed address, max message length.
>
> Signed-off-by: Alexander Usyskin <[email protected]>
> Signed-off-by: Tomas Winkler <[email protected]>
> ---
> Documentation/ABI/testing/sysfs-bus-mei | 21 +++++++++++++++
> drivers/misc/mei/bus.c | 33 +++++++++++++++++++++++
> drivers/misc/mei/client.h | 36 +++++++++++++++++++++++++
> 3 files changed, 90 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-mei b/Documentation/ABI/testing/sysfs-bus-mei
> index 3f8701e8fa24..3d37e2796d5a 100644
> --- a/Documentation/ABI/testing/sysfs-bus-mei
> +++ b/Documentation/ABI/testing/sysfs-bus-mei
> @@ -26,3 +26,24 @@ KernelVersion: 4.3
> Contact: Tomas Winkler <[email protected]>
> Description: Stores mei client protocol version
> Format: %d
> +
> +What: /sys/bus/mei/devices/.../max_conn
> +Date: Nov 2019
> +KernelVersion: 5.5
> +Contact: Tomas Winkler <[email protected]>
> +Description: Stores mei client maximum number of connections
> + Format: %d
> +
> +What: /sys/bus/mei/devices/.../fixed
> +Date: Nov 2019
> +KernelVersion: 5.5
> +Contact: Tomas Winkler <[email protected]>
> +Description: Stores mei client fixed address, if any
> + Format: %d
> +
> +What: /sys/bus/mei/devices/.../max_len
> +Date: Nov 2019
> +KernelVersion: 5.5
> +Contact: Tomas Winkler <[email protected]>
> +Description: Stores mei client maximum message length
> + Format: %d
> diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
> index 53bb394ccba6..a0a495c95e3c 100644
> --- a/drivers/misc/mei/bus.c
> +++ b/drivers/misc/mei/bus.c
> @@ -791,11 +791,44 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
> }
> static DEVICE_ATTR_RO(modalias);
>
> +static ssize_t max_conn_show(struct device *dev, struct device_attribute *a,
> + char *buf)
> +{
> + struct mei_cl_device *cldev = to_mei_cl_device(dev);
> + u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
> +
> + return scnprintf(buf, PAGE_SIZE, "%d", maxconn);

Nit, you can just do sprintf() for sysfs file attributes as you "know"
the buffer is big enough and your variable will fit.

Not a bit deal, but something to do in the future.

thanks,

greg k-h

2019-11-16 12:11:52

by Tomas Winkler

[permalink] [raw]
Subject: RE: [char-misc-next] mei: bus: add more client attributes to sysfs

>
> On Sat, Nov 16, 2019 at 04:21:36PM +0200, Tomas Winkler wrote:
> > From: Alexander Usyskin <[email protected]>
> >
> > Export more client attributes via sysfs that are usually obtained upon
> > connection. In some cases, for example a monitoring application may
> > wish to know the attributes without actually performing the connection.
> > Added attributes:
> > max number of connections, fixed address, max message length.
> >
> > Signed-off-by: Alexander Usyskin <[email protected]>
> > Signed-off-by: Tomas Winkler <[email protected]>
> > ---
> > Documentation/ABI/testing/sysfs-bus-mei | 21 +++++++++++++++
> > drivers/misc/mei/bus.c | 33 +++++++++++++++++++++++
> > drivers/misc/mei/client.h | 36 +++++++++++++++++++++++++
> > 3 files changed, 90 insertions(+)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-bus-mei
> > b/Documentation/ABI/testing/sysfs-bus-mei
> > index 3f8701e8fa24..3d37e2796d5a 100644
> > --- a/Documentation/ABI/testing/sysfs-bus-mei
> > +++ b/Documentation/ABI/testing/sysfs-bus-mei
> > @@ -26,3 +26,24 @@ KernelVersion: 4.3
> > Contact: Tomas Winkler <[email protected]>
> > Description: Stores mei client protocol version
> > Format: %d
> > +
> > +What: /sys/bus/mei/devices/.../max_conn
> > +Date: Nov 2019
> > +KernelVersion: 5.5
> > +Contact: Tomas Winkler <[email protected]>
> > +Description: Stores mei client maximum number of connections
> > + Format: %d
> > +
> > +What: /sys/bus/mei/devices/.../fixed
> > +Date: Nov 2019
> > +KernelVersion: 5.5
> > +Contact: Tomas Winkler <[email protected]>
> > +Description: Stores mei client fixed address, if any
> > + Format: %d
> > +
> > +What: /sys/bus/mei/devices/.../max_len
> > +Date: Nov 2019
> > +KernelVersion: 5.5
> > +Contact: Tomas Winkler <[email protected]>
> > +Description: Stores mei client maximum message length
> > + Format: %d
> > diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index
> > 53bb394ccba6..a0a495c95e3c 100644
> > --- a/drivers/misc/mei/bus.c
> > +++ b/drivers/misc/mei/bus.c
> > @@ -791,11 +791,44 @@ static ssize_t modalias_show(struct device *dev,
> > struct device_attribute *a, } static DEVICE_ATTR_RO(modalias);
> >
> > +static ssize_t max_conn_show(struct device *dev, struct device_attribute
> *a,
> > + char *buf)
> > +{
> > + struct mei_cl_device *cldev = to_mei_cl_device(dev);
> > + u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
> > +
> > + return scnprintf(buf, PAGE_SIZE, "%d", maxconn);
>
> Nit, you can just do sprintf() for sysfs file attributes as you "know"
> the buffer is big enough and your variable will fit.
>
> Not a bit deal, but something to do in the future.


Right, missed that, I can fix it in a follow up patch or resend this one.
Thanks
Tomas


2019-11-16 12:40:30

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [char-misc-next] mei: bus: add more client attributes to sysfs

On Sat, Nov 16, 2019 at 12:08:52PM +0000, Winkler, Tomas wrote:
> >
> > On Sat, Nov 16, 2019 at 04:21:36PM +0200, Tomas Winkler wrote:
> > > From: Alexander Usyskin <[email protected]>
> > >
> > > Export more client attributes via sysfs that are usually obtained upon
> > > connection. In some cases, for example a monitoring application may
> > > wish to know the attributes without actually performing the connection.
> > > Added attributes:
> > > max number of connections, fixed address, max message length.
> > >
> > > Signed-off-by: Alexander Usyskin <[email protected]>
> > > Signed-off-by: Tomas Winkler <[email protected]>
> > > ---
> > > Documentation/ABI/testing/sysfs-bus-mei | 21 +++++++++++++++
> > > drivers/misc/mei/bus.c | 33 +++++++++++++++++++++++
> > > drivers/misc/mei/client.h | 36 +++++++++++++++++++++++++
> > > 3 files changed, 90 insertions(+)
> > >
> > > diff --git a/Documentation/ABI/testing/sysfs-bus-mei
> > > b/Documentation/ABI/testing/sysfs-bus-mei
> > > index 3f8701e8fa24..3d37e2796d5a 100644
> > > --- a/Documentation/ABI/testing/sysfs-bus-mei
> > > +++ b/Documentation/ABI/testing/sysfs-bus-mei
> > > @@ -26,3 +26,24 @@ KernelVersion: 4.3
> > > Contact: Tomas Winkler <[email protected]>
> > > Description: Stores mei client protocol version
> > > Format: %d
> > > +
> > > +What: /sys/bus/mei/devices/.../max_conn
> > > +Date: Nov 2019
> > > +KernelVersion: 5.5
> > > +Contact: Tomas Winkler <[email protected]>
> > > +Description: Stores mei client maximum number of connections
> > > + Format: %d
> > > +
> > > +What: /sys/bus/mei/devices/.../fixed
> > > +Date: Nov 2019
> > > +KernelVersion: 5.5
> > > +Contact: Tomas Winkler <[email protected]>
> > > +Description: Stores mei client fixed address, if any
> > > + Format: %d
> > > +
> > > +What: /sys/bus/mei/devices/.../max_len
> > > +Date: Nov 2019
> > > +KernelVersion: 5.5
> > > +Contact: Tomas Winkler <[email protected]>
> > > +Description: Stores mei client maximum message length
> > > + Format: %d
> > > diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index
> > > 53bb394ccba6..a0a495c95e3c 100644
> > > --- a/drivers/misc/mei/bus.c
> > > +++ b/drivers/misc/mei/bus.c
> > > @@ -791,11 +791,44 @@ static ssize_t modalias_show(struct device *dev,
> > > struct device_attribute *a, } static DEVICE_ATTR_RO(modalias);
> > >
> > > +static ssize_t max_conn_show(struct device *dev, struct device_attribute
> > *a,
> > > + char *buf)
> > > +{
> > > + struct mei_cl_device *cldev = to_mei_cl_device(dev);
> > > + u8 maxconn = mei_me_cl_max_conn(cldev->me_cl);
> > > +
> > > + return scnprintf(buf, PAGE_SIZE, "%d", maxconn);
> >
> > Nit, you can just do sprintf() for sysfs file attributes as you "know"
> > the buffer is big enough and your variable will fit.
> >
> > Not a bit deal, but something to do in the future.
>
>
> Right, missed that, I can fix it in a follow up patch or resend this one.

follow-up is fine, I've already queued this one up.

thanks,

greg k-h