Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomas Winkler and committed by
Greg Kroah-Hartman
55c4e640 edca5ea3

+41 -2
+41 -2
drivers/misc/mei/main.c
··· 631 631 return mask; 632 632 } 633 633 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 + 634 672 /* 635 673 * file operations structure will be used for mei char device. 636 674 */ ··· 748 710 goto err_dev_add; 749 711 } 750 712 751 - clsdev = device_create(mei_class, parent, devno, 752 - NULL, "mei%d", dev->minor); 713 + clsdev = device_create_with_groups(mei_class, parent, devno, 714 + dev, mei_groups, 715 + "mei%d", dev->minor); 753 716 754 717 if (IS_ERR(clsdev)) { 755 718 dev_err(parent, "unable to create device %d:%d\n",