diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2011-03-03 12:59:01 -0500 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2011-03-09 12:04:12 -0500 |
commit | b65d6040e3a7cd75d9287f7ddfd115e85fde4b44 (patch) | |
tree | 398b234ea6b9501a2e9ab271c687787fa6befaf8 /drivers/video/via | |
parent | a625e305edd8e3ac08888a9b52981205b68cdb0e (diff) |
video via: fix iomem access
This driver is not respecting the iomem memory space restrictions
and does direct access. This works on x86 but is non-portable and
should not be done. Converted memcpy() of 2 to readw.
Last post increment of romptr was unnecessary since pointer never
used after that.
Found by sparse, compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/via')
-rw-r--r-- | drivers/video/via/lcd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c index 3425c3969806..723fa04b303f 100644 --- a/drivers/video/via/lcd.c +++ b/drivers/video/via/lcd.c | |||
@@ -1064,34 +1064,33 @@ static struct display_timing lcd_centering_timging(struct display_timing | |||
1064 | 1064 | ||
1065 | bool viafb_lcd_get_mobile_state(bool *mobile) | 1065 | bool viafb_lcd_get_mobile_state(bool *mobile) |
1066 | { | 1066 | { |
1067 | unsigned char *romptr, *tableptr; | 1067 | unsigned char __iomem *romptr, *tableptr, *biosptr; |
1068 | u8 core_base; | 1068 | u8 core_base; |
1069 | unsigned char *biosptr; | ||
1070 | /* Rom address */ | 1069 | /* Rom address */ |
1071 | u32 romaddr = 0x000C0000; | 1070 | const u32 romaddr = 0x000C0000; |
1072 | u16 start_pattern = 0; | 1071 | u16 start_pattern; |
1073 | 1072 | ||
1074 | biosptr = ioremap(romaddr, 0x10000); | 1073 | biosptr = ioremap(romaddr, 0x10000); |
1074 | start_pattern = readw(biosptr); | ||
1075 | 1075 | ||
1076 | memcpy(&start_pattern, biosptr, 2); | ||
1077 | /* Compare pattern */ | 1076 | /* Compare pattern */ |
1078 | if (start_pattern == 0xAA55) { | 1077 | if (start_pattern == 0xAA55) { |
1079 | /* Get the start of Table */ | 1078 | /* Get the start of Table */ |
1080 | /* 0x1B means BIOS offset position */ | 1079 | /* 0x1B means BIOS offset position */ |
1081 | romptr = biosptr + 0x1B; | 1080 | romptr = biosptr + 0x1B; |
1082 | tableptr = biosptr + *((u16 *) romptr); | 1081 | tableptr = biosptr + readw(romptr); |
1083 | 1082 | ||
1084 | /* Get the start of biosver structure */ | 1083 | /* Get the start of biosver structure */ |
1085 | /* 18 means BIOS version position. */ | 1084 | /* 18 means BIOS version position. */ |
1086 | romptr = tableptr + 18; | 1085 | romptr = tableptr + 18; |
1087 | romptr = biosptr + *((u16 *) romptr); | 1086 | romptr = biosptr + readw(romptr); |
1088 | 1087 | ||
1089 | /* The offset should be 44, but the | 1088 | /* The offset should be 44, but the |
1090 | actual image is less three char. */ | 1089 | actual image is less three char. */ |
1091 | /* pRom += 44; */ | 1090 | /* pRom += 44; */ |
1092 | romptr += 41; | 1091 | romptr += 41; |
1093 | 1092 | ||
1094 | core_base = *romptr++; | 1093 | core_base = readb(romptr); |
1095 | 1094 | ||
1096 | if (core_base & 0x8) | 1095 | if (core_base & 0x8) |
1097 | *mobile = false; | 1096 | *mobile = false; |