You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
drm/amdgpu: optimize amdgpu device attribute code
unified amdgpu device attribute node functions: 1. add some helper functions to create amdgpu device attribute node. 2. create device node according to device attr flags on different VF mode. 3. rename some functions name to adapt a new interface. v2: 1. remove ATTR_STATE_DEAD, ATTR_STATE_ALIVE enum. 2. rename callback function perform to attr_update. 3. modify some variable names Signed-off-by: Kevin Wang <kevin1.wang@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,52 @@ struct cg_flag_name
|
||||
const char *name;
|
||||
};
|
||||
|
||||
enum amdgpu_device_attr_flags {
|
||||
ATTR_FLAG_BASIC = (1 << 0),
|
||||
ATTR_FLAG_ONEVF = (1 << 16),
|
||||
};
|
||||
|
||||
#define ATTR_FLAG_TYPE_MASK (0x0000ffff)
|
||||
#define ATTR_FLAG_MODE_MASK (0xffff0000)
|
||||
#define ATTR_FLAG_MASK_ALL (0xffffffff)
|
||||
|
||||
enum amdgpu_device_attr_states {
|
||||
ATTR_STATE_UNSUPPORTED = 0,
|
||||
ATTR_STATE_SUPPORTED,
|
||||
};
|
||||
|
||||
struct amdgpu_device_attr {
|
||||
struct device_attribute dev_attr;
|
||||
enum amdgpu_device_attr_flags flags;
|
||||
enum amdgpu_device_attr_states states;
|
||||
int (*attr_update)(struct amdgpu_device *adev,
|
||||
struct amdgpu_device_attr* attr,
|
||||
uint32_t mask);
|
||||
};
|
||||
|
||||
#define to_amdgpu_device_attr(_dev_attr) \
|
||||
container_of(_dev_attr, struct amdgpu_device_attr, dev_attr)
|
||||
|
||||
#define __AMDGPU_DEVICE_ATTR(_name, _mode, _show, _store, _flags, ...) \
|
||||
{ .dev_attr = __ATTR(_name, _mode, _show, _store), \
|
||||
.flags = _flags, \
|
||||
.states = ATTR_STATE_SUPPORTED, \
|
||||
##__VA_ARGS__, }
|
||||
|
||||
#define AMDGPU_DEVICE_ATTR(_name, _mode, _flags, ...) \
|
||||
__AMDGPU_DEVICE_ATTR(_name, _mode, \
|
||||
amdgpu_get_##_name, amdgpu_set_##_name, \
|
||||
_flags, ##__VA_ARGS__)
|
||||
|
||||
#define AMDGPU_DEVICE_ATTR_RW(_name, _flags, ...) \
|
||||
AMDGPU_DEVICE_ATTR(_name, S_IRUGO | S_IWUSR, \
|
||||
_flags, ##__VA_ARGS__)
|
||||
|
||||
#define AMDGPU_DEVICE_ATTR_RO(_name, _flags, ...) \
|
||||
__AMDGPU_DEVICE_ATTR(_name, S_IRUGO, \
|
||||
amdgpu_get_##_name, NULL, \
|
||||
_flags, ##__VA_ARGS__)
|
||||
|
||||
void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev);
|
||||
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev);
|
||||
int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);
|
||||
|
||||
Reference in New Issue
Block a user