LinuxKPI: Implement default sysfs kobject attribute operations
Required by drm-kmod 5.7 MFC after: 1 week Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D33292
This commit is contained in:
parent
c427456fd5
commit
04d42cb453
@ -68,6 +68,8 @@ struct attribute {
|
||||
mode_t mode;
|
||||
};
|
||||
|
||||
extern const struct sysfs_ops kobj_sysfs_ops;
|
||||
|
||||
struct kobj_attribute {
|
||||
struct attribute attr;
|
||||
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
|
@ -282,6 +282,36 @@ const struct kobj_type linux_kfree_type = {
|
||||
.release = linux_kobject_kfree
|
||||
};
|
||||
|
||||
static ssize_t
|
||||
lkpi_kobj_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
||||
{
|
||||
struct kobj_attribute *ka =
|
||||
container_of(attr, struct kobj_attribute, attr);
|
||||
|
||||
if (ka->show == NULL)
|
||||
return (-EIO);
|
||||
|
||||
return (ka->show(kobj, ka, buf));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
lkpi_kobj_attr_store(struct kobject *kobj, struct attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct kobj_attribute *ka =
|
||||
container_of(attr, struct kobj_attribute, attr);
|
||||
|
||||
if (ka->store == NULL)
|
||||
return (-EIO);
|
||||
|
||||
return (ka->store(kobj, ka, buf, count));
|
||||
}
|
||||
|
||||
const struct sysfs_ops kobj_sysfs_ops = {
|
||||
.show = lkpi_kobj_attr_show,
|
||||
.store = lkpi_kobj_attr_store,
|
||||
};
|
||||
|
||||
static void
|
||||
linux_device_release(struct device *dev)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user