Skip to content

Commit 8c4e378

Browse files
committed
Merge tag 'staging-4.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging fixes from Greg KH: "Here are some small staging driver fixes for 4.5-rc2. One of them predated 4.4-final, but I missed that merge window due to the holliday. The others fix reported issues that have come up recently. The tty change is needed for the speakup driver fix and has the ack of the tty driver maintainer as well, i.e. myself :) All have been in linux-next with no reported issues" * tag 'staging-4.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: Staging: speakup: fix read scrolled-back VT Staging: speakup: Fix getting port information Revert "Staging: panel: usleep_range is preferred over udelay" iio: adis_buffer: Fix out-of-bounds memory access
2 parents f3ca903 + 88867e3 commit 8c4e378

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

drivers/iio/imu/adis_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
4343
return -ENOMEM;
4444

4545
rx = adis->buffer;
46-
tx = rx + indio_dev->scan_bytes;
46+
tx = rx + scan_count;
4747

4848
spi_message_init(&adis->msg);
4949

drivers/staging/panel/panel.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,7 @@ static void lcd_write_cmd_s(int cmd)
825825
lcd_send_serial(0x1F); /* R/W=W, RS=0 */
826826
lcd_send_serial(cmd & 0x0F);
827827
lcd_send_serial((cmd >> 4) & 0x0F);
828-
/* the shortest command takes at least 40 us */
829-
usleep_range(40, 100);
828+
udelay(40); /* the shortest command takes at least 40 us */
830829
spin_unlock_irq(&pprt_lock);
831830
}
832831

@@ -837,8 +836,7 @@ static void lcd_write_data_s(int data)
837836
lcd_send_serial(0x5F); /* R/W=W, RS=1 */
838837
lcd_send_serial(data & 0x0F);
839838
lcd_send_serial((data >> 4) & 0x0F);
840-
/* the shortest data takes at least 40 us */
841-
usleep_range(40, 100);
839+
udelay(40); /* the shortest data takes at least 40 us */
842840
spin_unlock_irq(&pprt_lock);
843841
}
844842

@@ -848,20 +846,19 @@ static void lcd_write_cmd_p8(int cmd)
848846
spin_lock_irq(&pprt_lock);
849847
/* present the data to the data port */
850848
w_dtr(pprt, cmd);
851-
/* maintain the data during 20 us before the strobe */
852-
usleep_range(20, 100);
849+
udelay(20); /* maintain the data during 20 us before the strobe */
853850

854851
bits.e = BIT_SET;
855852
bits.rs = BIT_CLR;
856853
bits.rw = BIT_CLR;
857854
set_ctrl_bits();
858855

859-
usleep_range(40, 100); /* maintain the strobe during 40 us */
856+
udelay(40); /* maintain the strobe during 40 us */
860857

861858
bits.e = BIT_CLR;
862859
set_ctrl_bits();
863860

864-
usleep_range(120, 500); /* the shortest command takes at least 120 us */
861+
udelay(120); /* the shortest command takes at least 120 us */
865862
spin_unlock_irq(&pprt_lock);
866863
}
867864

@@ -871,20 +868,19 @@ static void lcd_write_data_p8(int data)
871868
spin_lock_irq(&pprt_lock);
872869
/* present the data to the data port */
873870
w_dtr(pprt, data);
874-
/* maintain the data during 20 us before the strobe */
875-
usleep_range(20, 100);
871+
udelay(20); /* maintain the data during 20 us before the strobe */
876872

877873
bits.e = BIT_SET;
878874
bits.rs = BIT_SET;
879875
bits.rw = BIT_CLR;
880876
set_ctrl_bits();
881877

882-
usleep_range(40, 100); /* maintain the strobe during 40 us */
878+
udelay(40); /* maintain the strobe during 40 us */
883879

884880
bits.e = BIT_CLR;
885881
set_ctrl_bits();
886882

887-
usleep_range(45, 100); /* the shortest data takes at least 45 us */
883+
udelay(45); /* the shortest data takes at least 45 us */
888884
spin_unlock_irq(&pprt_lock);
889885
}
890886

@@ -894,7 +890,7 @@ static void lcd_write_cmd_tilcd(int cmd)
894890
spin_lock_irq(&pprt_lock);
895891
/* present the data to the control port */
896892
w_ctr(pprt, cmd);
897-
usleep_range(60, 120);
893+
udelay(60);
898894
spin_unlock_irq(&pprt_lock);
899895
}
900896

@@ -904,7 +900,7 @@ static void lcd_write_data_tilcd(int data)
904900
spin_lock_irq(&pprt_lock);
905901
/* present the data to the data port */
906902
w_dtr(pprt, data);
907-
usleep_range(60, 120);
903+
udelay(60);
908904
spin_unlock_irq(&pprt_lock);
909905
}
910906

@@ -947,7 +943,7 @@ static void lcd_clear_fast_s(void)
947943
lcd_send_serial(0x5F); /* R/W=W, RS=1 */
948944
lcd_send_serial(' ' & 0x0F);
949945
lcd_send_serial((' ' >> 4) & 0x0F);
950-
usleep_range(40, 100); /* the shortest data takes at least 40 us */
946+
udelay(40); /* the shortest data takes at least 40 us */
951947
}
952948
spin_unlock_irq(&pprt_lock);
953949

@@ -971,21 +967,21 @@ static void lcd_clear_fast_p8(void)
971967
w_dtr(pprt, ' ');
972968

973969
/* maintain the data during 20 us before the strobe */
974-
usleep_range(20, 100);
970+
udelay(20);
975971

