diff mbox series

[06/12] drm/edid: add typedef for block read function

Message ID 94e414efe8d127f3fd0b4fd7948aafbe7be079a9.1649322799.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: low level EDID block read refactoring etc. | expand

Commit Message

Jani Nikula April 7, 2022, 9:14 a.m. UTC
Make the callback a bit easier on the eye.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Ville Syrjälä April 7, 2022, 12:06 p.m. UTC | #1
On Thu, Apr 07, 2022 at 12:14:32PM +0300, Jani Nikula wrote:
> Make the callback a bit easier on the eye.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index ba54701f91f6..926ffe5cd97e 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2037,10 +2037,11 @@ int drm_add_override_edid_modes(struct drm_connector *connector)
>  }
>  EXPORT_SYMBOL(drm_add_override_edid_modes);
>  
> +typedef int read_block_fn(void *context, u8 *buf, unsigned int block, size_t len);
> +

The header still has the eyesore. Maybe we want to put the typedef
there?

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
> -	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
> -			      size_t len),
> -	void *data)
> +					       read_block_fn read_block,
> +					       void *context)
>  {
>  	int *null_edid_counter = connector ? &connector->null_edid_counter : NULL;
>  	bool *edid_corrupt = connector ? &connector->edid_corrupt : NULL;
> @@ -2053,7 +2054,7 @@ static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
>  
>  	/* base block fetch */
>  	for (try = 0; try < 4; try++) {
> -		if (get_edid_block(data, edid, 0, EDID_LENGTH))
> +		if (read_block(context, edid, 0, EDID_LENGTH))
>  			goto out;
>  		if (drm_edid_block_valid(edid, 0, false, edid_corrupt))
>  			break;
> @@ -2097,9 +2098,8 @@ static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
>   * Return: Pointer to valid EDID or NULL if we couldn't find any.
>   */
>  struct edid *drm_do_get_edid(struct drm_connector *connector,
> -	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
> -			      size_t len),
> -	void *data)
> +			     read_block_fn read_block,
> +			     void *context)
>  {
>  	int j, invalid_blocks = 0;
>  	struct edid *edid, *new, *override;
> @@ -2108,7 +2108,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>  	if (override)
>  		return override;
>  
> -	edid = drm_do_get_edid_base_block(connector, get_edid_block, data);
> +	edid = drm_do_get_edid_base_block(connector, read_block, context);
>  	if (!edid)
>  		return NULL;
>  
> @@ -2125,7 +2125,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>  		int try;
>  
>  		for (try = 0; try < 4; try++) {
> -			if (get_edid_block(data, block, j, EDID_LENGTH))
> +			if (read_block(context, block, j, EDID_LENGTH))
>  				goto out;
>  			if (drm_edid_block_valid(block, j, false, NULL))
>  				break;
> -- 
> 2.30.2
Jani Nikula April 11, 2022, 9:48 a.m. UTC | #2
On Thu, 07 Apr 2022, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Thu, Apr 07, 2022 at 12:14:32PM +0300, Jani Nikula wrote:
>> Make the callback a bit easier on the eye.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/drm_edid.c | 18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>> index ba54701f91f6..926ffe5cd97e 100644
>> --- a/drivers/gpu/drm/drm_edid.c
>> +++ b/drivers/gpu/drm/drm_edid.c
>> @@ -2037,10 +2037,11 @@ int drm_add_override_edid_modes(struct drm_connector *connector)
>>  }
>>  EXPORT_SYMBOL(drm_add_override_edid_modes);
>>  
>> +typedef int read_block_fn(void *context, u8 *buf, unsigned int block, size_t len);
>> +
>
> The header still has the eyesore. Maybe we want to put the typedef
> there?

Decided to leave that for the future, possibly with a s/u8*/void*/
change.

Thanks,
Jani.


>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>>  static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
>> -	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
>> -			      size_t len),
>> -	void *data)
>> +					       read_block_fn read_block,
>> +					       void *context)
>>  {
>>  	int *null_edid_counter = connector ? &connector->null_edid_counter : NULL;
>>  	bool *edid_corrupt = connector ? &connector->edid_corrupt : NULL;
>> @@ -2053,7 +2054,7 @@ static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
>>  
>>  	/* base block fetch */
>>  	for (try = 0; try < 4; try++) {
>> -		if (get_edid_block(data, edid, 0, EDID_LENGTH))
>> +		if (read_block(context, edid, 0, EDID_LENGTH))
>>  			goto out;
>>  		if (drm_edid_block_valid(edid, 0, false, edid_corrupt))
>>  			break;
>> @@ -2097,9 +2098,8 @@ static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
>>   * Return: Pointer to valid EDID or NULL if we couldn't find any.
>>   */
>>  struct edid *drm_do_get_edid(struct drm_connector *connector,
>> -	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
>> -			      size_t len),
>> -	void *data)
>> +			     read_block_fn read_block,
>> +			     void *context)
>>  {
>>  	int j, invalid_blocks = 0;
>>  	struct edid *edid, *new, *override;
>> @@ -2108,7 +2108,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>>  	if (override)
>>  		return override;
>>  
>> -	edid = drm_do_get_edid_base_block(connector, get_edid_block, data);
>> +	edid = drm_do_get_edid_base_block(connector, read_block, context);
>>  	if (!edid)
>>  		return NULL;
>>  
>> @@ -2125,7 +2125,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
>>  		int try;
>>  
>>  		for (try = 0; try < 4; try++) {
>> -			if (get_edid_block(data, block, j, EDID_LENGTH))
>> +			if (read_block(context, block, j, EDID_LENGTH))
>>  				goto out;
>>  			if (drm_edid_block_valid(block, j, false, NULL))
>>  				break;
>> -- 
>> 2.30.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index ba54701f91f6..926ffe5cd97e 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2037,10 +2037,11 @@  int drm_add_override_edid_modes(struct drm_connector *connector)
 }
 EXPORT_SYMBOL(drm_add_override_edid_modes);
 
+typedef int read_block_fn(void *context, u8 *buf, unsigned int block, size_t len);
+
 static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
-	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
-			      size_t len),
-	void *data)
+					       read_block_fn read_block,
+					       void *context)
 {
 	int *null_edid_counter = connector ? &connector->null_edid_counter : NULL;
 	bool *edid_corrupt = connector ? &connector->edid_corrupt : NULL;
@@ -2053,7 +2054,7 @@  static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
 
 	/* base block fetch */
 	for (try = 0; try < 4; try++) {
-		if (get_edid_block(data, edid, 0, EDID_LENGTH))
+		if (read_block(context, edid, 0, EDID_LENGTH))
 			goto out;
 		if (drm_edid_block_valid(edid, 0, false, edid_corrupt))
 			break;
@@ -2097,9 +2098,8 @@  static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
  * Return: Pointer to valid EDID or NULL if we couldn't find any.
  */
 struct edid *drm_do_get_edid(struct drm_connector *connector,
-	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
-			      size_t len),
-	void *data)
+			     read_block_fn read_block,
+			     void *context)
 {
 	int j, invalid_blocks = 0;
 	struct edid *edid, *new, *override;
@@ -2108,7 +2108,7 @@  struct edid *drm_do_get_edid(struct drm_connector *connector,
 	if (override)
 		return override;
 
-	edid = drm_do_get_edid_base_block(connector, get_edid_block, data);
+	edid = drm_do_get_edid_base_block(connector, read_block, context);
 	if (!edid)
 		return NULL;
 
@@ -2125,7 +2125,7 @@  struct edid *drm_do_get_edid(struct drm_connector *connector,
 		int try;
 
 		for (try = 0; try < 4; try++) {
-			if (get_edid_block(data, block, j, EDID_LENGTH))
+			if (read_block(context, block, j, EDID_LENGTH))
 				goto out;
 			if (drm_edid_block_valid(block, j, false, NULL))
 				break;