diff mbox

[3/3] mdacon: replace MDA_ADDR macro by inline function

Message ID 20160725152440.6734-3-jslaby@suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Jiri Slaby July 25, 2016, 3:24 p.m. UTC
MDA_ADDR is one of those macros which could be an inline function. So
convert MDA_ADDR to mda_addr.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/video/console/mdacon.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Joe Perches July 25, 2016, 4:04 p.m. UTC | #1
On Mon, 2016-07-25 at 17:24 +0200, Jiri Slaby wrote:
> MDA_ADDR is one of those macros which could be an inline function. So
> convert MDA_ADDR to mda_addr.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  drivers/video/console/mdacon.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
> index 814606bd26d1..24fe55134eb5 100644
> --- a/drivers/video/console/mdacon.c
> +++ b/drivers/video/console/mdacon.c
> @@ -420,17 +420,20 @@ static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
>  	}
>  }
>  
> -#define MDA_ADDR(x, y)  (mda_vram_base + (y)*mda_num_columns + (x))
> +static inline u16 *mda_addr(unsigned int x, unsigned int y)

Are you sure about the unsigned?
All of the changed use are taking int

> +{
> +	return mda_vram_base + y * mda_num_columns + x;
> +}
>  
>  static void mdacon_putc(struct vc_data *c, int ch, int y, int x)
>  {
> -	scr_writew(mda_convert_attr(ch), MDA_ADDR(x, y));
> +	scr_writew(mda_convert_attr(ch), mda_addr(x, y));
>  }
>  
>  static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
>  		         int count, int y, int x)
>  {
> -	u16 *dest = MDA_ADDR(x, y);
> +	u16 *dest = mda_addr(x, y);
>  
>  	for (; count > 0; count--) {
>  		scr_writew(mda_convert_attr(scr_readw(s++)), dest++);
> @@ -440,7 +443,7 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
>  static void mdacon_clear(struct vc_data *c, int y, int x, 
>  			  int height, int width)
>  {
> -	u16 *dest = MDA_ADDR(x, y);
> +	u16 *dest = mda_addr(x, y);
>  	u16 eattr = mda_convert_attr(c->vc_video_erase_char);
>  
>  	if (width <= 0 || height <= 0)
> @@ -511,16 +514,16 @@ static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
>  	switch (dir) {
>  
>  	case SM_UP:
> -		scr_memmovew(MDA_ADDR(0,t), MDA_ADDR(0,t+lines),
> +		scr_memmovew(mda_addr(0, t), mda_addr(0, t + lines),
>  				(b-t-lines)*mda_num_columns*2);
> -		scr_memsetw(MDA_ADDR(0,b-lines), eattr,
> +		scr_memsetw(mda_addr(0, b - lines), eattr,
>  				lines*mda_num_columns*2);
>  		break;
>  
>  	case SM_DOWN:
> -		scr_memmovew(MDA_ADDR(0,t+lines), MDA_ADDR(0,t),
> +		scr_memmovew(mda_addr(0, t + lines), mda_addr(0, t),
>  				(b-t-lines)*mda_num_columns*2);
> -		scr_memsetw(MDA_ADDR(0,t), eattr, lines*mda_num_columns*2);
> +		scr_memsetw(mda_addr(0, t), eattr, lines*mda_num_columns*2);
>  		break;
>  	}
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Slaby July 29, 2016, 10:53 a.m. UTC | #2
On 07/25/2016, 06:04 PM, Joe Perches wrote:
> On Mon, 2016-07-25 at 17:24 +0200, Jiri Slaby wrote:
>> MDA_ADDR is one of those macros which could be an inline function. So
>> convert MDA_ADDR to mda_addr.
>>
>> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
>> ---
>>  drivers/video/console/mdacon.c | 19 +++++++++++--------
>>  1 file changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
>> index 814606bd26d1..24fe55134eb5 100644
>> --- a/drivers/video/console/mdacon.c
>> +++ b/drivers/video/console/mdacon.c
>> @@ -420,17 +420,20 @@ static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
>>  	}
>>  }
>>  
>> -#define MDA_ADDR(x, y)  (mda_vram_base + (y)*mda_num_columns + (x))
>> +static inline u16 *mda_addr(unsigned int x, unsigned int y)
> 
> Are you sure about the unsigned?
> All of the changed use are taking int

Yeah, they are really absolute x and y coordinates.

thanks,
diff mbox

Patch

diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 814606bd26d1..24fe55134eb5 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -420,17 +420,20 @@  static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
 	}
 }
 
-#define MDA_ADDR(x, y)  (mda_vram_base + (y)*mda_num_columns + (x))
+static inline u16 *mda_addr(unsigned int x, unsigned int y)
+{
+	return mda_vram_base + y * mda_num_columns + x;
+}
 
 static void mdacon_putc(struct vc_data *c, int ch, int y, int x)
 {
-	scr_writew(mda_convert_attr(ch), MDA_ADDR(x, y));
+	scr_writew(mda_convert_attr(ch), mda_addr(x, y));
 }
 
 static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
 		         int count, int y, int x)
 {
-	u16 *dest = MDA_ADDR(x, y);
+	u16 *dest = mda_addr(x, y);
 
 	for (; count > 0; count--) {
 		scr_writew(mda_convert_attr(scr_readw(s++)), dest++);
@@ -440,7 +443,7 @@  static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
 static void mdacon_clear(struct vc_data *c, int y, int x, 
 			  int height, int width)
 {
-	u16 *dest = MDA_ADDR(x, y);
+	u16 *dest = mda_addr(x, y);
 	u16 eattr = mda_convert_attr(c->vc_video_erase_char);
 
 	if (width <= 0 || height <= 0)
@@ -511,16 +514,16 @@  static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
 	switch (dir) {
 
 	case SM_UP:
-		scr_memmovew(MDA_ADDR(0,t), MDA_ADDR(0,t+lines),
+		scr_memmovew(mda_addr(0, t), mda_addr(0, t + lines),
 				(b-t-lines)*mda_num_columns*2);
-		scr_memsetw(MDA_ADDR(0,b-lines), eattr,
+		scr_memsetw(mda_addr(0, b - lines), eattr,
 				lines*mda_num_columns*2);
 		break;
 
 	case SM_DOWN:
-		scr_memmovew(MDA_ADDR(0,t+lines), MDA_ADDR(0,t),
+		scr_memmovew(mda_addr(0, t + lines), mda_addr(0, t),
 				(b-t-lines)*mda_num_columns*2);
-		scr_memsetw(MDA_ADDR(0,t), eattr, lines*mda_num_columns*2);
+		scr_memsetw(mda_addr(0, t), eattr, lines*mda_num_columns*2);
 		break;
 	}