976972
bits.e = BIT_SET;
977973
bits.rs = BIT_SET;
978974
bits.rw = BIT_CLR;
979975
set_ctrl_bits();
980976

981977
/* maintain the strobe during 40 us */
982-
usleep_range(40, 100);
978+
udelay(40);
983979

984980
bits.e = BIT_CLR;
985981
set_ctrl_bits();
986982

987983
/* the shortest data takes at least 45 us */
988-
usleep_range(45, 100);
984+
udelay(45);
989985
}
990986
spin_unlock_irq(&pprt_lock);
991987

@@ -1007,7 +1003,7 @@ static void lcd_clear_fast_tilcd(void)
10071003
for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
10081004
/* present the data to the data port */
10091005
w_dtr(pprt, ' ');
1010-
usleep_range(60, 120);
1006+
udelay(60);
10111007
}
10121008

10131009
spin_unlock_irq(&pprt_lock);

drivers/staging/speakup/main.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ static struct notifier_block vt_notifier_block = {
264264
.notifier_call = vt_notifier_call,
265265
};
266266

267-
static unsigned char get_attributes(u16 *pos)
267+
static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
268268
{
269+
pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
269270
return (u_char) (scr_readw(pos) >> 8);
270271
}
271272

@@ -275,7 +276,7 @@ static void speakup_date(struct vc_data *vc)
275276
spk_y = spk_cy = vc->vc_y;
276277
spk_pos = spk_cp = vc->vc_pos;
277278
spk_old_attr = spk_attr;
278-
spk_attr = get_attributes((u_short *) spk_pos);
279+
spk_attr = get_attributes(vc, (u_short *)spk_pos);
279280
}
280281

281282
static void bleep(u_short val)
@@ -469,8 +470,12 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs)
469470
u16 ch = ' ';
470471

471472
if (vc && pos) {
472-
u16 w = scr_readw(pos);
473-
u16 c = w & 0xff;
473+
u16 w;
474+
u16 c;
475+
476+
pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
477+
w = scr_readw(pos);
478+
c = w & 0xff;
474479

475480
if (w & vc->vc_hi_font_mask)
476481
c |= 0x100;
@@ -746,7 +751,7 @@ static int get_line(struct vc_data *vc)
746751
u_char tmp2;
747752

748753
spk_old_attr = spk_attr;
749-
spk_attr = get_attributes((u_short *) spk_pos);
754+
spk_attr = get_attributes(vc, (u_short *)spk_pos);
750755
for (i = 0; i < vc->vc_cols; i++) {
751756
buf[i] = (u_char) get_char(vc, (u_short *) tmp, &tmp2);
752757
tmp += 2;
@@ -811,7 +816,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to,
811816
u_short saved_punc_mask = spk_punc_mask;
812817

813818
spk_old_attr = spk_attr;
814-
spk_attr = get_attributes((u_short *) from);
819+
spk_attr = get_attributes(vc, (u_short *)from);
815820
while (from < to) {
816821
buf[i++] = (char)get_char(vc, (u_short *) from, &tmp);
817822
from += 2;
@@ -886,7 +891,7 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc)
886891
sentmarks[bn][0] = &sentbuf[bn][0];
887892
i = 0;
888893
spk_old_attr = spk_attr;
889-
spk_attr = get_attributes((u_short *) start);
894+
spk_attr = get_attributes(vc, (u_short *)start);
890895

891896
while (start < end) {
892897
sentbuf[bn][i] = (char)get_char(vc, (u_short *) start, &tmp);
@@ -1585,7 +1590,7 @@ static int count_highlight_color(struct vc_data *vc)
15851590
u16 *ptr;
15861591

15871592
for (ptr = start; ptr < end; ptr++) {
1588-
ch = get_attributes(ptr);
1593+
ch = get_attributes(vc, ptr);
15891594
bg = (ch & 0x70) >> 4;
15901595
speakup_console[vc_num]->ht.bgcount[bg]++;
15911596
}

drivers/staging/speakup/serialio.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "spk_priv.h"
77
#include "serialio.h"
88

9+
#include <linux/serial_core.h>
10+
/* WARNING: Do not change this to <linux/serial.h> without testing that
11+
* SERIAL_PORT_DFNS does get defined to the appropriate value. */
12+
#include <asm/serial.h>
13+
914
#ifndef SERIAL_PORT_DFNS
1015
#define SERIAL_PORT_DFNS
1116
#endif
@@ -23,9 +28,15 @@ const struct old_serial_port *spk_serial_init(int index)
2328
int baud = 9600, quot = 0;
2429
unsigned int cval = 0;
2530
int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
26-
const struct old_serial_port *ser = rs_table + index;
31+
const struct old_serial_port *ser;
2732
int err;
2833

34+
if (index >= ARRAY_SIZE(rs_table)) {
35+
pr_info("no port info for ttyS%d\n", index);
36+
return NULL;
37+
}
38+
ser = rs_table + index;
39+
2940
/* Divisor, bytesize and parity */
3041
quot = ser->baud_base / baud;
3142
cval = cflag & (CSIZE | CSTOPB);

drivers/tty/vt/vt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,7 @@ unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed)
42504250
{
42514251
return screenpos(vc, 2 * w_offset, viewed);
42524252
}
4253+
EXPORT_SYMBOL_GPL(screen_pos);
42534254

42544255
void getconsxy(struct vc_data *vc, unsigned char *p)
42554256
{

0 commit comments

Comments
 (0)