Message ID | 60dcf3fb69ec74bd57026ae434bd06514d699044.1452696179.git.geliangtang@163.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jan 13, 2016 at 10:48:39PM +0800, Geliang Tang wrote: > Use hlist_for_each_entry() instead of hlist_for_each() to simplify > the code. > > Signed-off-by: Geliang Tang <geliangtang@163.com> > --- > drivers/gpu/drm/i915/i915_gem_execbuffer.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c > index 5d01ea6..8f194be 100644 > --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c > +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c > @@ -192,14 +192,10 @@ static struct i915_vma *eb_get_vma(struct eb_vmas *eb, unsigned long handle) > return NULL; > return eb->lut[handle]; > } else { > - struct hlist_head *head; > - struct hlist_node *node; > - > - head = &eb->buckets[handle & eb->and]; > - hlist_for_each(node, head) { > - struct i915_vma *vma; > + struct i915_vma *vma; > > - vma = hlist_entry(node, struct i915_vma, exec_node); > + hlist_for_each_entry(vma, &eb->buckets[handle & eb->and], > + exec_node) { Keep the head = &eb->buckets[handle & eb->and]; local assignment as it makes the line splitting neater (and iirc something like gcc -Os doesn't use the temporary assignment - but then who would use CONFIG_OPTIMIZE_FOR_SIZE!). -Chris
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 5d01ea6..8f194be 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -192,14 +192,10 @@ static struct i915_vma *eb_get_vma(struct eb_vmas *eb, unsigned long handle) return NULL; return eb->lut[handle]; } else { - struct hlist_head *head; - struct hlist_node *node; - - head = &eb->buckets[handle & eb->and]; - hlist_for_each(node, head) { - struct i915_vma *vma; + struct i915_vma *vma; - vma = hlist_entry(node, struct i915_vma, exec_node); + hlist_for_each_entry(vma, &eb->buckets[handle & eb->and], + exec_node) { if (vma->exec_handle == handle) return vma; }
Use hlist_for_each_entry() instead of hlist_for_each() to simplify the code. Signed-off-by: Geliang Tang <geliangtang@163.com> --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)