Skip to content

Commit 55c4e64

Browse files
Tomas Winklergregkh
authored andcommitted
mei: export fw status registers through sysfs
The interface is for applications that monitor the fw health. We use device_create_with_groups interface to register attribute with the mei class device Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent edca5ea commit 55c4e64

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

‎drivers/misc/mei/main.c‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,44 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
631631
return mask;
632632
}
633633

634+
/**
635+
* fw_status_show - mei device attribute show method
636+
*
637+
* @device: device pointer
638+
* @attr: attribute pointer
639+
* @buf: char out buffer
640+
*
641+
* Return: number of the bytes printed into buf or error
642+
*/
643+
static ssize_t fw_status_show(struct device *device,
644+
struct device_attribute *attr, char *buf)
645+
{
646+
struct mei_device *dev = dev_get_drvdata(device);
647+
struct mei_fw_status fw_status;
648+
int err, i;
649+
ssize_t cnt = 0;
650+
651+
mutex_lock(&dev->device_lock);
652+
err = mei_fw_status(dev, &fw_status);
653+
mutex_unlock(&dev->device_lock);
654+
if (err) {
655+
dev_err(device, "read fw_status error = %d\n", err);
656+
return err;
657+
}
658+
659+
for (i = 0; i < fw_status.count; i++)
660+
cnt += scnprintf(buf + cnt, PAGE_SIZE - cnt, "%08X\n",
661+
fw_status.status[i]);
662+
return cnt;
663+
}
664+
static DEVICE_ATTR_RO(fw_status);
665+
666+
static struct attribute *mei_attrs[] = {
667+
&dev_attr_fw_status.attr,
668+
NULL
669+
};
670+
ATTRIBUTE_GROUPS(mei);
671+
634672
/*
635673
* file operations structure will be used for mei char device.
636674
*/
@@ -710,8 +748,9 @@ int mei_register(struct mei_device *dev, struct device *parent)
710748
goto err_dev_add;
711749
}
712750

713-
clsdev = device_create(mei_class, parent, devno,
714-
NULL, "mei%d", dev->minor);
751+
clsdev = device_create_with_groups(mei_class, parent, devno,
752+
dev, mei_groups,
753+
"mei%d", dev->minor);
715754

716755
if (IS_ERR(clsdev)) {
717756
dev_err(parent, "unable to create device %d:%d\n",

0 commit comments

Comments
 (0)