Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da31de3

Browse files
viviergregkh
authored andcommitted
tty: goldfish: use __raw_writel()/__raw_readl()
gf_early_console_putchar() uses __raw_writel() but the standard driver uses writel()/readl(). This means we can't use both on the same machine as the device is either big-endian, little-endian or native-endian. As android implementation defines the endianness of the device is the one of the architecture replace all writel()/readl() by __raw_writel()/__raw_readl() https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/hw/char/goldfish_tty.c#222 Signed-off-by: Laurent Vivier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1a460c3 commit da31de3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/tty/goldfish.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ static void do_rw_io(struct goldfish_tty *qtty,
6161
spin_lock_irqsave(&qtty->lock, irq_flags);
6262
gf_write_ptr((void *)address, base + GOLDFISH_TTY_REG_DATA_PTR,
6363
base + GOLDFISH_TTY_REG_DATA_PTR_HIGH);
64-
writel(count, base + GOLDFISH_TTY_REG_DATA_LEN);
64+
__raw_writel(count, base + GOLDFISH_TTY_REG_DATA_LEN);
6565

6666
if (is_write)
67-
writel(GOLDFISH_TTY_CMD_WRITE_BUFFER,
67+
__raw_writel(GOLDFISH_TTY_CMD_WRITE_BUFFER,
6868
base + GOLDFISH_TTY_REG_CMD);
6969
else
70-
writel(GOLDFISH_TTY_CMD_READ_BUFFER,
70+
__raw_writel(GOLDFISH_TTY_CMD_READ_BUFFER,
7171
base + GOLDFISH_TTY_REG_CMD);
7272

7373
spin_unlock_irqrestore(&qtty->lock, irq_flags);
@@ -142,7 +142,7 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
142142
unsigned char *buf;
143143
u32 count;
144144

145-
count = readl(base + GOLDFISH_TTY_REG_BYTES_READY);
145+
count = __raw_readl(base + GOLDFISH_TTY_REG_BYTES_READY);
146146
if (count == 0)
147147
return IRQ_NONE;
148148

@@ -159,15 +159,15 @@ static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty)
159159
{
160160
struct goldfish_tty *qtty = container_of(port, struct goldfish_tty,
161161
port);
162-
writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_REG_CMD);
162+
__raw_writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_REG_CMD);
163163
return 0;
164164
}
165165

166166
static void goldfish_tty_shutdown(struct tty_port *port)
167167
{
168168
struct goldfish_tty *qtty = container_of(port, struct goldfish_tty,
169169
port);
170-
writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_REG_CMD);
170+
__raw_writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_REG_CMD);
171171
}
172172

173173
static int goldfish_tty_open(struct tty_struct *tty, struct file *filp)
@@ -202,7 +202,7 @@ static int goldfish_tty_chars_in_buffer(struct tty_struct *tty)
202202
{
203203
struct goldfish_tty *qtty = &goldfish_ttys[tty->index];
204204
void __iomem *base = qtty->base;
205-
return readl(base + GOLDFISH_TTY_REG_BYTES_READY);
205+
return __raw_readl(base + GOLDFISH_TTY_REG_BYTES_READY);
206206
}
207207

208208
static void goldfish_tty_console_write(struct console *co, const char *b,
@@ -357,7 +357,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
357357
* on Ranchu emulator (qemu2) returns 1 here and
358358
* driver will use physical addresses.
359359
*/
360-
qtty->version = readl(base + GOLDFISH_TTY_REG_VERSION);
360+
qtty->version = __raw_readl(base + GOLDFISH_TTY_REG_VERSION);
361361

362362
/*
363363
* Goldfish TTY device on Ranchu emulator (qemu2)
@@ -376,7 +376,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
376376
}
377377
}
378378

379-
writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_REG_CMD);
379+
__raw_writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_REG_CMD);
380380

381381
ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED,
382382
"goldfish_tty", qtty);

include/linux/goldfish.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
1313
{
1414
const unsigned long addr = (unsigned long)ptr;
1515

16-
writel(lower_32_bits(addr), portl);
16+
__raw_writel(lower_32_bits(addr), portl);
1717
#ifdef CONFIG_64BIT
18-
writel(upper_32_bits(addr), porth);
18+
__raw_writel(upper_32_bits(addr), porth);
1919
#endif
2020
}
2121

2222
static inline void gf_write_dma_addr(const dma_addr_t addr,
2323
void __iomem *portl,
2424
void __iomem *porth)
2525
{
26-
writel(lower_32_bits(addr), portl);
26+
__raw_writel(lower_32_bits(addr), portl);
2727
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
28-
writel(upper_32_bits(addr), porth);
28+
__raw_writel(upper_32_bits(addr), porth);
2929
#endif
3030
}
3131

0 commit comments

Comments
 (0)