drm: Don't pass the index to drm_property_add_enum()
Subsystems (5)
PATCH 1/1 drm: Don't pass the index to drm_property_add_enum()
From: Ville Syrjälä <[email protected]>
drm_property_add_enum() can calculate the index itself just fine, so no point in having the caller pass it in.
--- drivers/gpu/drm/drm_connector.c | 6 +++--- drivers/gpu/drm/drm_property.c | 27 +++++++++++++-------------- drivers/gpu/drm/gma500/cdv_device.c | 4 ++-- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 4 +--- include/drm/drm_property.h | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_connector.c +3 -3
@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, goto nomem;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]); dev->mode_config.tv_brightness_property =
@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, {struct drm_device *dev = connector->dev;struct drm_property *scaling_mode_property; -int i, j =0 ; +int i;const unsigned valid_scaling_mode_mask = (1U <<ARRAY_SIZE (drm_scaling_mode_enum_list)) -1 ;
@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,if (!(BIT (i) & scaling_mode_mask))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].name);
drivers/gpu/drm/drm_property.c +13 -14
@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev,return NULL ;for (i =0 ; i < num_values; i++) { - ret =drm_property_add_enum (property, i, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, uint64_t supported_bits) {struct drm_property *property; -int i, ret, index =0 ; +int i, ret;int num_values =hweight64 (supported_bits); flags |=DRM_MODE_PROP_BITMASK ;
@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,if (!(supported_bits & (1ULL << props[i].type)))continue ; -if (WARN_ON (index >= num_values)) { -drm_property_destroy (dev, property); -return NULL ; - } - - ret =drm_property_add_enum (property, index++, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool);/** * drm_property_add_enum - add a possible value to an enumeration property * @property: enumeration property to change -* @index: index of the new enumeration * @value: value of the new enumeration * @name: symbolic name of the new enumeration *
@@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool);* Returns: * 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) {struct drm_property_enum *prop_enum; +int index =0 ;if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return -EINVAL ;
@@ -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) {if (WARN_ON (prop_enum->value == value))return -EINVAL ; + index++; } +if (WARN_ON (index >= property->num_values)) +return -EINVAL ; + prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );if (!prop_enum)return -ENOMEM ;
drivers/gpu/drm/gma500/cdv_device.c +2 -2
@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector)return ;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; }
@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)return ;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; }
drivers/gpu/drm/gma500/psb_intel_sdvo.c +1 -1
@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_sfor (i =0 ; i < psb_intel_sdvo_connector->format_supported_num; i++)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]]); psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0 ];
drivers/gpu/drm/i915/intel_sdvo.c +2 -3
@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,return false;for (i =0 ; i < intel_sdvo_connector->format_supported_num; i++) -drm_property_add_enum ( - intel_sdvo_connector->tv_format, i, - i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); +drm_property_add_enum (intel_sdvo_connector->tv_format, 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 ]; drm_object_attach_property(&intel_sdvo_connector->base.base.base,
drivers/gpu/drm/nouveau/nouveau_display.c +1 -3
@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {if (c) { \ p =drm_property_create (dev,DRM_MODE_PROP_ENUM , n, c); \ l = (list); \ - c =0 ; \while (p && l->gen_mask) { \if (l->gen_mask & (1 << (gen))) { \ -drm_property_add_enum (p, c, l->type, l->name); \ - c++; \ +drm_property_add_enum (p, l->type, l->name); \ } \ l++; \ } \
include/drm/drm_property.h +1 -1
@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev, uint32_t type);struct drm_property *drm_property_create_bool (struct drm_device *dev,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);void drm_property_destroy (struct drm_device *dev,struct drm_property *property);
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm: Don't pass the index to drm_property_add_enum()
== Series Details ==
== Series Details ==
Series: drm: Don't pass the index to drm_property_add_enum()
URL : https://patchwork.freedesktop.org/series/40122/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip f153106cd56b drm: Don't pass the index to drm_property_add_enum() -:135: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #135: FILE: drivers/gpu/drm/gma500/cdv_device.c:488: + drm_property_add_enum(prop, i-1, force_audio_names[i]); ^
-:173: WARNING:LONG_LINE: line over 100 characters #173: FILE: drivers/gpu/drm/i915/intel_sdvo.c:2783:
+ tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
total: 0 errors, 1 warnings, 1 checks, 147 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm: Don't pass the index to drm_property_add_enum()
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Don't pass the index to drm_property_add_enum()
URL : https://patchwork.freedesktop.org/series/40122/
State : success
== Summary ==
Series 40122v1 drm: Don't pass the index to drm_property_add_enum()
https://patchwork.freedesktop.org/api/1.0/series/40122/revisions/1/mbox/
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:431s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:443s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:383s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:544s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:297s fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:514s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:518s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:503s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:412s fi-cfl-s2 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:580s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:510s fi-cnl-drrs total:285 pass:254 dwarn:3 dfail:0 fail:0 skip:28 time:529s fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:584s fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:420s fi-gdg-551 total:285 pass:177 dwarn:0 dfail:0 fail:0 skip:108 time:320s fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:539s fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:404s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:424s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:474s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:428s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:480s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:468s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:516s fi-pnv-d510 total:285 pass:219 dwarn:1 dfail:0 fail:0 skip:65 time:654s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:446s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:532s fi-skl-6700hq total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:544s fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:508s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:504s fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:432s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:446s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:570s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:408s
66a3be2efe097a5aa8617214ac99fef81d623fe7 drm-tip: 2018y-03m-16d-16h-32m-51s UTC integration manifest f153106cd56b drm: Don't pass the index to drm_property_add_enum()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8381/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm: Don't pass the index to drm_property_add_enum()
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Don't pass the index to drm_property_add_enum()
URL : https://patchwork.freedesktop.org/series/40122/
State : success
== Summary ==
---- Possible new issues:
Test kms_cursor_crc:
Subgroup cursor-128x128-suspend:
skip -> PASS (shard-snb)---- Known issues:
Test drv_suspend:
Subgroup debugfs-reader:
pass -> SKIP (shard-snb) fdo#102365
Test kms_sysfs_edid_timing:
pass -> WARN (shard-apl) fdo#100047
Test perf:
Subgroup blocking:
fail -> PASS (shard-hsw) fdo#102252fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-apl total:3442 pass:1814 dwarn:1 dfail:0 fail:7 skip:1619 time:13058s shard-hsw total:3442 pass:1768 dwarn:1 dfail:0 fail:1 skip:1671 time:12043s shard-snb total:3442 pass:1358 dwarn:1 dfail:0 fail:2 skip:2081 time:7251s
Blacklisted hosts:
shard-kbl total:3382 pass:1902 dwarn:1 dfail:0 fail:7 skip:1471 time:9556s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8381/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Best Regards,
Lisovskiy Stanislav
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo>
________________________________________
From: Ville Syrjala [[email protected]]
Sent: Friday, March 16, 2018 9:04 PM
To: [email protected]
Cc: [email protected]; Patrik Jakobsson; Ben Skeggs; [email protected]
Subject: [PATCH] drm: Don't pass the index to drm_property_add_enum()
From: Ville Syrjälä <[email protected]>
drm_property_add_enum() can calculate the index itself just fine, so no point in having the caller pass it in.
--- drivers/gpu/drm/drm_connector.c | 6 +++--- drivers/gpu/drm/drm_property.c | 27 +++++++++++++-------------- drivers/gpu/drm/gma500/cdv_device.c | 4 ++-- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 4 +--- include/drm/drm_property.h | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_connector.c +3 -3
@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, goto nomem;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]); dev->mode_config.tv_brightness_property =
@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, {struct drm_device *dev = connector->dev;struct drm_property *scaling_mode_property; -int i, j =0 ; +int i;const unsigned valid_scaling_mode_mask = (1U <<ARRAY_SIZE (drm_scaling_mode_enum_list)) -1 ;
@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,if (!(BIT (i) & scaling_mode_mask))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].name);
drivers/gpu/drm/drm_property.c +13 -14
@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev,return NULL ;for (i =0 ; i < num_values; i++) { - ret =drm_property_add_enum (property, i, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, uint64_t supported_bits) {struct drm_property *property; -int i, ret, index =0 ; +int i, ret;int num_values =hweight64 (supported_bits); flags |=DRM_MODE_PROP_BITMASK ;
@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,if (!(supported_bits & (1ULL << props[i].type)))continue ; -if (WARN_ON (index >= num_values)) { -drm_property_destroy (dev, property); -return NULL ; - } - - ret =drm_property_add_enum (property, index++, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool);/** * drm_property_add_enum - add a possible value to an enumeration property * @property: enumeration property to change -* @index: index of the new enumeration * @value: value of the new enumeration * @name: symbolic name of the new enumeration *
@@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool);* Returns: * 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) {struct drm_property_enum *prop_enum; +int index =0 ;if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return -EINVAL ;
@@ -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) {if (WARN_ON (prop_enum->value == value))return -EINVAL ; + index++; } +if (WARN_ON (index >= property->num_values)) +return -EINVAL ; + prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );if (!prop_enum)return -ENOMEM ;
drivers/gpu/drm/gma500/cdv_device.c +2 -2
@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector)return ;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; }
@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)return ;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; }
drivers/gpu/drm/gma500/psb_intel_sdvo.c +1 -1
@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_sfor (i =0 ; i < psb_intel_sdvo_connector->format_supported_num; i++)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]]); psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0 ];
drivers/gpu/drm/i915/intel_sdvo.c +2 -3
@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,return false;for (i =0 ; i < intel_sdvo_connector->format_supported_num; i++) -drm_property_add_enum ( - intel_sdvo_connector->tv_format, i, - i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); +drm_property_add_enum (intel_sdvo_connector->tv_format, 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 ]; drm_object_attach_property(&intel_sdvo_connector->base.base.base,
drivers/gpu/drm/nouveau/nouveau_display.c +1 -3
@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {if (c) { \ p =drm_property_create (dev,DRM_MODE_PROP_ENUM , n, c); \ l = (list); \ - c =0 ; \while (p && l->gen_mask) { \if (l->gen_mask & (1 << (gen))) { \ -drm_property_add_enum (p, c, l->type, l->name); \ - c++; \ +drm_property_add_enum (p, l->type, l->name); \ } \ l++; \ } \
include/drm/drm_property.h +1 -1
@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev, uint32_t type);struct drm_property *drm_property_create_bool (struct drm_device *dev,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);void drm_property_destroy (struct drm_device *dev,struct drm_property *property);
--
2.16.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): A98B49F3E938DC4A837FD9A548D117E612880037-kPTMFJFq+rFT4JjzTwqWc7fspsVTdybXVpNB7YpNyf8@public.gmane.org
Best Regards,
Lisovskiy Stanislav
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
________________________________________
From: Intel-gfx [[email protected]] on behalf of Lisovskiy, Stanislav [[email protected]]
Sent: Monday, April 23, 2018 4:59 PM
To: Ville Syrjala; [email protected]
Cc: [email protected]; [email protected]; Ben Skeggs
Subject: Re: [Intel-gfx] [PATCH] drm: Don't pass the index to drm_property_add_enum()
Best Regards,
Lisovskiy Stanislav
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo>
________________________________________
From: Ville Syrjala [[email protected]]
Sent: Friday, March 16, 2018 9:04 PM
To: [email protected]
Cc: [email protected]; Patrik Jakobsson; Ben Skeggs; [email protected]
Subject: [PATCH] drm: Don't pass the index to drm_property_add_enum()
From: Ville Syrjälä <[email protected]>
drm_property_add_enum() can calculate the index itself just fine, so no point in having the caller pass it in.
--- drivers/gpu/drm/drm_connector.c | 6 +++--- drivers/gpu/drm/drm_property.c | 27 +++++++++++++-------------- drivers/gpu/drm/gma500/cdv_device.c | 4 ++-- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 4 +--- include/drm/drm_property.h | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_connector.c +3 -3
@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, goto nomem;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]); dev->mode_config.tv_brightness_property =
@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, {struct drm_device *dev = connector->dev;struct drm_property *scaling_mode_property; -int i, j =0 ; +int i;const unsigned valid_scaling_mode_mask = (1U <<ARRAY_SIZE (drm_scaling_mode_enum_list)) -1 ;
@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,if (!(BIT (i) & scaling_mode_mask))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].name);
drivers/gpu/drm/drm_property.c +13 -14
@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev,return NULL ;for (i =0 ; i < num_values; i++) { - ret =drm_property_add_enum (property, i, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, uint64_t supported_bits) {struct drm_property *property; -int i, ret, index =0 ; +int i, ret;int num_values =hweight64 (supported_bits); flags |=DRM_MODE_PROP_BITMASK ;
@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,if (!(supported_bits & (1ULL << props[i].type)))continue ; -if (WARN_ON (index >= num_values)) { -drm_property_destroy (dev, property); -return NULL ; - } - - ret =drm_property_add_enum (property, index++, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;
@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool);/** * drm_property_add_enum - add a possible value to an enumeration property * @property: enumeration property to change -* @index: index of the new enumeration * @value: value of the new enumeration * @name: symbolic name of the new enumeration *
@@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool);* Returns: * 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) {struct drm_property_enum *prop_enum; +int index =0 ;if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return -EINVAL ;
@@ -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) {if (WARN_ON (prop_enum->value == value))return -EINVAL ; + index++; } +if (WARN_ON (index >= property->num_values)) +return -EINVAL ; + prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );if (!prop_enum)return -ENOMEM ;
drivers/gpu/drm/gma500/cdv_device.c +2 -2
@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector)return ;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; }
@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)return ;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; }
drivers/gpu/drm/gma500/psb_intel_sdvo.c +1 -1
@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_sfor (i =0 ; i < psb_intel_sdvo_connector->format_supported_num; i++)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]]); psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0 ];
drivers/gpu/drm/i915/intel_sdvo.c +2 -3
@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,return false;for (i =0 ; i < intel_sdvo_connector->format_supported_num; i++) -drm_property_add_enum ( - intel_sdvo_connector->tv_format, i, - i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); +drm_property_add_enum (intel_sdvo_connector->tv_format, 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 ]; drm_object_attach_property(&intel_sdvo_connector->base.base.base,
drivers/gpu/drm/nouveau/nouveau_display.c +1 -3
@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {if (c) { \ p =drm_property_create (dev,DRM_MODE_PROP_ENUM , n, c); \ l = (list); \ - c =0 ; \while (p && l->gen_mask) { \if (l->gen_mask & (1 << (gen))) { \ -drm_property_add_enum (p, c, l->type, l->name); \ - c++; \ +drm_property_add_enum (p, l->type, l->name); \ } \ l++; \ } \
include/drm/drm_property.h +1 -1
@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev, uint32_t type);struct drm_property *drm_property_create_bool (struct drm_device *dev,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);void drm_property_destroy (struct drm_device *dev,struct drm_property *property);
--
2.16.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): A98B49F3E938DC4A837FD9A548D117E6128815E8-kPTMFJFq+rFT4JjzTwqWc7fspsVTdybXVpNB7YpNyf8@public.gmane.org
Quoted 1 line · Stanislav
Reviewed-by Stanislav Lisovskiy <[email protected]>
Thanks. Pushed to drm-misc-next.
Quoted 244 lines
Best Regards,
Lisovskiy Stanislav
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
________________________________________
From: Intel-gfx [[email protected]] on behalf of Lisovskiy, Stanislav [[email protected]]
Sent: Monday, April 23, 2018 4:59 PM
To: Ville Syrjala; [email protected]
Cc: [email protected]; [email protected]; Ben Skeggs
Subject: Re: [Intel-gfx] [PATCH] drm: Don't pass the index todrm_property_add_enum()Best Regards,
Lisovskiy Stanislav
Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo>
________________________________________
From: Ville Syrjala [[email protected]]
Sent: Friday, March 16, 2018 9:04 PM
To: [email protected]
Cc: [email protected]; Patrik Jakobsson; Ben Skeggs; [email protected]
Subject: [PATCH] drm: Don't pass the index todrm_property_add_enum()From: Ville Syrjälä <[email protected]>
drm_property_add_enum()can calculate the index itself just fine, so no point in having the caller pass it in.Cc Patrik Jakobsson <[email protected]>Cc Ben Skeggs <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_connector.c | 6 +++--- drivers/gpu/drm/drm_property.c | 27 +++++++++++++-------------- drivers/gpu/drm/gma500/cdv_device.c | 4 ++-- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_display.c | 4 +--- include/drm/drm_property.h | 2 +- 7 files changed, 23 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_connector.c +3
-3@@ -1069,7 +1069,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, goto nomem;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]); dev->mode_config.tv_brightness_property =@@ -1156,7 +1156,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, {struct drm_device *dev = connector->dev;struct drm_property *scaling_mode_property; -int i, j =0 ; +int i;const unsigned valid_scaling_mode_mask = (1U <<ARRAY_SIZE (drm_scaling_mode_enum_list)) -1 ;@@ -1177,7 +1177,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,if (!(BIT (i) & scaling_mode_mask))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].name);drivers/gpu/drm/drm_property.c +13
-14@@ -169,9 +169,9 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev,return NULL ;for (i =0 ; i < num_values; i++) { - ret =drm_property_add_enum (property, i, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;@@ -209,7 +209,7 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev, uint64_t supported_bits) {struct drm_property *property; -int i, ret, index =0 ; +int i, ret;int num_values =hweight64 (supported_bits); flags |=DRM_MODE_PROP_BITMASK ;@@ -221,14 +221,9 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,if (!(supported_bits & (1ULL << props[i].type)))continue ; -if (WARN_ON (index >= num_values)) { -drm_property_destroy (dev, property); -return NULL ; - } - - ret =drm_property_add_enum (property, index++, - props[i].type, - props[i].name); + ret =drm_property_add_enum (property, + props[i].type, + props[i].name);if (ret) {drm_property_destroy (dev, property);return NULL ;@@ -376,7 +371,6 @@ EXPORT_SYMBOL(drm_property_create_bool);/** * drm_property_add_enum - add a possible value to an enumeration property * @property: enumeration property to change -* @index: index of the new enumeration * @value: value of the new enumeration * @name: symbolic name of the new enumeration * @@ -388,10 +382,11 @@ EXPORT_SYMBOL(drm_property_create_bool);* Returns: * 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) {struct drm_property_enum *prop_enum; +int index =0 ;if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return -EINVAL ;@@ -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) {if (WARN_ON (prop_enum->value == value))return -EINVAL ; + index++; } +if (WARN_ON (index >= property->num_values)) +return -EINVAL ; + prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );if (!prop_enum)return -ENOMEM ;drivers/gpu/drm/gma500/cdv_device.c +2
-2@@ -485,7 +485,7 @@ void cdv_intel_attach_force_audio_property(struct drm_connector *connector)return ;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; }@@ -514,7 +514,7 @@ void cdv_intel_attach_broadcast_rgb_property(struct drm_connector *connector)return ;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; }drivers/gpu/drm/gma500/psb_intel_sdvo.c +1
-1@@ -2281,7 +2281,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_sfor (i =0 ; i < psb_intel_sdvo_connector->format_supported_num; i++)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]]); psb_intel_sdvo->tv_format_index = psb_intel_sdvo_connector->tv_format_supported[0 ];drivers/gpu/drm/i915/intel_sdvo.c +2
-3@@ -2779,9 +2779,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,return false;for (i =0 ; i < intel_sdvo_connector->format_supported_num; i++) -drm_property_add_enum ( - intel_sdvo_connector->tv_format, i, - i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); +drm_property_add_enum (intel_sdvo_connector->tv_format, 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 ]; drm_object_attach_property(&intel_sdvo_connector->base.base.base,drivers/gpu/drm/nouveau/nouveau_display.c +1
-3@@ -338,11 +338,9 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {if (c) { \ p =drm_property_create (dev,DRM_MODE_PROP_ENUM , n, c); \ l = (list); \ - c =0 ; \while (p && l->gen_mask) { \if (l->gen_mask & (1 << (gen))) { \ -drm_property_add_enum (p, c, l->type, l->name); \ - c++; \ +drm_property_add_enum (p, l->type, l->name); \ } \ l++; \ } \include/drm/drm_property.h +1
-2@@ -260,7 +260,7 @@ struct drm_property *drm_property_create_object(struct drm_device *dev, uint32_t type);struct drm_property *drm_property_create_bool (struct drm_device *dev,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);void drm_property_destroy (struct drm_device *dev,struct drm_property *property); --2.16.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
Patchwork
CI✗ Fi.CI.BAT: failure for drm: Don't pass the index to drm_property_add_enum() (rev2)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Don't pass the index to drm_property_add_enum() (rev2)
URL : https://patchwork.freedesktop.org/series/40122/
State : failure
== Summary ==
Applying: drm: Don't pass the index to drm_property_add_enum()
error: patch failed: drivers/gpu/drm/drm_connector.c:1069
error: drivers/gpu/drm/drm_connector.c: patch does not apply
error: patch failed: drivers/gpu/drm/drm_property.c:169
error: drivers/gpu/drm/drm_property.c: patch does not apply
error: patch failed: drivers/gpu/drm/gma500/cdv_device.c:485
error: drivers/gpu/drm/gma500/cdv_device.c: patch does not apply
error: patch failed: drivers/gpu/drm/gma500/psb_intel_sdvo.c:2281
error: drivers/gpu/drm/gma500/psb_intel_sdvo.c: patch does not apply
error: patch failed: drivers/gpu/drm/i915/intel_sdvo.c:2779
error: drivers/gpu/drm/i915/intel_sdvo.c: patch does not apply
error: patch failed: drivers/gpu/drm/nouveau/nouveau_display.c:338
error: drivers/gpu/drm/nouveau/nouveau_display.c: patch does not apply
error: patch failed: include/drm/drm_property.h:260
error: include/drm/drm_property.h: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
Using index info to reconstruct a base tree...
M include/drm/drm_property.h
Patch failed at 0001 drm: Don't pass the index to drm_property_add_enum() The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for drm: Don't pass the index to drm_property_add_enum() (rev3)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Don't pass the index to drm_property_add_enum() (rev3)
URL : https://patchwork.freedesktop.org/series/40122/
State : failure
== Summary ==
Applying: drm: Don't pass the index to drm_property_add_enum()
error: patch failed: drivers/gpu/drm/drm_connector.c:1069
error: drivers/gpu/drm/drm_connector.c: patch does not apply
error: patch failed: drivers/gpu/drm/drm_property.c:169
error: drivers/gpu/drm/drm_property.c: patch does not apply
error: patch failed: drivers/gpu/drm/gma500/cdv_device.c:485
error: drivers/gpu/drm/gma500/cdv_device.c: patch does not apply
error: patch failed: drivers/gpu/drm/gma500/psb_intel_sdvo.c:2281
error: drivers/gpu/drm/gma500/psb_intel_sdvo.c: patch does not apply
error: patch failed: drivers/gpu/drm/i915/intel_sdvo.c:2779
error: drivers/gpu/drm/i915/intel_sdvo.c: patch does not apply
error: patch failed: drivers/gpu/drm/nouveau/nouveau_display.c:338
error: drivers/gpu/drm/nouveau/nouveau_display.c: patch does not apply
error: patch failed: include/drm/drm_property.h:260
error: include/drm/drm_property.h: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
Using index info to reconstruct a base tree...
M drivers/gpu/drm/gma500/psb_intel_sdvo.c
M include/drm/drm_property.h
Patch failed at 0001 drm: Don't pass the index to drm_property_add_enum() The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx