Skip to content

Commit 8b43ef0

Browse files
jwrdegoedepavelmachek
authored andcommitted
leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr
Sparse (rightly) currently gives the following warning: drivers/leds/simple/simatic-ipc-leds.c:155:40: sparse: sparse: incorrect type in assignment (different address spaces) expected void *static [toplevel] simatic_ipc_led_memory got void [noderef] __iomem * Fix this by changing the type of simatic_ipc_led_memory to void __iomem * and use readl()/writel() to access it. Cc: Henning Schild <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Tested-by: Gerd Haeussler <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent a8f5949 commit 8b43ef0

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

drivers/leds/simple/simatic-ipc-leds.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = {
4141
/* the actual start will be discovered with PCI, 0 is a placeholder */
4242
static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME);
4343

44-
static void *simatic_ipc_led_memory;
44+
static void __iomem *simatic_ipc_led_memory;
4545

4646
static struct simatic_ipc_led simatic_ipc_leds_mem[] = {
4747
{0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"},
@@ -92,21 +92,22 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd,
9292
enum led_brightness brightness)
9393
{
9494
struct simatic_ipc_led *led = cdev_to_led(led_cd);
95+
void __iomem *reg = simatic_ipc_led_memory + led->value;
96+
u32 val;
9597

96-
u32 *p;
97-
98-
p = simatic_ipc_led_memory + led->value;
99-
*p = (*p & ~1) | (brightness == LED_OFF);
98+
val = readl(reg);
99+
val = (val & ~1) | (brightness == LED_OFF);
100+
writel(val, reg);
100101
}
101102

102103
static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd)
103104
{
104105
struct simatic_ipc_led *led = cdev_to_led(led_cd);
106+
void __iomem *reg = simatic_ipc_led_memory + led->value;
107+
u32 val;
105108

106-
u32 *p;
107-
108-
p = simatic_ipc_led_memory + led->value;
109-
return (*p & 1) ? LED_OFF : led_cd->max_brightness;
109+
val = readl(reg);
110+
return (val & 1) ? LED_OFF : led_cd->max_brightness;
110111
}
111112

112113
static int simatic_ipc_leds_probe(struct platform_device *pdev)
@@ -116,8 +117,9 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
116117
struct simatic_ipc_led *ipcled;
117118
struct led_classdev *cdev;
118119
struct resource *res;
120+
void __iomem *reg;
119121
int err, type;
120-
u32 *p;
122+
u32 val;
121123

122124
switch (plat->devmode) {
123125
case SIMATIC_IPC_DEVICE_227D:
@@ -157,11 +159,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
157159
return PTR_ERR(simatic_ipc_led_memory);
158160

159161
/* initialize power/watchdog LED */
160-
p = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
161-
*p = (*p & ~1);
162-
p = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
163-
*p = (*p | 1);
162+
reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
163+
val = readl(reg);
164+
writel(val & ~1, reg);
164165

166+
reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
167+
val = readl(reg);
168+
writel(val | 1, reg);
165169
break;
166170
default:
167171
return -ENODEV;

0 commit comments

Comments
 (0)