Skip to content

Commit 8f28ca6

Browse files
krzktorvalds
authored andcommitted
iomap: constify ioreadX() iomem argument (as in generic implementation)
Patch series "iomap: Constify ioreadX() iomem argument", v3. The ioread8/16/32() and others have inconsistent interface among the architectures: some taking address as const, some not. It seems there is nothing really stopping all of them to take pointer to const. This patch (of 4): The ioreadX() and ioreadX_rep() helpers have inconsistent interface. On some architectures void *__iomem address argument is a pointer to const, on some not. Implementations of ioreadX() do not modify the memory under the address so they can be converted to a "const" version for const-safety and consistency among architectures. [[email protected]: sh: clk: fix assignment from incompatible pointer type for ioreadX()] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: fix drivers/mailbox/bcm-pdc-mailbox.c] Link: http://lkml.kernel.org/r/202007132209.Rxmv4QyS%[email protected] Suggested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Helge Deller <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Yoshinori Sato <[email protected]> Cc: Rich Felker <[email protected]> Cc: Kalle Valo <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Jon Mason <[email protected]> Cc: Allen Hubbe <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Jason Wang <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent f9e7ff9 commit 8f28ca6

File tree

22 files changed

+138
-138
lines changed

22 files changed

+138
-138
lines changed

arch/alpha/include/asm/core_apecs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct el_apecs_procdata
384384
} \
385385
} while (0)
386386

387-
__EXTERN_INLINE unsigned int apecs_ioread8(void __iomem *xaddr)
387+
__EXTERN_INLINE unsigned int apecs_ioread8(const void __iomem *xaddr)
388388
{
389389
unsigned long addr = (unsigned long) xaddr;
390390
unsigned long result, base_and_type;
@@ -420,7 +420,7 @@ __EXTERN_INLINE void apecs_iowrite8(u8 b, void __iomem *xaddr)
420420
*(vuip) ((addr << 5) + base_and_type) = w;
421421
}
422422

423-
__EXTERN_INLINE unsigned int apecs_ioread16(void __iomem *xaddr)
423+
__EXTERN_INLINE unsigned int apecs_ioread16(const void __iomem *xaddr)
424424
{
425425
unsigned long addr = (unsigned long) xaddr;
426426
unsigned long result, base_and_type;
@@ -456,7 +456,7 @@ __EXTERN_INLINE void apecs_iowrite16(u16 b, void __iomem *xaddr)
456456
*(vuip) ((addr << 5) + base_and_type) = w;
457457
}
458458

