From: Hans de Goede <hdegoede@redhat.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Hans de Goede <hdegoede@redhat.com>,
linux-leds@vger.kernel.org,
Henning Schild <henning.schild@siemens.com>,
kernel test robot <lkp@intel.com>
Subject: [PATCH 2/2] leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr
Date: Mon, 17 Jan 2022 12:21:09 +0100 [thread overview]
Message-ID: <20220117112109.215695-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20220117112109.215695-1-hdegoede@redhat.com>
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 <henning.schild@siemens.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Note this is not tested on actual hw, since I do not have the hw in question
---
drivers/leds/simple/simatic-ipc-leds.c | 32 +++++++++++++++-----------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c
index 179110448659..078d43f5ba38 100644
--- a/drivers/leds/simple/simatic-ipc-leds.c
+++ b/drivers/leds/simple/simatic-ipc-leds.c
@@ -41,7 +41,7 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = {
/* the actual start will be discovered with PCI, 0 is a placeholder */
static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME);
-static void *simatic_ipc_led_memory;
+static void __iomem *simatic_ipc_led_memory;
static struct simatic_ipc_led simatic_ipc_leds_mem[] = {
{0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"},
@@ -92,21 +92,22 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd,
enum led_brightness brightness)
{
struct simatic_ipc_led *led = cdev_to_led(led_cd);
+ void __iomem *reg = simatic_ipc_led_memory + led->value;
+ u32 val;
- u32 *p;
-
- p = simatic_ipc_led_memory + led->value;
- *p = (*p & ~1) | (brightness == LED_OFF);
+ val = readl(reg);
+ val = (val & ~1) | (brightness == LED_OFF);
+ writel(val, reg);
}
static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd)
{
struct simatic_ipc_led *led = cdev_to_led(led_cd);
+ void __iomem *reg = simatic_ipc_led_memory + led->value;
+ u32 val;
- u32 *p;
-
- p = simatic_ipc_led_memory + led->value;
- return (*p & 1) ? LED_OFF : led_cd->max_brightness;
+ val = readl(reg);
+ return (val & 1) ? LED_OFF : led_cd->max_brightness;
}
static int simatic_ipc_leds_probe(struct platform_device *pdev)
@@ -116,8 +117,9 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
struct simatic_ipc_led *ipcled;
struct led_classdev *cdev;
struct resource *res;
+ void __iomem *reg;
int err, type;
- u32 *p;
+ u32 val;
switch (plat->devmode) {
case SIMATIC_IPC_DEVICE_227D:
@@ -157,11 +159,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
return PTR_ERR(simatic_ipc_led_memory);
/* initialize power/watchdog LED */
- p = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
- *p = (*p & ~1);
- p = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
- *p = (*p | 1);
+ reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
+ val = readl(reg);
+ writel(val & ~1, reg);
+ reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
+ val = readl(reg);
+ writel(val | 1, reg);
break;
default:
return -ENODEV;
--
2.33.1
next prev parent reply other threads:[~2022-01-17 11:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 11:21 [PATCH 1/2] leds: simatic-ipc-leds: Make simatic_ipc_led_mem_res static Hans de Goede
2022-01-17 11:21 ` Hans de Goede [this message]
2022-01-28 9:30 ` [PATCH 2/2] leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr Henning Schild
2022-01-28 9:37 ` Hans de Goede
2022-01-28 15:26 ` Henning Schild
2022-02-03 10:43 ` Hans de Goede
2022-02-17 11:17 ` Hans de Goede
2022-02-17 11:26 ` Pavel Machek
2022-01-28 9:22 ` [PATCH 1/2] leds: simatic-ipc-leds: Make simatic_ipc_led_mem_res static Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220117112109.215695-2-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=henning.schild@siemens.com \
--cc=linux-leds@vger.kernel.org \
--cc=lkp@intel.com \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox