Commit 30e9db6d authored by Ville Syrjälä's avatar Ville Syrjälä

drm: Don't pass the index to drm_property_add_enum()

drm_property_add_enum() can calculate the index itself just fine,
so no point in having the caller pass it in.

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: nouveau@lists.freedesktop.org
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180316190420.26734-1-ville.syrjala@linux.intel.comReviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
parent ebb513ad
...@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, ...@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev,
goto nomem; goto nomem;
for (i = 0; i < num_modes; i++) for (i = 0; i < num_modes; i++)
drm_property_add_enum(dev->mode_config.tv_mode_property, i, drm_property_add_enum(dev->mode_config.tv_mode_property,
i, modes[i]); i, modes[i]);
dev->mode_config.tv_brightness_property = dev->mode_config.tv_brightness_property =
...@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, ...@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
{ {
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct drm_property *scaling_mode_property; struct drm_property *scaling_mode_property;
int i, j = 0; int i;
const unsigned valid_scaling_mode_mask = const unsigned valid_scaling_mode_mask =
(1U << ARRAY_SIZE(drm_scaling_mode_enum_list)) - 1; (1U << ARRAY_SIZE(drm_scaling_mode_enum_list)) - 1;
...@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, ...@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
if (!(BIT(i) & scaling_mode_mask)) if (!(BIT(i) & scaling_mode_mask))
continue; continue;
ret = drm_property_add_enum(scaling_mode_property, j++, ret = drm_property_add_enum(scaling_mode_property,
drm_scaling_mode_enum_list[i].type, drm_scaling_mode_enum_list[i].type,
drm_scaling_mode_enum_list[i].name); drm_scaling_mode_enum_list[i].name);
......
...@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev, ...@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev,
return NULL; return NULL;
for (i = 0; i < num_values; i++) { for (i = 0; i < num_values; i++) {
ret = drm_property_add_enum(property, i, ret = drm_property_add_enum(property,
props[i].type, props[i].type,
props[i].name); props[i].name);
if (ret) { if (ret) {
drm_property_destroy(dev, property); drm_property_destroy(dev, property);
return NULL; return NULL;
...@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, ...@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
uint64_t supported_bits) uint64_t supported_bits)
{ {
struct drm_property *property; struct drm_property *property;
int i, ret, index = 0; int i, ret;
int num_values = hweight64(supported_bits); int num_values = hweight64(supported_bits);
flags |= DRM_MODE_PROP_BITMASK; flags |= DRM_MODE_PROP_BITMASK;
...@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, ...@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
if (!(supported_bits & (1ULL << props[i].type))) if (!(supported_bits & (1ULL << props[i].type)))
continue; continue;
if (WARN_ON(index >= num_values)) { ret = drm_property_add_enum(property,
drm_property_destroy(dev, property); props[i].type,
return NULL; props[i].name);
}
ret = drm_property_add_enum(property, index++,
props[i].type,
props[i].name);
if (ret) { if (ret) {
drm_property_destroy(dev, property); drm_property_destroy(dev, property);
return NULL; return NULL;
...@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool); ...@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool);
/** /**
* drm_property_add_enum - add a possible value to an enumeration property * drm_property_add_enum - add a possible value to an enumeration property
* @property: enumeration property to change * @property: enumeration property to change
* @index: index of the new enumeration
* @value: value of the new enumeration * @value: value of the new enumeration
* @name: symbolic name of the new enumeration * @name: symbolic name of the new enumeration
* *
...@@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool); ...@@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool);
* Returns: * Returns:
* Zero on success, error code on failure. * Zero on success, error code on failure.
*/ */
int drm_property_add_enum(struct drm_property *property, int index, int drm_property_add_enum(struct drm_property *property,
uint64_t value, const char *name) uint64_t value, const char *name)
{ {
struct drm_property_enum *prop_enum; struct drm_property_enum *prop_enum;
int index = 0;
if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN)) if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
return -EINVAL; return -EINVAL;
...@@ -411,8 +406,12 @@ int drm_property_add_enum(struct drm_property *property, int index, ...@@ -411,8 +406,12 @@ int drm_property_add_enum(struct drm_property *property, int index,
list_for_each_entry(prop_enum, &property->enum_list, head) { list_for_each_entry(prop_enum, &property->enum_list, head) {
if (WARN_ON(prop_enum->value == value)) if (WARN_ON(prop_enum->value == value))
return -EINVAL; return -EINVAL;
index++;
} }
if (WARN_ON(index >= property->num_values))
return -EINVAL;
prop_enum = kzalloc(sizeof(struct drm_property_enum), GFP_KERNEL); prop_enum = kzalloc(sizeof(struct drm_property_enum), GFP_KERNEL);
if (!prop_enum) if (!prop_enum)
return -ENOMEM; return -ENOMEM;
......
...@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector) ...@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector)
return; return;
for (i = 0; i < ARRAY_SIZE(force_audio_names); i++) for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
drm_property_add_enum(prop, i, i-1, force_audio_names[i]); drm_property_add_enum(prop, i-1, force_audio_names[i]);
dev_priv->force_audio_property = prop; dev_priv->force_audio_property = prop;
} }
...@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector) ...@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)
return; return;
for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++) for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++)
drm_property_add_enum(prop, i, i, broadcast_rgb_names[i]); drm_property_add_enum(prop, i, broadcast_rgb_names[i]);
dev_priv->broadcast_rgb_property = prop; dev_priv->broadcast_rgb_property = prop;
} }
......
...@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_s ...@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_s
for (i = 0; i < psb_intel_sdvo_connector->format_supported_num; i++) for (i = 0; i < psb_intel_sdvo_connector->format_supported_num; i++)
drm_property_add_enum( drm_property_add_enum(
psb_intel_sdvo_connector->tv_format, i, psb_intel_sdvo_connector->tv_format,
i, tv_format_names[psb_intel_sdvo_connector->tv_format_supported[i]]); i, tv_format_names[psb_intel_sdvo_connector->tv_format_supported[i]]);
psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0]; psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0];
......
...@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, ...@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
return false; return false;
for (i = 0; i < intel_sdvo_connector->format_supported_num; i++) for (i = 0; i < intel_sdvo_connector->format_supported_num; i++)
drm_property_add_enum( drm_property_add_enum(intel_sdvo_connector->tv_format, i,
intel_sdvo_connector->tv_format, i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
intel_sdvo_connector->base.base.state->tv.mode = intel_sdvo_connector->tv_format_supported[0]; intel_sdvo_connector->base.base.state->tv.mode = intel_sdvo_connector->tv_format_supported[0];
drm_object_attach_property(&intel_sdvo_connector->base.base.base, drm_object_attach_property(&intel_sdvo_connector->base.base.base,
......
...@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = { ...@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {
if (c) { \ if (c) { \
p = drm_property_create(dev, DRM_MODE_PROP_ENUM, n, c); \ p = drm_property_create(dev, DRM_MODE_PROP_ENUM, n, c); \
l = (list); \ l = (list); \
c = 0; \
while (p && l->gen_mask) { \ while (p && l->gen_mask) { \
if (l->gen_mask & (1 << (gen))) { \ if (l->gen_mask & (1 << (gen))) { \
drm_property_add_enum(p, c, l->type, l->name); \ drm_property_add_enum(p, l->type, l->name); \
c++; \
} \ } \
l++; \ l++; \
} \ } \
......
...@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev, ...@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev,
uint32_t type); uint32_t type);
struct drm_property *drm_property_create_bool(struct drm_device *dev, struct drm_property *drm_property_create_bool(struct drm_device *dev,
u32 flags, const char *name); u32 flags, const char *name);
int drm_property_add_enum(struct drm_property *property, int index, int drm_property_add_enum(struct drm_property *property,
uint64_t value, const char *name); uint64_t value, const char *name);
void drm_property_destroy(struct drm_device *dev, struct drm_property *property); void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment