|
6 | 6 |
|
7 | 7 | #include "core.h"
|
8 | 8 |
|
| 9 | +static ssize_t offset_show(struct device *dev, struct device_attribute *attr, |
| 10 | + char *buf) |
| 11 | +{ |
| 12 | + struct region_extent *region_extent = to_region_extent(dev); |
| 13 | + |
| 14 | + return sysfs_emit(buf, "%#llx\n", region_extent->hpa_range.start); |
| 15 | +} |
| 16 | +static DEVICE_ATTR_RO(offset); |
| 17 | + |
| 18 | +static ssize_t length_show(struct device *dev, struct device_attribute *attr, |
| 19 | + char *buf) |
| 20 | +{ |
| 21 | + struct region_extent *region_extent = to_region_extent(dev); |
| 22 | + u64 length = range_len(®ion_extent->hpa_range); |
| 23 | + |
| 24 | + return sysfs_emit(buf, "%#llx\n", length); |
| 25 | +} |
| 26 | +static DEVICE_ATTR_RO(length); |
| 27 | + |
| 28 | +static ssize_t uuid_show(struct device *dev, struct device_attribute *attr, |
| 29 | + char *buf) |
| 30 | +{ |
| 31 | + struct region_extent *region_extent = to_region_extent(dev); |
| 32 | + |
| 33 | + return sysfs_emit(buf, "%pUb\n", ®ion_extent->uuid); |
| 34 | +} |
| 35 | +static DEVICE_ATTR_RO(uuid); |
| 36 | + |
| 37 | +static struct attribute *region_extent_attrs[] = { |
| 38 | + &dev_attr_offset.attr, |
| 39 | + &dev_attr_length.attr, |
| 40 | + &dev_attr_uuid.attr, |
| 41 | + NULL |
| 42 | +}; |
| 43 | + |
| 44 | +static uuid_t empty_uuid = { 0 }; |
| 45 | + |
| 46 | +static umode_t region_extent_visible(struct kobject *kobj, |
| 47 | + struct attribute *a, int n) |
| 48 | +{ |
| 49 | + struct device *dev = kobj_to_dev(kobj); |
| 50 | + struct region_extent *region_extent = to_region_extent(dev); |
| 51 | + |
| 52 | + if (a == &dev_attr_uuid.attr && |
| 53 | + uuid_equal(®ion_extent->uuid, &empty_uuid)) |
| 54 | + return 0; |
| 55 | + |
| 56 | + return a->mode; |
| 57 | +} |
| 58 | + |
| 59 | +static const struct attribute_group region_extent_attribute_group = { |
| 60 | + .attrs = region_extent_attrs, |
| 61 | + .is_visible = region_extent_visible, |
| 62 | +}; |
| 63 | + |
| 64 | +__ATTRIBUTE_GROUPS(region_extent_attribute); |
| 65 | + |
9 | 66 | static void cxled_release_extent(struct cxl_endpoint_decoder *cxled,
|
10 | 67 | struct cxled_extent *ed_extent)
|
11 | 68 | {
|
@@ -44,6 +101,7 @@ static void region_extent_release(struct device *dev)
|
44 | 101 | static const struct device_type region_extent_type = {
|
45 | 102 | .name = "extent",
|
46 | 103 | .release = region_extent_release,
|
| 104 | + .groups = region_extent_attribute_groups, |
47 | 105 | };
|
48 | 106 |
|
49 | 107 | bool is_region_extent(struct device *dev)
|
|
0 commit comments