diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2012-05-15 17:09:04 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-05-17 06:11:38 -0400 |
commit | 7f88a9bedfb814a2d4d537db8295c524298256cb (patch) | |
tree | ddfb291cada7622915622a95ff2263612bdf1715 /drivers/gpu/drm/drm_crtc.c | |
parent | 0057d8dd8d378bf88f75736496d779f3c9454b5f (diff) |
drm: add 'count' to struct drm_object_properties
This way, we don't need to count every time, so we're a little bit
faster and code is a little bit smaller.
Change suggested by Ville Syrjälä.
Reviewed-by: Rob Clark <rob.clark@linaro.org>
Tested-by: Rob Clark <rob.clark@linaro.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 793f51b0f7a4..368e3e72a452 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -1425,11 +1425,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, | |||
1425 | } | 1425 | } |
1426 | connector = obj_to_connector(obj); | 1426 | connector = obj_to_connector(obj); |
1427 | 1427 | ||
1428 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | 1428 | props_count = connector->properties.count; |
1429 | if (connector->properties.ids[i] != 0) { | ||
1430 | props_count++; | ||
1431 | } | ||
1432 | } | ||
1433 | 1429 | ||
1434 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | 1430 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
1435 | if (connector->encoder_ids[i] != 0) { | 1431 | if (connector->encoder_ids[i] != 0) { |
@@ -1482,21 +1478,19 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, | |||
1482 | copied = 0; | 1478 | copied = 0; |
1483 | prop_ptr = (uint32_t __user *)(unsigned long)(out_resp->props_ptr); | 1479 | prop_ptr = (uint32_t __user *)(unsigned long)(out_resp->props_ptr); |
1484 | prop_values = (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr); | 1480 | prop_values = (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr); |
1485 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | 1481 | for (i = 0; i < connector->properties.count; i++) { |
1486 | if (connector->properties.ids[i] != 0) { | 1482 | if (put_user(connector->properties.ids[i], |
1487 | if (put_user(connector->properties.ids[i], | 1483 | prop_ptr + copied)) { |
1488 | prop_ptr + copied)) { | 1484 | ret = -EFAULT; |
1489 | ret = -EFAULT; | 1485 | goto out; |
1490 | goto out; | 1486 | } |
1491 | } | ||
1492 | 1487 | ||
1493 | if (put_user(connector->properties.values[i], | 1488 | if (put_user(connector->properties.values[i], |
1494 | prop_values + copied)) { | 1489 | prop_values + copied)) { |
1495 | ret = -EFAULT; | 1490 | ret = -EFAULT; |
1496 | goto out; | 1491 | goto out; |
1497 | } | ||
1498 | copied++; | ||
1499 | } | 1492 | } |
1493 | copied++; | ||
1500 | } | 1494 | } |
1501 | } | 1495 | } |
1502 | out_resp->count_props = props_count; | 1496 | out_resp->count_props = props_count; |
@@ -2845,19 +2839,19 @@ void drm_object_attach_property(struct drm_mode_object *obj, | |||
2845 | struct drm_property *property, | 2839 | struct drm_property *property, |
2846 | uint64_t init_val) | 2840 | uint64_t init_val) |
2847 | { | 2841 | { |
2848 | int i; | 2842 | int count = obj->properties->count; |
2849 | 2843 | ||
2850 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | 2844 | if (count == DRM_OBJECT_MAX_PROPERTY) { |
2851 | if (obj->properties->ids[i] == 0) { | 2845 | WARN(1, "Failed to attach object property (type: 0x%x). Please " |
2852 | obj->properties->ids[i] = property->base.id; | 2846 | "increase DRM_OBJECT_MAX_PROPERTY by 1 for each time " |
2853 | obj->properties->values[i] = init_val; | 2847 | "you see this message on the same object type.\n", |
2854 | return; | 2848 | obj->type); |
2855 | } | 2849 | return; |
2856 | } | 2850 | } |
2857 | 2851 | ||
2858 | WARN(1, "Failed to attach object property (type: 0x%x). Please " | 2852 | obj->properties->ids[count] = property->base.id; |
2859 | "increase DRM_OBJECT_MAX_PROPERTY by 1 for each time you see " | 2853 | obj->properties->values[count] = init_val; |
2860 | "this message on the same object type.\n", obj->type); | 2854 | obj->properties->count++; |
2861 | } | 2855 | } |
2862 | EXPORT_SYMBOL(drm_object_attach_property); | 2856 | EXPORT_SYMBOL(drm_object_attach_property); |
2863 | 2857 | ||
@@ -2866,7 +2860,7 @@ int drm_object_property_set_value(struct drm_mode_object *obj, | |||
2866 | { | 2860 | { |
2867 | int i; | 2861 | int i; |
2868 | 2862 | ||
2869 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | 2863 | for (i = 0; i < obj->properties->count; i++) { |
2870 | if (obj->properties->ids[i] == property->base.id) { | 2864 | if (obj->properties->ids[i] == property->base.id) { |
2871 | obj->properties->values[i] = val; | 2865 | obj->properties->values[i] = val; |
2872 | return 0; | 2866 | return 0; |
@@ -2882,7 +2876,7 @@ int drm_object_property_get_value(struct drm_mode_object *obj, | |||
2882 | { | 2876 | { |
2883 | int i; | 2877 | int i; |
2884 | 2878 | ||
2885 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | 2879 | for (i = 0; i < obj->properties->count; i++) { |
2886 | if (obj->properties->ids[i] == property->base.id) { | 2880 | if (obj->properties->ids[i] == property->base.id) { |
2887 | *val = obj->properties->values[i]; | 2881 | *val = obj->properties->values[i]; |
2888 | return 0; | 2882 | return 0; |
@@ -3174,11 +3168,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, | |||
3174 | goto out; | 3168 | goto out; |
3175 | } | 3169 | } |
3176 | 3170 | ||
3177 | /* Assume [ prop, 0, prop ] won't happen (if we ever delete properties, | 3171 | props_count = obj->properties->count; |
3178 | * we need to remove the gap inside the array). */ | ||
3179 | for (props_count = 0; props_count < DRM_OBJECT_MAX_PROPERTY && | ||
3180 | obj->properties->ids[props_count] != 0; props_count++) | ||
3181 | ; | ||
3182 | 3172 | ||
3183 | /* This ioctl is called twice, once to determine how much space is | 3173 | /* This ioctl is called twice, once to determine how much space is |
3184 | * needed, and the 2nd time to fill it. */ | 3174 | * needed, and the 2nd time to fill it. */ |
@@ -3228,11 +3218,11 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, | |||
3228 | if (!arg_obj->properties) | 3218 | if (!arg_obj->properties) |
3229 | goto out; | 3219 | goto out; |
3230 | 3220 | ||
3231 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) | 3221 | for (i = 0; i < arg_obj->properties->count; i++) |
3232 | if (arg_obj->properties->ids[i] == arg->prop_id) | 3222 | if (arg_obj->properties->ids[i] == arg->prop_id) |
3233 | break; | 3223 | break; |
3234 | 3224 | ||
3235 | if (i == DRM_OBJECT_MAX_PROPERTY) | 3225 | if (i == arg_obj->properties->count) |
3236 | goto out; | 3226 | goto out; |
3237 | 3227 | ||
3238 | prop_obj = drm_mode_object_find(dev, arg->prop_id, | 3228 | prop_obj = drm_mode_object_find(dev, arg->prop_id, |