diff mbox

[13/17] DRM/KMS/EDID: Allow for multiple Connectors when specifying 'firmware'-EDID Files.

Message ID 1353356598-10634-14-git-send-email-eich@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Egbert Eich Nov. 19, 2012, 8:23 p.m. UTC
So far it was only possible to load an EDID for a single connector (unless
no connector was specified at all in which case the same EDID file was used
for all).
This patch extends the EDID loader so that EDID files can be specified for
more than one connector. A semicolon is used to separate the different connector
sections.
The option now looks like this:
   edid_firmware="[<connector_0>:]<edid_file_0>[;<connector_n>:<edid_file_1>]..."

Signed-off-by: Egbert Eich <eich@suse.de>
---
 drivers/gpu/drm/drm_edid_load.c |   45 ++++++++++++++++++++++++++------------
 1 files changed, 31 insertions(+), 14 deletions(-)

Comments

Takashi Iwai Nov. 20, 2012, 8:38 a.m. UTC | #1
At Mon, 19 Nov 2012 15:23:14 -0500,
"Egbert Eich " <"eich@novell.com> wrote:
> 
> So far it was only possible to load an EDID for a single connector (unless
> no connector was specified at all in which case the same EDID file was used
> for all).
> This patch extends the EDID loader so that EDID files can be specified for
> more than one connector. A semicolon is used to separate the different connector
> sections.
> The option now looks like this:
>    edid_firmware="[<connector_0>:]<edid_file_0>[;<connector_n>:<edid_file_1>]..."
> 
> Signed-off-by: Egbert Eich <eich@suse.de>
> ---
>  drivers/gpu/drm/drm_edid_load.c |   45 ++++++++++++++++++++++++++------------
>  1 files changed, 31 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
> index 1475c6f..a40a88505 100644
> --- a/drivers/gpu/drm/drm_edid_load.c
> +++ b/drivers/gpu/drm/drm_edid_load.c
> @@ -196,26 +196,43 @@ struct edid *
>  drm_load_edid_firmware(struct drm_connector *connector)
>  {
>  	char *connector_name = drm_get_connector_name(connector);
> -	char *edidname = edid_firmware, *last, *colon;
> -	struct edid *edid;
> +	char *edidname, *last, *colon;
> +	struct edid *edid = NULL;
> +	char *next, *mem;
> +	bool many = false;
>  
> -	if (*edidname == '\0')
> +	if (*edid_firmware == '\0')
>  		return NULL;
>  
> -	colon = strchr(edidname, ':');
> -	if (colon != NULL) {
> -		if (strncmp(connector_name, edidname, colon - edidname))
> -			return NULL;
> -		edidname = colon + 1;
> -		if (*edidname == '\0')
> -			return NULL;
> +	edidname = mem = kstrndup(edid_firmware, PATH_MAX, GFP_KERNEL);
> +	do {

Missing NULL check of edidname.


Takashi

> +		next = strchr(edidname, ';');
> +		if (next)
> +			*(next++) = '\0';
> +		colon = strchr(edidname, ':');
> +		if (colon == NULL) {
> +			if (next || many)
> +				edidname = NULL;
> +			break;
> +		} else if (!strncmp(connector_name, edidname, colon - edidname)) {
> +			edidname = colon + 1;
> +			break;
> +		}
> +		edidname = next;
> +		many = true;
> +	} while (edidname);
> +
> +	if (edidname && *edidname != '\0') {
> +		last = edidname + strlen(edidname) - 1;
> +		if (*last == '\n')
> +			*last = '\0';
> +
> +		if (strlen(edidname) > 0)
> +			edid = edid_load(connector, edidname, connector_name);
>  	}
>  
> -	last = edidname + strlen(edidname) - 1;
> -	if (*last == '\n')
> -		*last = '\0';
> +	kfree(mem);
>  
> -	edid = edid_load(connector, edidname, connector_name);
>  	if (IS_ERR_OR_NULL(edid))
>  		return NULL;
>  
> -- 
> 1.7.7
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 1475c6f..a40a88505 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -196,26 +196,43 @@  struct edid *
 drm_load_edid_firmware(struct drm_connector *connector)
 {
 	char *connector_name = drm_get_connector_name(connector);
-	char *edidname = edid_firmware, *last, *colon;
-	struct edid *edid;
+	char *edidname, *last, *colon;
+	struct edid *edid = NULL;
+	char *next, *mem;
+	bool many = false;
 
-	if (*edidname == '\0')
+	if (*edid_firmware == '\0')
 		return NULL;
 
-	colon = strchr(edidname, ':');
-	if (colon != NULL) {
-		if (strncmp(connector_name, edidname, colon - edidname))
-			return NULL;
-		edidname = colon + 1;
-		if (*edidname == '\0')
-			return NULL;
+	edidname = mem = kstrndup(edid_firmware, PATH_MAX, GFP_KERNEL);
+	do {
+		next = strchr(edidname, ';');
+		if (next)
+			*(next++) = '\0';
+		colon = strchr(edidname, ':');
+		if (colon == NULL) {
+			if (next || many)
+				edidname = NULL;
+			break;
+		} else if (!strncmp(connector_name, edidname, colon - edidname)) {
+			edidname = colon + 1;
+			break;
+		}
+		edidname = next;
+		many = true;
+	} while (edidname);
+
+	if (edidname && *edidname != '\0') {
+		last = edidname + strlen(edidname) - 1;
+		if (*last == '\n')
+			*last = '\0';
+
+		if (strlen(edidname) > 0)
+			edid = edid_load(connector, edidname, connector_name);
 	}
 
-	last = edidname + strlen(edidname) - 1;
-	if (*last == '\n')
-		*last = '\0';
+	kfree(mem);
 
-	edid = edid_load(connector, edidname, connector_name);
 	if (IS_ERR_OR_NULL(edid))
 		return NULL;