diff options
Diffstat (limited to 'drivers/gpu/drm/drm_mode_object.c')
-rw-r--r-- | drivers/gpu/drm/drm_mode_object.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index 6edda8382a4c..9f17085b1fdd 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c | |||
@@ -372,14 +372,25 @@ out: | |||
372 | return ret; | 372 | return ret; |
373 | } | 373 | } |
374 | 374 | ||
375 | struct drm_property *drm_mode_obj_find_prop_id(struct drm_mode_object *obj, | ||
376 | uint32_t prop_id) | ||
377 | { | ||
378 | int i; | ||
379 | |||
380 | for (i = 0; i < obj->properties->count; i++) | ||
381 | if (obj->properties->properties[i]->base.id == prop_id) | ||
382 | return obj->properties->properties[i]; | ||
383 | |||
384 | return NULL; | ||
385 | } | ||
386 | |||
375 | int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, | 387 | int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, |
376 | struct drm_file *file_priv) | 388 | struct drm_file *file_priv) |
377 | { | 389 | { |
378 | struct drm_mode_obj_set_property *arg = data; | 390 | struct drm_mode_obj_set_property *arg = data; |
379 | struct drm_mode_object *arg_obj; | 391 | struct drm_mode_object *arg_obj; |
380 | struct drm_mode_object *prop_obj; | ||
381 | struct drm_property *property; | 392 | struct drm_property *property; |
382 | int i, ret = -EINVAL; | 393 | int ret = -EINVAL; |
383 | struct drm_mode_object *ref; | 394 | struct drm_mode_object *ref; |
384 | 395 | ||
385 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 396 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
@@ -392,23 +403,13 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, | |||
392 | ret = -ENOENT; | 403 | ret = -ENOENT; |
393 | goto out; | 404 | goto out; |
394 | } | 405 | } |
395 | if (!arg_obj->properties) | ||
396 | goto out_unref; | ||
397 | |||
398 | for (i = 0; i < arg_obj->properties->count; i++) | ||
399 | if (arg_obj->properties->properties[i]->base.id == arg->prop_id) | ||
400 | break; | ||
401 | 406 | ||
402 | if (i == arg_obj->properties->count) | 407 | if (!arg_obj->properties) |
403 | goto out_unref; | 408 | goto out_unref; |
404 | 409 | ||
405 | prop_obj = drm_mode_object_find(dev, arg->prop_id, | 410 | property = drm_mode_obj_find_prop_id(arg_obj, arg->prop_id); |
406 | DRM_MODE_OBJECT_PROPERTY); | 411 | if (!property) |
407 | if (!prop_obj) { | ||
408 | ret = -ENOENT; | ||
409 | goto out_unref; | 412 | goto out_unref; |
410 | } | ||
411 | property = obj_to_property(prop_obj); | ||
412 | 413 | ||
413 | if (!drm_property_change_valid_get(property, arg->value, &ref)) | 414 | if (!drm_property_change_valid_get(property, arg->value, &ref)) |
414 | goto out_unref; | 415 | goto out_unref; |