diff options
author | Dave Airlie <airlied@redhat.com> | 2013-10-11 00:45:30 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-10-15 04:06:06 -0400 |
commit | 14c8d110e083d3a09ccf8cfe18ad22fe1450c2e9 (patch) | |
tree | 803f22a1bac1ca6af8f30dc9aa04feb4975321da /drivers/gpu/drm/i915/i915_sysfs.c | |
parent | 5259c522a0b2e827b402c2993b8088071a87d7e2 (diff) |
drm/i915: abstract the conversion of device->minor out to a macro
This will make the next patch to change how this works a lot cleaner.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_sysfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_sysfs.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 8003886361b8..3ae47951c1bd 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include "intel_drv.h" | 32 | #include "intel_drv.h" |
33 | #include "i915_drv.h" | 33 | #include "i915_drv.h" |
34 | 34 | ||
35 | #define dev_to_drm_minor(d) container_of((d), struct drm_minor, kdev) | ||
36 | |||
35 | #ifdef CONFIG_PM | 37 | #ifdef CONFIG_PM |
36 | static u32 calc_residency(struct drm_device *dev, const u32 reg) | 38 | static u32 calc_residency(struct drm_device *dev, const u32 reg) |
37 | { | 39 | { |
@@ -66,14 +68,14 @@ static u32 calc_residency(struct drm_device *dev, const u32 reg) | |||
66 | static ssize_t | 68 | static ssize_t |
67 | show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf) | 69 | show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf) |
68 | { | 70 | { |
69 | struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev); | 71 | struct drm_minor *dminor = dev_to_drm_minor(kdev); |
70 | return snprintf(buf, PAGE_SIZE, "%x\n", intel_enable_rc6(dminor->dev)); | 72 | return snprintf(buf, PAGE_SIZE, "%x\n", intel_enable_rc6(dminor->dev)); |
71 | } | 73 | } |
72 | 74 | ||
73 | static ssize_t | 75 | static ssize_t |
74 | show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 76 | show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
75 | { | 77 | { |
76 | struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev); | 78 | struct drm_minor *dminor = dev_to_drm_minor(kdev); |
77 | u32 rc6_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6); | 79 | u32 rc6_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6); |
78 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); | 80 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); |
79 | } | 81 | } |
@@ -81,7 +83,7 @@ show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) | |||
81 | static ssize_t | 83 | static ssize_t |
82 | show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 84 | show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
83 | { | 85 | { |
84 | struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev); | 86 | struct drm_minor *dminor = dev_to_drm_minor(kdev); |
85 | u32 rc6p_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6p); | 87 | u32 rc6p_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6p); |
86 | if (IS_VALLEYVIEW(dminor->dev)) | 88 | if (IS_VALLEYVIEW(dminor->dev)) |
87 | rc6p_residency = 0; | 89 | rc6p_residency = 0; |
@@ -91,7 +93,7 @@ show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) | |||
91 | static ssize_t | 93 | static ssize_t |
92 | show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 94 | show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
93 | { | 95 | { |
94 | struct drm_minor *dminor = container_of(kdev, struct drm_minor, kdev); | 96 | struct drm_minor *dminor = dev_to_drm_minor(kdev); |
95 | u32 rc6pp_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6pp); | 97 | u32 rc6pp_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6pp); |
96 | if (IS_VALLEYVIEW(dminor->dev)) | 98 | if (IS_VALLEYVIEW(dminor->dev)) |
97 | rc6pp_residency = 0; | 99 | rc6pp_residency = 0; |
@@ -137,7 +139,7 @@ i915_l3_read(struct file *filp, struct kobject *kobj, | |||
137 | loff_t offset, size_t count) | 139 | loff_t offset, size_t count) |
138 | { | 140 | { |
139 | struct device *dev = container_of(kobj, struct device, kobj); | 141 | struct device *dev = container_of(kobj, struct device, kobj); |
140 | struct drm_minor *dminor = container_of(dev, struct drm_minor, kdev); | 142 | struct drm_minor *dminor = dev_to_drm_minor(dev); |
141 | struct drm_device *drm_dev = dminor->dev; | 143 | struct drm_device *drm_dev = dminor->dev; |
142 | struct drm_i915_private *dev_priv = drm_dev->dev_private; | 144 | struct drm_i915_private *dev_priv = drm_dev->dev_private; |
143 | int slice = (int)(uintptr_t)attr->private; | 145 | int slice = (int)(uintptr_t)attr->private; |
@@ -173,7 +175,7 @@ i915_l3_write(struct file *filp, struct kobject *kobj, | |||
173 | loff_t offset, size_t count) | 175 | loff_t offset, size_t count) |
174 | { | 176 | { |
175 | struct device *dev = container_of(kobj, struct device, kobj); | 177 | struct device *dev = container_of(kobj, struct device, kobj); |
176 | struct drm_minor *dminor = container_of(dev, struct drm_minor, kdev); | 178 | struct drm_minor *dminor = dev_to_drm_minor(dev); |
177 | struct drm_device *drm_dev = dminor->dev; | 179 | struct drm_device *drm_dev = dminor->dev; |
178 | struct drm_i915_private *dev_priv = drm_dev->dev_private; | 180 | struct drm_i915_private *dev_priv = drm_dev->dev_private; |
179 | struct i915_hw_context *ctx; | 181 | struct i915_hw_context *ctx; |
@@ -246,7 +248,7 @@ static struct bin_attribute dpf_attrs_1 = { | |||
246 | static ssize_t gt_cur_freq_mhz_show(struct device *kdev, | 248 | static ssize_t gt_cur_freq_mhz_show(struct device *kdev, |
247 | struct device_attribute *attr, char *buf) | 249 | struct device_attribute *attr, char *buf) |
248 | { | 250 | { |
249 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 251 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
250 | struct drm_device *dev = minor->dev; | 252 | struct drm_device *dev = minor->dev; |
251 | struct drm_i915_private *dev_priv = dev->dev_private; | 253 | struct drm_i915_private *dev_priv = dev->dev_private; |
252 | int ret; | 254 | int ret; |
@@ -267,7 +269,7 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev, | |||
267 | static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, | 269 | static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, |
268 | struct device_attribute *attr, char *buf) | 270 | struct device_attribute *attr, char *buf) |
269 | { | 271 | { |
270 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 272 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
271 | struct drm_device *dev = minor->dev; | 273 | struct drm_device *dev = minor->dev; |
272 | struct drm_i915_private *dev_priv = dev->dev_private; | 274 | struct drm_i915_private *dev_priv = dev->dev_private; |
273 | 275 | ||
@@ -278,7 +280,7 @@ static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, | |||
278 | 280 | ||
279 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 281 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
280 | { | 282 | { |
281 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 283 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
282 | struct drm_device *dev = minor->dev; | 284 | struct drm_device *dev = minor->dev; |
283 | struct drm_i915_private *dev_priv = dev->dev_private; | 285 | struct drm_i915_private *dev_priv = dev->dev_private; |
284 | int ret; | 286 | int ret; |
@@ -297,7 +299,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
297 | struct device_attribute *attr, | 299 | struct device_attribute *attr, |
298 | const char *buf, size_t count) | 300 | const char *buf, size_t count) |
299 | { | 301 | { |
300 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 302 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
301 | struct drm_device *dev = minor->dev; | 303 | struct drm_device *dev = minor->dev; |
302 | struct drm_i915_private *dev_priv = dev->dev_private; | 304 | struct drm_i915_private *dev_priv = dev->dev_private; |
303 | u32 val, rp_state_cap, hw_max, hw_min, non_oc_max; | 305 | u32 val, rp_state_cap, hw_max, hw_min, non_oc_max; |
@@ -350,7 +352,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
350 | 352 | ||
351 | static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 353 | static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
352 | { | 354 | { |
353 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 355 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
354 | struct drm_device *dev = minor->dev; | 356 | struct drm_device *dev = minor->dev; |
355 | struct drm_i915_private *dev_priv = dev->dev_private; | 357 | struct drm_i915_private *dev_priv = dev->dev_private; |
356 | int ret; | 358 | int ret; |
@@ -369,7 +371,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, | |||
369 | struct device_attribute *attr, | 371 | struct device_attribute *attr, |
370 | const char *buf, size_t count) | 372 | const char *buf, size_t count) |
371 | { | 373 | { |
372 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 374 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
373 | struct drm_device *dev = minor->dev; | 375 | struct drm_device *dev = minor->dev; |
374 | struct drm_i915_private *dev_priv = dev->dev_private; | 376 | struct drm_i915_private *dev_priv = dev->dev_private; |
375 | u32 val, rp_state_cap, hw_max, hw_min; | 377 | u32 val, rp_state_cap, hw_max, hw_min; |
@@ -428,7 +430,7 @@ static DEVICE_ATTR(gt_RPn_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL); | |||
428 | /* For now we have a static number of RP states */ | 430 | /* For now we have a static number of RP states */ |
429 | static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 431 | static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
430 | { | 432 | { |
431 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 433 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
432 | struct drm_device *dev = minor->dev; | 434 | struct drm_device *dev = minor->dev; |
433 | struct drm_i915_private *dev_priv = dev->dev_private; | 435 | struct drm_i915_private *dev_priv = dev->dev_private; |
434 | u32 val, rp_state_cap; | 436 | u32 val, rp_state_cap; |
@@ -476,7 +478,7 @@ static ssize_t error_state_read(struct file *filp, struct kobject *kobj, | |||
476 | { | 478 | { |
477 | 479 | ||
478 | struct device *kdev = container_of(kobj, struct device, kobj); | 480 | struct device *kdev = container_of(kobj, struct device, kobj); |
479 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 481 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
480 | struct drm_device *dev = minor->dev; | 482 | struct drm_device *dev = minor->dev; |
481 | struct i915_error_state_file_priv error_priv; | 483 | struct i915_error_state_file_priv error_priv; |
482 | struct drm_i915_error_state_buf error_str; | 484 | struct drm_i915_error_state_buf error_str; |
@@ -511,7 +513,7 @@ static ssize_t error_state_write(struct file *file, struct kobject *kobj, | |||
511 | loff_t off, size_t count) | 513 | loff_t off, size_t count) |
512 | { | 514 | { |
513 | struct device *kdev = container_of(kobj, struct device, kobj); | 515 | struct device *kdev = container_of(kobj, struct device, kobj); |
514 | struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev); | 516 | struct drm_minor *minor = dev_to_drm_minor(kdev); |
515 | struct drm_device *dev = minor->dev; | 517 | struct drm_device *dev = minor->dev; |
516 | int ret; | 518 | int ret; |
517 | 519 | ||