459-
__EXTERN_INLINE unsigned int apecs_ioread32(void __iomem *xaddr)
459+
__EXTERN_INLINE unsigned int apecs_ioread32(const void __iomem *xaddr)
460460
{
461461
unsigned long addr = (unsigned long) xaddr;
462462
if (addr < APECS_DENSE_MEM)

arch/alpha/include/asm/core_cia.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct el_CIA_sysdata_mcheck {
342342
#define vuip volatile unsigned int __force *
343343
#define vulp volatile unsigned long __force *
344344

345-
__EXTERN_INLINE unsigned int cia_ioread8(void __iomem *xaddr)
345+
__EXTERN_INLINE unsigned int cia_ioread8(const void __iomem *xaddr)
346346
{
347347
unsigned long addr = (unsigned long) xaddr;
348348
unsigned long result, base_and_type;
@@ -374,7 +374,7 @@ __EXTERN_INLINE void cia_iowrite8(u8 b, void __iomem *xaddr)
374374
*(vuip) ((addr << 5) + base_and_type) = w;
375375
}
376376

377-
__EXTERN_INLINE unsigned int cia_ioread16(void __iomem *xaddr)
377+
__EXTERN_INLINE unsigned int cia_ioread16(const void __iomem *xaddr)
378378
{
379379
unsigned long addr = (unsigned long) xaddr;
380380
unsigned long result, base_and_type;
@@ -404,7 +404,7 @@ __EXTERN_INLINE void cia_iowrite16(u16 b, void __iomem *xaddr)
404404
*(vuip) ((addr << 5) + base_and_type) = w;
405405
}
406406

407-
__EXTERN_INLINE unsigned int cia_ioread32(void __iomem *xaddr)
407+
__EXTERN_INLINE unsigned int cia_ioread32(const void __iomem *xaddr)
408408
{
409409
unsigned long addr = (unsigned long) xaddr;
410410
if (addr < CIA_DENSE_MEM)

arch/alpha/include/asm/core_lca.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ union el_lca {
230230
} while (0)
231231

232232

233-
__EXTERN_INLINE unsigned int lca_ioread8(void __iomem *xaddr)
233+
__EXTERN_INLINE unsigned int lca_ioread8(const void __iomem *xaddr)
234234
{
235235
unsigned long addr = (unsigned long) xaddr;
236236
unsigned long result, base_and_type;
@@ -266,7 +266,7 @@ __EXTERN_INLINE void lca_iowrite8(u8 b, void __iomem *xaddr)
266266
*(vuip) ((addr << 5) + base_and_type) = w;
267267
}
268268

269-
__EXTERN_INLINE unsigned int lca_ioread16(void __iomem *xaddr)
269+
__EXTERN_INLINE unsigned int lca_ioread16(const void __iomem *xaddr)
270270
{
271271
unsigned long addr = (unsigned long) xaddr;
272272
unsigned long result, base_and_type;
@@ -302,7 +302,7 @@ __EXTERN_INLINE void lca_iowrite16(u16 b, void __iomem *xaddr)
302302
*(vuip) ((addr << 5) + base_and_type) = w;
303303
}
304304

305-
__EXTERN_INLINE unsigned int lca_ioread32(void __iomem *xaddr)
305+
__EXTERN_INLINE unsigned int lca_ioread32(const void __iomem *xaddr)
306306
{
307307
unsigned long addr = (unsigned long) xaddr;
308308
if (addr < LCA_DENSE_MEM)

arch/alpha/include/asm/core_marvel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ struct io7 {
332332
#define vucp volatile unsigned char __force *
333333
#define vusp volatile unsigned short __force *
334334

335-
extern unsigned int marvel_ioread8(void __iomem *);
335+
extern unsigned int marvel_ioread8(const void __iomem *);
336336
extern void marvel_iowrite8(u8 b, void __iomem *);
337337

338-
__EXTERN_INLINE unsigned int marvel_ioread16(void __iomem *addr)
338+
__EXTERN_INLINE unsigned int marvel_ioread16(const void __iomem *addr)
339339
{
340340
return __kernel_ldwu(*(vusp)addr);
341341
}

arch/alpha/include/asm/core_mcpcia.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ extern inline int __mcpcia_is_mmio(unsigned long addr)
267267
return (addr & 0x80000000UL) == 0;
268268
}
269269

270-
__EXTERN_INLINE unsigned int mcpcia_ioread8(void __iomem *xaddr)
270+
__EXTERN_INLINE unsigned int mcpcia_ioread8(const void __iomem *xaddr)
271271
{
272272
unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
273273
unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -291,7 +291,7 @@ __EXTERN_INLINE void mcpcia_iowrite8(u8 b, void __iomem *xaddr)
291291
*(vuip) ((addr << 5) + hose + 0x00) = w;
292292
}
293293

294-
__EXTERN_INLINE unsigned int mcpcia_ioread16(void __iomem *xaddr)
294+
__EXTERN_INLINE unsigned int mcpcia_ioread16(const void __iomem *xaddr)
295295
{
296296
unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
297297
unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -315,7 +315,7 @@ __EXTERN_INLINE void mcpcia_iowrite16(u16 b, void __iomem *xaddr)
315315
*(vuip) ((addr << 5) + hose + 0x08) = w;
316316
}
317317

318-
__EXTERN_INLINE unsigned int mcpcia_ioread32(void __iomem *xaddr)
318+
__EXTERN_INLINE unsigned int mcpcia_ioread32(const void __iomem *xaddr)
319319
{
320320
unsigned long addr = (unsigned long)xaddr;
321321

arch/alpha/include/asm/core_t2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ __EXTERN_INLINE int t2_is_mmio(const volatile void __iomem *addr)
572572
it doesn't make sense to merge the pio and mmio routines. */
573573

574574
#define IOPORT(OS, NS) \
575-
__EXTERN_INLINE unsigned int t2_ioread##NS(void __iomem *xaddr) \
575+
__EXTERN_INLINE unsigned int t2_ioread##NS(const void __iomem *xaddr) \
576576
{ \
577577
if (t2_is_mmio(xaddr)) \
578578
return t2_read##OS(xaddr); \

arch/alpha/include/asm/io.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ static inline void generic_##NAME(TYPE b, QUAL void __iomem *addr) \
150150
alpha_mv.mv_##NAME(b, addr); \
151151
}
152152

153-
REMAP1(unsigned int, ioread8, /**/)
154-
REMAP1(unsigned int, ioread16, /**/)
155-
REMAP1(unsigned int, ioread32, /**/)
153+
REMAP1(unsigned int, ioread8, const)
154+
REMAP1(unsigned int, ioread16, const)
155+
REMAP1(unsigned int, ioread32, const)
156156
REMAP1(u8, readb, const volatile)
157157
REMAP1(u16, readw, const volatile)
158158
REMAP1(u32, readl, const volatile)
@@ -307,7 +307,7 @@ static inline int __is_mmio(const volatile void __iomem *addr)
307307
*/
308308

309309
#if IO_CONCAT(__IO_PREFIX,trivial_io_bw)
310-
extern inline unsigned int ioread8(void __iomem *addr)
310+
extern inline unsigned int ioread8(const void __iomem *addr)
311311
{
312312
unsigned int ret;
313313
mb();
@@ -316,7 +316,7 @@ extern inline unsigned int ioread8(void __iomem *addr)
316316
return ret;
317317
}
318318

319-
extern inline unsigned int ioread16(void __iomem *addr)
319+
extern inline unsigned int ioread16(const void __iomem *addr)
320320
{
321321
unsigned int ret;
322322
mb();
@@ -359,7 +359,7 @@ extern inline void outw(u16 b, unsigned long port)
359359
#endif
360360

361361
#if IO_CONCAT(__IO_PREFIX,trivial_io_lq)
362-
extern inline unsigned int ioread32(void __iomem *addr)
362+
extern inline unsigned int ioread32(const void __iomem *addr)
363363
{
364364
unsigned int ret;
365365
mb();

arch/alpha/include/asm/io_trivial.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
#if IO_CONCAT(__IO_PREFIX,trivial_io_bw)
99
__EXTERN_INLINE unsigned int
10-
IO_CONCAT(__IO_PREFIX,ioread8)(void __iomem *a)
10+
IO_CONCAT(__IO_PREFIX,ioread8)(const void __iomem *a)
1111
{
12-
return __kernel_ldbu(*(volatile u8 __force *)a);
12+
return __kernel_ldbu(*(const volatile u8 __force *)a);
1313
}
1414

1515
__EXTERN_INLINE unsigned int
16-
IO_CONCAT(__IO_PREFIX,ioread16)(void __iomem *a)
16+
IO_CONCAT(__IO_PREFIX,ioread16)(const void __iomem *a)
1717
{
18-
return __kernel_ldwu(*(volatile u16 __force *)a);
18+
return __kernel_ldwu(*(const volatile u16 __force *)a);
1919
}
2020

2121
__EXTERN_INLINE void
@@ -33,9 +33,9 @@ IO_CONCAT(__IO_PREFIX,iowrite16)(u16 b, void __iomem *a)
3333

3434
#if IO_CONCAT(__IO_PREFIX,trivial_io_lq)
3535
__EXTERN_INLINE unsigned int
36-
IO_CONCAT(__IO_PREFIX,ioread32)(void __iomem *a)
36+
IO_CONCAT(__IO_PREFIX,ioread32)(const void __iomem *a)
3737
{
38-
return *(volatile u32 __force *)a;
38+
return *(const volatile u32 __force *)a;
3939
}
4040

4141
__EXTERN_INLINE void
@@ -73,14 +73,14 @@ IO_CONCAT(__IO_PREFIX,writew)(u16 b, volatile void __iomem *a)
7373
__EXTERN_INLINE u8
7474
IO_CONCAT(__IO_PREFIX,readb)(const volatile void __iomem *a)
7575
{
76-
void __iomem *addr = (void __iomem *)a;
76+
const void __iomem *addr = (const void __iomem *)a;
7777
return IO_CONCAT(__IO_PREFIX,ioread8)(addr);
7878
}
7979

8080
__EXTERN_INLINE u16
8181
IO_CONCAT(__IO_PREFIX,readw)(const volatile void __iomem *a)
8282
{
83-
void __iomem *addr = (void __iomem *)a;
83+
const void __iomem *addr = (const void __iomem *)a;
8484
return IO_CONCAT(__IO_PREFIX,ioread16)(addr);
8585
}
8686

arch/alpha/include/asm/jensen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ __EXTERN_INLINE int jensen_is_mmio(const volatile void __iomem *addr)
305305
that it doesn't make sense to merge them. */
306306

307307
#define IOPORT(OS, NS) \
308-
__EXTERN_INLINE unsigned int jensen_ioread##NS(void __iomem *xaddr) \
308+
__EXTERN_INLINE unsigned int jensen_ioread##NS(const void __iomem *xaddr) \
309309
{ \
310310
if (jensen_is_mmio(xaddr)) \
311311
return jensen_read##OS(xaddr - 0x100000000ul); \

arch/alpha/include/asm/machvec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ struct alpha_machine_vector
4646
void (*mv_pci_tbi)(struct pci_controller *hose,
4747
dma_addr_t start, dma_addr_t end);
4848

49-
unsigned int (*mv_ioread8)(void __iomem *);
50-
unsigned int (*mv_ioread16)(void __iomem *);
51-
unsigned int (*mv_ioread32)(void __iomem *);
49+
unsigned int (*mv_ioread8)(const void __iomem *);
50+
unsigned int (*mv_ioread16)(const void __iomem *);
51+
unsigned int (*mv_ioread32)(const void __iomem *);
5252

5353
void (*mv_iowrite8)(u8, void __iomem *);
5454
void (*mv_iowrite16)(u16, void __iomem *);

0 commit comments

Comments
 (0)