Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/dist/drm/i915 Avoid container_of-inspi...
details: https://anonhg.NetBSD.org/src/rev/64539053f50a
branches: trunk
changeset: 332355:64539053f50a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Sep 17 16:35:39 2014 +0000
description:
Avoid container_of-inspired &obj->base == NULL nonsense.
diffstat:
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c | 72 +++++++++++++++++--------
1 files changed, 48 insertions(+), 24 deletions(-)
diffs (279 lines):
diff -r 93f77574683c -r 64539053f50a sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Wed Sep 17 16:16:33 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Wed Sep 17 16:35:39 2014 +0000
@@ -809,6 +809,7 @@
struct drm_file *file)
{
struct drm_i915_gem_pread *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret = 0;
@@ -824,11 +825,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
/* Bounds check source. */
if (args->offset > obj->base.size ||
@@ -1201,6 +1203,7 @@
struct drm_file *file)
{
struct drm_i915_gem_pwrite *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -1225,11 +1228,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
/* Bounds check destination. */
if (args->offset > obj->base.size ||
@@ -1661,6 +1665,7 @@
struct drm_file *file)
{
struct drm_i915_gem_set_domain *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
uint32_t read_domains = args->read_domains;
uint32_t write_domain = args->write_domain;
@@ -1683,11 +1688,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
/* Try to flush the object off the GPU without holding the lock.
* We will repeat the flush holding the lock in the normal manner
@@ -1727,6 +1733,7 @@
struct drm_file *file)
{
struct drm_i915_gem_sw_finish *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret = 0;
@@ -1734,11 +1741,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
/* Pinned buffers may be scanout, so flush the cache */
if (obj->pin_display)
@@ -2266,6 +2274,7 @@
uint64_t *offset)
{
struct drm_i915_private *dev_priv = dev->dev_private;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -2273,11 +2282,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
if (obj->base.size > dev_priv->gtt.mappable_end) {
ret = -E2BIG;
@@ -3356,6 +3366,7 @@
{
struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_gem_wait *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
struct intel_ring_buffer *ring = NULL;
struct timespec timeout_stack, *timeout = NULL;
@@ -3372,11 +3383,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->bo_handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->bo_handle);
+ if (gobj == NULL) {
mutex_unlock(&dev->struct_mutex);
return -ENOENT;
}
+ obj = to_intel_bo(gobj);
/* Need to make sure the object gets inactive eventually. */
ret = i915_gem_object_flush_active(obj);
@@ -4319,6 +4331,7 @@
struct drm_file *file)
{
struct drm_i915_gem_caching *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -4326,11 +4339,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
switch (obj->cache_level) {
case I915_CACHE_LLC:
@@ -4357,6 +4371,7 @@
struct drm_file *file)
{
struct drm_i915_gem_caching *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
enum i915_cache_level level;
int ret;
@@ -4379,11 +4394,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
ret = i915_gem_object_set_cache_level(obj, level);
@@ -4689,6 +4705,7 @@
struct drm_file *file)
{
struct drm_i915_gem_pin *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -4699,11 +4716,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
if (obj->madv != I915_MADV_WILLNEED) {
DRM_DEBUG("Attempting to pin a purgeable buffer\n");
@@ -4745,6 +4763,7 @@
struct drm_file *file)
{
struct drm_i915_gem_pin *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -4752,11 +4771,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
if (obj->pin_filp != file) {
DRM_DEBUG("Not pinned by caller in i915_gem_pin_ioctl(): %d\n",
@@ -4782,6 +4802,7 @@
struct drm_file *file)
{
struct drm_i915_gem_busy *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -4789,11 +4810,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
/* Count all active objects as busy, even if they are currently not used
* by the gpu. Users of this interface expect objects to eventually
@@ -4826,6 +4848,7 @@
struct drm_file *file_priv)
{
struct drm_i915_gem_madvise *args = data;
+ struct drm_gem_object *gobj;
struct drm_i915_gem_object *obj;
int ret;
@@ -4841,11 +4864,12 @@
if (ret)
return ret;
- obj = to_intel_bo(drm_gem_object_lookup(dev, file_priv, args->handle));
- if (&obj->base == NULL) {
+ gobj = drm_gem_object_lookup(dev, file_priv, args->handle);
+ if (gobj == NULL) {
ret = -ENOENT;
goto unlock;
}
+ obj = to_intel_bo(gobj);
if (i915_gem_obj_is_pinned(obj)) {
ret = -EINVAL;
Home |
Main Index |
Thread Index |
Old Index