Skip to content

Commit 8423895

Browse files
niklas88hdeller
authored andcommitted
video: Handle HAS_IOPORT dependencies
In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at compile time. We thus need to #ifdef functions and their callsites which unconditionally use these I/O accessors. In the include/video/vga.h these are conveniently all those functions with the vga_io_* prefix. Co-developed-by: Arnd Bergmann <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Niklas Schnelle <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 8400291 commit 8423895

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

include/video/vga.h

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,26 @@ struct vgastate {
197197
extern int save_vga(struct vgastate *state);
198198
extern int restore_vga(struct vgastate *state);
199199

200+
static inline unsigned char vga_mm_r (void __iomem *regbase, unsigned short port)
201+
{
202+
return readb (regbase + port);
203+
}
204+
205+
static inline void vga_mm_w (void __iomem *regbase, unsigned short port, unsigned char val)
206+
{
207+
writeb (val, regbase + port);
208+
}
209+
210+
static inline void vga_mm_w_fast (void __iomem *regbase, unsigned short port,
211+
unsigned char reg, unsigned char val)
212+
{
213+
writew (VGA_OUT16VAL (val, reg), regbase + port);
214+
}
215+
200216
/*
201217
* generic VGA port read/write
202218
*/
219+
#ifdef CONFIG_HAS_IOPORT
203220

204221
static inline unsigned char vga_io_r (unsigned short port)
205222
{
@@ -217,22 +234,6 @@ static inline void vga_io_w_fast (unsigned short port, unsigned char reg,
217234
outw(VGA_OUT16VAL (val, reg), port);
218235
}
219236

220-
static inline unsigned char vga_mm_r (void __iomem *regbase, unsigned short port)
221-
{
222-
return readb (regbase + port);
223-
}
224-
225-
static inline void vga_mm_w (void __iomem *regbase, unsigned short port, unsigned char val)
226-
{
227-
writeb (val, regbase + port);
228-
}
229-
230-
static inline void vga_mm_w_fast (void __iomem *regbase, unsigned short port,
231-
unsigned char reg, unsigned char val)
232-
{
233-
writew (VGA_OUT16VAL (val, reg), regbase + port);
234-
}
235-
236237
static inline unsigned char vga_r (void __iomem *regbase, unsigned short port)
237238
{
238239
if (regbase)
@@ -258,8 +259,25 @@ static inline void vga_w_fast (void __iomem *regbase, unsigned short port,
258259
else
259260
vga_io_w_fast (port, reg, val);
260261
}
262+
#else /* CONFIG_HAS_IOPORT */
263+
static inline unsigned char vga_r (void __iomem *regbase, unsigned short port)
264+
{
265+
return vga_mm_r (regbase, port);
266+
}
267+
268+
static inline void vga_w (void __iomem *regbase, unsigned short port, unsigned char val)
269+
{
270+
vga_mm_w (regbase, port, val);
271+
}
261272

262273

274+
static inline void vga_w_fast (void __iomem *regbase, unsigned short port,
275+
unsigned char reg, unsigned char val)
276+
{
277+
vga_mm_w_fast (regbase, port, reg, val);
278+
}
279+
#endif /* CONFIG_HAS_IOPORT */
280+
263281
/*
264282
* VGA CRTC register read/write
265283
*/
@@ -280,6 +298,7 @@ static inline void vga_wcrt (void __iomem *regbase, unsigned char reg, unsigned
280298
#endif /* VGA_OUTW_WRITE */
281299
}
282300

301+
#ifdef CONFIG_HAS_IOPORT
283302
static inline unsigned char vga_io_rcrt (unsigned char reg)
284303
{
285304
vga_io_w (VGA_CRT_IC, reg);
@@ -295,6 +314,7 @@ static inline void vga_io_wcrt (unsigned char reg, unsigned char val)
295314
vga_io_w (VGA_CRT_DC, val);
296315
#endif /* VGA_OUTW_WRITE */
297316
}
317+
#endif /* CONFIG_HAS_IOPORT */
298318

299319
static inline unsigned char vga_mm_rcrt (void __iomem *regbase, unsigned char reg)
300320
{
@@ -333,6 +353,7 @@ static inline void vga_wseq (void __iomem *regbase, unsigned char reg, unsigned
333353
#endif /* VGA_OUTW_WRITE */
334354
}
335355

356+
#ifdef CONFIG_HAS_IOPORT
336357
static inline unsigned char vga_io_rseq (unsigned char reg)
337358
{
338359
vga_io_w (VGA_SEQ_I, reg);
@@ -348,6 +369,7 @@ static inline void vga_io_wseq (unsigned char reg, unsigned char val)
348369
vga_io_w (VGA_SEQ_D, val);
349370
#endif /* VGA_OUTW_WRITE */
350371
}
372+
#endif /* CONFIG_HAS_IOPORT */
351373

352374
static inline unsigned char vga_mm_rseq (void __iomem *regbase, unsigned char reg)
353375
{
@@ -385,6 +407,7 @@ static inline void vga_wgfx (void __iomem *regbase, unsigned char reg, unsigned
385407
#endif /* VGA_OUTW_WRITE */
386408
}
387409

410+
#ifdef CONFIG_HAS_IOPORT
388411
static inline unsigned char vga_io_rgfx (unsigned char reg)
389412
{
390413
vga_io_w (VGA_GFX_I, reg);
@@ -400,6 +423,7 @@ static inline void vga_io_wgfx (unsigned char reg, unsigned char val)
400423
vga_io_w (VGA_GFX_D, val);
401424
#endif /* VGA_OUTW_WRITE */
402425
}
426+
#endif /* CONFIG_HAS_IOPORT */
403427

404428
static inline unsigned char vga_mm_rgfx (void __iomem *regbase, unsigned char reg)
405429
{
@@ -434,6 +458,7 @@ static inline void vga_wattr (void __iomem *regbase, unsigned char reg, unsigned
434458
vga_w (regbase, VGA_ATT_W, val);
435459
}
436460

461+
#ifdef CONFIG_HAS_IOPORT
437462
static inline unsigned char vga_io_rattr (unsigned char reg)
438463
{
439464
vga_io_w (VGA_ATT_IW, reg);
@@ -445,6 +470,7 @@ static inline void vga_io_wattr (unsigned char reg, unsigned char val)
445470
vga_io_w (VGA_ATT_IW, reg);
446471
vga_io_w (VGA_ATT_W, val);
447472
}
473+
#endif /* CONFIG_HAS_IOPORT */
448474

449475
static inline unsigned char vga_mm_rattr (void __iomem *regbase, unsigned char reg)
450476
{

0 commit comments

Comments
 (0)