From: Paulo Zanoni <przanoni@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 1/8] drm: add drm_property_change_is_valid
Date: Tue, 15 May 2012 18:08:59 -0300 [thread overview]
Message-ID: <1337116145-15041-1-git-send-email-przanoni@gmail.com> (raw)
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
Move code from drm_mode_connector_property_set_ioctl to a new
function, so we can reuse this code when we add crtc properties.
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
drivers/gpu/drm/drm_crtc.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
>From the previous patch series sent, the only comment this patch had was this,
from Eugeni:
> Those two checks could probably be combined into one (< values || > values)
> for further simplification.
Answer:
Fixed. The new function was just copy-paste, but your suggestion is good.
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d3aaeb6..6014413 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3033,6 +3033,24 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
+static bool drm_property_change_is_valid(struct drm_property *property,
+ __u64 value)
+{
+ if (property->flags & DRM_MODE_PROP_IMMUTABLE)
+ return false;
+ if (property->flags & DRM_MODE_PROP_RANGE) {
+ if (value < property->values[0] || value > property->values[1])
+ return false;
+ return true;
+ } else {
+ int i;
+ for (i = 0; i < property->num_values; i++)
+ if (property->values[i] == value)
+ return true;
+ return false;
+ }
+}
+
int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv)
{
@@ -3069,28 +3087,9 @@ int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
}
property = obj_to_property(obj);
- if (property->flags & DRM_MODE_PROP_IMMUTABLE)
+ if (!drm_property_change_is_valid(property, out_resp->value))
goto out;
- if (property->flags & DRM_MODE_PROP_RANGE) {
- if (out_resp->value < property->values[0])
- goto out;
-
- if (out_resp->value > property->values[1])
- goto out;
- } else {
- int found = 0;
- for (i = 0; i < property->num_values; i++) {
- if (property->values[i] == out_resp->value) {
- found = 1;
- break;
- }
- }
- if (!found) {
- goto out;
- }
- }
-
/* Do DPMS ourselves */
if (property == connector->dev->mode_config.dpms_property) {
if (connector->funcs->dpms)
--
1.7.10
next reply other threads:[~2012-05-15 21:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-15 21:08 Paulo Zanoni [this message]
2012-05-15 21:09 ` [PATCH] drm: WARN() when drm_connector_attach_property fails Paulo Zanoni
2012-05-15 21:09 ` [PATCH] drm: create struct drm_object_properties and use it Paulo Zanoni
2012-05-15 21:09 ` [PATCH] drm: add generic ioctls to get/set properties on any object Paulo Zanoni
2012-05-15 21:09 ` [PATCH] drm: make the connector properties code use the object properties code Paulo Zanoni
2012-05-15 21:09 ` [PATCH] drm: add 'count' to struct drm_object_properties Paulo Zanoni
2012-05-15 21:09 ` [PATCH] drm: add CRTC properties Paulo Zanoni
2012-05-15 21:27 ` Paulo Zanoni
-- strict thread matches above, loose matches on Subject: below --
2012-03-29 21:27 [PATCH 1/8] drm: add drm_property_change_is_valid Paulo Zanoni
2012-03-30 2:38 ` Eugeni Dodonov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337116145-15041-1-git-send-email-przanoni@gmail.com \
--to=przanoni@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.