aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2016-06-23 07:34:32 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-25 12:04:48 -0400
commit0f91e14264cb04c90987206f30d97385eef121c9 (patch)
treedf4ed6698a84a302263bd014b86b33d7631b65e3 /drivers/tty/vt
parente05ab238e30572abbac0cc4aba051553928de949 (diff)
tty: vt, do not pass structure over stack
The compiler noticed passing structure over stack. Even though rgb is a small structure, let us define one and pass that over all the functions wherever needed. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/vt.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index da49f5cfa654..63972336de20 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1240,36 +1240,34 @@ static void default_attr(struct vc_data *vc)
1240 1240
1241struct rgb { u8 r; u8 g; u8 b; }; 1241struct rgb { u8 r; u8 g; u8 b; };
1242 1242
1243static struct rgb rgb_from_256(int i) 1243static void rgb_from_256(int i, struct rgb *c)
1244{ 1244{
1245 struct rgb c;
1246 if (i < 8) { /* Standard colours. */ 1245 if (i < 8) { /* Standard colours. */
1247 c.r = i&1 ? 0xaa : 0x00; 1246 c->r = i&1 ? 0xaa : 0x00;
1248 c.g = i&2 ? 0xaa : 0x00; 1247 c->g = i&2 ? 0xaa : 0x00;
1249 c.b = i&4 ? 0xaa : 0x00; 1248 c->b = i&4 ? 0xaa : 0x00;
1250 } else if (i < 16) { 1249 } else if (i < 16) {
1251 c.r = i&1 ? 0xff : 0x55; 1250 c->r = i&1 ? 0xff : 0x55;
1252 c.g = i&2 ? 0xff : 0x55; 1251 c->g = i&2 ? 0xff : 0x55;
1253 c.b = i&4 ? 0xff : 0x55; 1252 c->b = i&4 ? 0xff : 0x55;
1254 } else if (i < 232) { /* 6x6x6 colour cube. */ 1253 } else if (i < 232) { /* 6x6x6 colour cube. */
1255 c.r = (i - 16) / 36 * 85 / 2; 1254 c->r = (i - 16) / 36 * 85 / 2;
1256 c.g = (i - 16) / 6 % 6 * 85 / 2; 1255 c->g = (i - 16) / 6 % 6 * 85 / 2;
1257 c.b = (i - 16) % 6 * 85 / 2; 1256 c->b = (i - 16) % 6 * 85 / 2;
1258 } else /* Grayscale ramp. */ 1257 } else /* Grayscale ramp. */
1259 c.r = c.g = c.b = i * 10 - 2312; 1258 c->r = c->g = c->b = i * 10 - 2312;
1260 return c;
1261} 1259}
1262 1260
1263static void rgb_foreground(struct vc_data *vc, struct rgb c) 1261static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
1264{ 1262{
1265 u8 hue, max = c.r; 1263 u8 hue, max = c->r;
1266 if (c.g > max) 1264 if (c->g > max)
1267 max = c.g; 1265 max = c->g;
1268 if (c.b > max) 1266 if (c->b > max)
1269 max = c.b; 1267 max = c->b;
1270 hue = (c.r > max/2 ? 4 : 0) 1268 hue = (c->r > max/2 ? 4 : 0)
1271 | (c.g > max/2 ? 2 : 0) 1269 | (c->g > max/2 ? 2 : 0)
1272 | (c.b > max/2 ? 1 : 0); 1270 | (c->b > max/2 ? 1 : 0);
1273 if (hue == 7 && max <= 0x55) 1271 if (hue == 7 && max <= 0x55)
1274 hue = 0, vc->vc_intensity = 2; 1272 hue = 0, vc->vc_intensity = 2;
1275 else 1273 else
@@ -1277,11 +1275,11 @@ static void rgb_foreground(struct vc_data *vc, struct rgb c)
1277 vc->vc_color = (vc->vc_color & 0xf0) | hue; 1275 vc->vc_color = (vc->vc_color & 0xf0) | hue;
1278} 1276}
1279 1277
1280static void rgb_background(struct vc_data *vc, struct rgb c) 1278static void rgb_background(struct vc_data *vc, const struct rgb *c)
1281{ 1279{
1282 /* For backgrounds, err on the dark side. */ 1280 /* For backgrounds, err on the dark side. */
1283 vc->vc_color = (vc->vc_color & 0x0f) 1281 vc->vc_color = (vc->vc_color & 0x0f)
1284 | (c.r&0x80) >> 1 | (c.g&0x80) >> 2 | (c.b&0x80) >> 3; 1282 | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3;
1285} 1283}
1286 1284
1287/* 1285/*
@@ -1294,8 +1292,10 @@ static void rgb_background(struct vc_data *vc, struct rgb c)
1294 * supporting them. 1292 * supporting them.
1295 */ 1293 */
1296static int vc_t416_color(struct vc_data *vc, int i, 1294static int vc_t416_color(struct vc_data *vc, int i,
1297 void(*set_color)(struct vc_data *vc, struct rgb c)) 1295 void(*set_color)(struct vc_data *vc, const struct rgb *c))
1298{ 1296{
1297 struct rgb c;
1298
1299 i++; 1299 i++;
1300 if (i > vc->vc_npar) 1300 if (i > vc->vc_npar)
1301 return i; 1301 return i;
@@ -1303,17 +1303,17 @@ static int vc_t416_color(struct vc_data *vc, int i,
1303 if (vc->vc_par[i] == 5 && i < vc->vc_npar) { 1303 if (vc->vc_par[i] == 5 && i < vc->vc_npar) {
1304 /* 256 colours -- ubiquitous */ 1304 /* 256 colours -- ubiquitous */
1305 i++; 1305 i++;
1306 set_color(vc, rgb_from_256(vc->vc_par[i])); 1306 rgb_from_256(vc->vc_par[i], &c);
1307 } else if (vc->vc_par[i] == 2 && i <= vc->vc_npar + 3) { 1307 } else if (vc->vc_par[i] == 2 && i <= vc->vc_npar + 3) {
1308 /* 24 bit -- extremely rare */ 1308 /* 24 bit -- extremely rare */
1309 struct rgb c = { 1309 c.r = vc->vc_par[i + 1];
1310 .r = vc->vc_par[i + 1], 1310 c.g = vc->vc_par[i + 2];
1311 .g = vc->vc_par[i + 2], 1311 c.b = vc->vc_par[i + 3];
1312 .b = vc->vc_par[i + 3],
1313 };
1314 set_color(vc, c);
1315 i += 3; 1312 i += 3;
1316 } 1313 } else
1314 return i;
1315
1316 set_color(vc, &c);
1317 1317
1318 return i; 1318 return i;
1319} 1319}