show()方法应返回打印到缓冲区中的字节数。 show()应仅在将要返回给用户空间的值进行格式化时使用sysfs_emit()或sysfs_emit_at()。 store()应返回从缓冲区使用的字节数。如果已使用整个缓冲区,只需返回计数参数。 show()或store()始终可以返回错误。如果出现错误值,请务必返回错误。 通过sysf
- show() should only use sysfs_emit() or sysfs_emit_at() when formatting 248+ the value to be returned to user space. 251249 252250 - store() should return the number of bytes used from the buffer. If the 253251 entire buffer has been used, just return the count argument. ...
#define pci_config_attr(field, format_string) \ static ssize_t \ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \ { \ struct pci_dev *pdev; \ \ pdev = to_pci_dev(dev); \ return sysfs_emit(buf, format_string, pdev->field); \ } \ static DEVICE_...
可通过sysfs接口创建驱动对应的属性,使得可以在用户空间通过sysfs接口的show和store函数与硬件交互; Syss...
return sysfs_emit(buf, "%llu\n", atomic64_read(&cma->nr_pages_failed)); } CMA_ATTR_RO(alloc_pages_fail);static void cma_kobj_release(struct kobject *kobj) { struct cma *cma = cma_from_kobj(kobj); struct cma_kobject *cma_kobj = cma->cma_kobj;...