diff options
author | David Weinehall <david.weinehall@linux.intel.com> | 2016-08-22 06:32:42 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-08-22 07:19:52 -0400 |
commit | c49d13ee13f709852cc05f9035df89e9ffa26108 (patch) | |
tree | 9a3e37a5bad0e2beab2031ff5389f46253790d82 /drivers/gpu/drm/i915/i915_sysfs.c | |
parent | 351c3b53e767b2512461843882f7c6baa8996c4b (diff) |
drm/i915: consistent struct device naming
We currently have a mix of struct device *device, struct device *kdev,
and struct device *dev (the latter forcing us to refer to
struct drm_device as something else than the normal dev).
To simplify things, always use kdev when referring to struct device.
v2: Replace the dev_to_drm_minor() macro with the inline function
kdev_to_drm_minor().
Signed-off-by: David Weinehall <david.weinehall@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20160822103245.24069-3-david.weinehall@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_sysfs.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_sysfs.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index f1ffde7f7c0b..05cb95bf2f4b 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c | |||
@@ -32,7 +32,10 @@ | |||
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) dev_get_drvdata((d)) | 35 | static inline struct drm_minor *kdev_to_drm_minor(struct device *kdev) |
36 | { | ||
37 | return dev_get_drvdata(kdev); | ||
38 | } | ||
36 | 39 | ||
37 | #ifdef CONFIG_PM | 40 | #ifdef CONFIG_PM |
38 | static u32 calc_residency(struct drm_device *dev, | 41 | static u32 calc_residency(struct drm_device *dev, |
@@ -84,7 +87,7 @@ show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) | |||
84 | static ssize_t | 87 | static ssize_t |
85 | show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 88 | show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
86 | { | 89 | { |
87 | struct drm_minor *dminor = dev_to_drm_minor(kdev); | 90 | struct drm_minor *dminor = kdev_to_drm_minor(kdev); |
88 | u32 rc6p_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6p); | 91 | u32 rc6p_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6p); |
89 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6p_residency); | 92 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6p_residency); |
90 | } | 93 | } |
@@ -92,7 +95,7 @@ show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) | |||
92 | static ssize_t | 95 | static ssize_t |
93 | show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf) | 96 | show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf) |
94 | { | 97 | { |
95 | struct drm_minor *dminor = dev_to_drm_minor(kdev); | 98 | struct drm_minor *dminor = kdev_to_drm_minor(kdev); |
96 | u32 rc6pp_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6pp); | 99 | u32 rc6pp_residency = calc_residency(dminor->dev, GEN6_GT_GFX_RC6pp); |
97 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6pp_residency); | 100 | return snprintf(buf, PAGE_SIZE, "%u\n", rc6pp_residency); |
98 | } | 101 | } |
@@ -163,22 +166,22 @@ i915_l3_read(struct file *filp, struct kobject *kobj, | |||
163 | struct bin_attribute *attr, char *buf, | 166 | struct bin_attribute *attr, char *buf, |
164 | loff_t offset, size_t count) | 167 | loff_t offset, size_t count) |
165 | { | 168 | { |
166 | struct device *dev = kobj_to_dev(kobj); | 169 | struct device *kdev = kobj_to_dev(kobj); |
167 | struct drm_minor *dminor = dev_to_drm_minor(dev); | 170 | struct drm_minor *dminor = kdev_to_drm_minor(kdev); |
168 | struct drm_device *drm_dev = dminor->dev; | 171 | struct drm_device *dev = dminor->dev; |
169 | struct drm_i915_private *dev_priv = to_i915(drm_dev); | 172 | struct drm_i915_private *dev_priv = to_i915(dev); |
170 | int slice = (int)(uintptr_t)attr->private; | 173 | int slice = (int)(uintptr_t)attr->private; |
171 | int ret; | 174 | int ret; |
172 | 175 | ||
173 | count = round_down(count, 4); | 176 | count = round_down(count, 4); |
174 | 177 | ||
175 | ret = l3_access_valid(drm_dev, offset); | 178 | ret = l3_access_valid(dev, offset); |
176 | if (ret) | 179 | if (ret) |
177 | return ret; | 180 | return ret; |
178 | 181 | ||
179 | count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count); | 182 | count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count); |
180 | 183 | ||
181 | ret = i915_mutex_lock_interruptible(drm_dev); | 184 | ret = i915_mutex_lock_interruptible(dev); |
182 | if (ret) | 185 | if (ret) |
183 | return ret; | 186 | return ret; |
184 | 187 | ||
@@ -189,7 +192,7 @@ i915_l3_read(struct file *filp, struct kobject *kobj, | |||
189 | else | 192 | else |
190 | memset(buf, 0, count); | 193 | memset(buf, 0, count); |
191 | 194 | ||
192 | mutex_unlock(&drm_dev->struct_mutex); | 195 | mutex_unlock(&dev->struct_mutex); |
193 | 196 | ||
194 | return count; | 197 | return count; |
195 | } | 198 | } |
@@ -199,30 +202,30 @@ i915_l3_write(struct file *filp, struct kobject *kobj, | |||
199 | struct bin_attribute *attr, char *buf, | 202 | struct bin_attribute *attr, char *buf, |
200 | loff_t offset, size_t count) | 203 | loff_t offset, size_t count) |
201 | { | 204 | { |
202 | struct device *dev = kobj_to_dev(kobj); | 205 | struct device *kdev = kobj_to_dev(kobj); |
203 | struct drm_minor *dminor = dev_to_drm_minor(dev); | 206 | struct drm_minor *dminor = kdev_to_drm_minor(kdev); |
204 | struct drm_device *drm_dev = dminor->dev; | 207 | struct drm_device *dev = dminor->dev; |
205 | struct drm_i915_private *dev_priv = to_i915(drm_dev); | 208 | struct drm_i915_private *dev_priv = to_i915(dev); |
206 | struct i915_gem_context *ctx; | 209 | struct i915_gem_context *ctx; |
207 | u32 *temp = NULL; /* Just here to make handling failures easy */ | 210 | u32 *temp = NULL; /* Just here to make handling failures easy */ |
208 | int slice = (int)(uintptr_t)attr->private; | 211 | int slice = (int)(uintptr_t)attr->private; |
209 | int ret; | 212 | int ret; |
210 | 213 | ||
211 | if (!HAS_HW_CONTEXTS(drm_dev)) | 214 | if (!HAS_HW_CONTEXTS(dev)) |
212 | return -ENXIO; | 215 | return -ENXIO; |
213 | 216 | ||
214 | ret = l3_access_valid(drm_dev, offset); | 217 | ret = l3_access_valid(dev, offset); |
215 | if (ret) | 218 | if (ret) |
216 | return ret; | 219 | return ret; |
217 | 220 | ||
218 | ret = i915_mutex_lock_interruptible(drm_dev); | 221 | ret = i915_mutex_lock_interruptible(dev); |
219 | if (ret) | 222 | if (ret) |
220 | return ret; | 223 | return ret; |
221 | 224 | ||
222 | if (!dev_priv->l3_parity.remap_info[slice]) { | 225 | if (!dev_priv->l3_parity.remap_info[slice]) { |
223 | temp = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL); | 226 | temp = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL); |
224 | if (!temp) { | 227 | if (!temp) { |
225 | mutex_unlock(&drm_dev->struct_mutex); | 228 | mutex_unlock(&dev->struct_mutex); |
226 | return -ENOMEM; | 229 | return -ENOMEM; |
227 | } | 230 | } |
228 | } | 231 | } |
@@ -240,7 +243,7 @@ i915_l3_write(struct file *filp, struct kobject *kobj, | |||
240 | list_for_each_entry(ctx, &dev_priv->context_list, link) | 243 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
241 | ctx->remap_slice |= (1<<slice); | 244 | ctx->remap_slice |= (1<<slice); |
242 | 245 | ||
243 | mutex_unlock(&drm_dev->struct_mutex); | 246 | mutex_unlock(&dev->struct_mutex); |
244 | 247 | ||
245 | return count; | 248 | return count; |
246 | } | 249 | } |
@@ -266,7 +269,7 @@ static struct bin_attribute dpf_attrs_1 = { | |||
266 | static ssize_t gt_act_freq_mhz_show(struct device *kdev, | 269 | static ssize_t gt_act_freq_mhz_show(struct device *kdev, |
267 | struct device_attribute *attr, char *buf) | 270 | struct device_attribute *attr, char *buf) |
268 | { | 271 | { |
269 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 272 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
270 | struct drm_device *dev = minor->dev; | 273 | struct drm_device *dev = minor->dev; |
271 | struct drm_i915_private *dev_priv = to_i915(dev); | 274 | struct drm_i915_private *dev_priv = to_i915(dev); |
272 | int ret; | 275 | int ret; |
@@ -298,7 +301,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev, | |||
298 | static ssize_t gt_cur_freq_mhz_show(struct device *kdev, | 301 | static ssize_t gt_cur_freq_mhz_show(struct device *kdev, |
299 | struct device_attribute *attr, char *buf) | 302 | struct device_attribute *attr, char *buf) |
300 | { | 303 | { |
301 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 304 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
302 | struct drm_device *dev = minor->dev; | 305 | struct drm_device *dev = minor->dev; |
303 | struct drm_i915_private *dev_priv = to_i915(dev); | 306 | struct drm_i915_private *dev_priv = to_i915(dev); |
304 | 307 | ||
@@ -309,7 +312,7 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev, | |||
309 | 312 | ||
310 | static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 313 | static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
311 | { | 314 | { |
312 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 315 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
313 | struct drm_i915_private *dev_priv = to_i915(minor->dev); | 316 | struct drm_i915_private *dev_priv = to_i915(minor->dev); |
314 | 317 | ||
315 | return snprintf(buf, PAGE_SIZE, "%d\n", | 318 | return snprintf(buf, PAGE_SIZE, "%d\n", |
@@ -321,7 +324,7 @@ static ssize_t gt_boost_freq_mhz_store(struct device *kdev, | |||
321 | struct device_attribute *attr, | 324 | struct device_attribute *attr, |
322 | const char *buf, size_t count) | 325 | const char *buf, size_t count) |
323 | { | 326 | { |
324 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 327 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
325 | struct drm_device *dev = minor->dev; | 328 | struct drm_device *dev = minor->dev; |
326 | struct drm_i915_private *dev_priv = to_i915(dev); | 329 | struct drm_i915_private *dev_priv = to_i915(dev); |
327 | u32 val; | 330 | u32 val; |
@@ -346,7 +349,7 @@ static ssize_t gt_boost_freq_mhz_store(struct device *kdev, | |||
346 | static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, | 349 | static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, |
347 | struct device_attribute *attr, char *buf) | 350 | struct device_attribute *attr, char *buf) |
348 | { | 351 | { |
349 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 352 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
350 | struct drm_device *dev = minor->dev; | 353 | struct drm_device *dev = minor->dev; |
351 | struct drm_i915_private *dev_priv = to_i915(dev); | 354 | struct drm_i915_private *dev_priv = to_i915(dev); |
352 | 355 | ||
@@ -357,7 +360,7 @@ static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, | |||
357 | 360 | ||
358 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 361 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
359 | { | 362 | { |
360 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 363 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
361 | struct drm_device *dev = minor->dev; | 364 | struct drm_device *dev = minor->dev; |
362 | struct drm_i915_private *dev_priv = to_i915(dev); | 365 | struct drm_i915_private *dev_priv = to_i915(dev); |
363 | 366 | ||
@@ -370,7 +373,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
370 | struct device_attribute *attr, | 373 | struct device_attribute *attr, |
371 | const char *buf, size_t count) | 374 | const char *buf, size_t count) |
372 | { | 375 | { |
373 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 376 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
374 | struct drm_device *dev = minor->dev; | 377 | struct drm_device *dev = minor->dev; |
375 | struct drm_i915_private *dev_priv = to_i915(dev); | 378 | struct drm_i915_private *dev_priv = to_i915(dev); |
376 | u32 val; | 379 | u32 val; |
@@ -418,7 +421,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
418 | 421 | ||
419 | static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 422 | static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
420 | { | 423 | { |
421 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 424 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
422 | struct drm_device *dev = minor->dev; | 425 | struct drm_device *dev = minor->dev; |
423 | struct drm_i915_private *dev_priv = to_i915(dev); | 426 | struct drm_i915_private *dev_priv = to_i915(dev); |
424 | 427 | ||
@@ -431,7 +434,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, | |||
431 | struct device_attribute *attr, | 434 | struct device_attribute *attr, |
432 | const char *buf, size_t count) | 435 | const char *buf, size_t count) |
433 | { | 436 | { |
434 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 437 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
435 | struct drm_device *dev = minor->dev; | 438 | struct drm_device *dev = minor->dev; |
436 | struct drm_i915_private *dev_priv = to_i915(dev); | 439 | struct drm_i915_private *dev_priv = to_i915(dev); |
437 | u32 val; | 440 | u32 val; |
@@ -490,7 +493,7 @@ static DEVICE_ATTR(gt_RPn_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL); | |||
490 | /* For now we have a static number of RP states */ | 493 | /* For now we have a static number of RP states */ |
491 | static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 494 | static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
492 | { | 495 | { |
493 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 496 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
494 | struct drm_device *dev = minor->dev; | 497 | struct drm_device *dev = minor->dev; |
495 | struct drm_i915_private *dev_priv = to_i915(dev); | 498 | struct drm_i915_private *dev_priv = to_i915(dev); |
496 | u32 val; | 499 | u32 val; |
@@ -538,7 +541,7 @@ static ssize_t error_state_read(struct file *filp, struct kobject *kobj, | |||
538 | { | 541 | { |
539 | 542 | ||
540 | struct device *kdev = kobj_to_dev(kobj); | 543 | struct device *kdev = kobj_to_dev(kobj); |
541 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 544 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
542 | struct drm_device *dev = minor->dev; | 545 | struct drm_device *dev = minor->dev; |
543 | struct i915_error_state_file_priv error_priv; | 546 | struct i915_error_state_file_priv error_priv; |
544 | struct drm_i915_error_state_buf error_str; | 547 | struct drm_i915_error_state_buf error_str; |
@@ -573,7 +576,7 @@ static ssize_t error_state_write(struct file *file, struct kobject *kobj, | |||
573 | loff_t off, size_t count) | 576 | loff_t off, size_t count) |
574 | { | 577 | { |
575 | struct device *kdev = kobj_to_dev(kobj); | 578 | struct device *kdev = kobj_to_dev(kobj); |
576 | struct drm_minor *minor = dev_to_drm_minor(kdev); | 579 | struct drm_minor *minor = kdev_to_drm_minor(kdev); |
577 | struct drm_device *dev = minor->dev; | 580 | struct drm_device *dev = minor->dev; |
578 | int ret; | 581 | int ret; |
579 | 582 | ||