Skip to content

Commit 759273c

Browse files
henning-schildlag-linaro
authored andcommitted
leds: simatic-ipc-leds: Convert to use P2SB accessor
Since we have a common P2SB accessor in tree we may use it instead of open coded variants. Replace custom code by p2sb_bar() call. Signed-off-by: Henning Schild <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent e38da7d commit 759273c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/leds/simple/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config LEDS_SIEMENS_SIMATIC_IPC
33
tristate "LED driver for Siemens Simatic IPCs"
44
depends on LEDS_CLASS
55
depends on SIEMENS_SIMATIC_IPC
6+
select P2SB
67
help
78
This option enables support for the LEDs of several Industrial PCs
89
from Siemens.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/leds.h>
1616
#include <linux/module.h>
1717
#include <linux/pci.h>
18+
#include <linux/platform_data/x86/p2sb.h>
1819
#include <linux/platform_data/x86/simatic-ipc-base.h>
1920
#include <linux/platform_device.h>
2021
#include <linux/sizes.h>
@@ -38,8 +39,8 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = {
3839
{ }
3940
};
4041

41-
/* the actual start will be discovered with PCI, 0 is a placeholder */
42-
static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME);
42+
/* the actual start will be discovered with p2sb, 0 is a placeholder */
43+
static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, 0, KBUILD_MODNAME);
4344

4445
static void __iomem *simatic_ipc_led_memory;
4546

@@ -145,14 +146,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
145146
ipcled = simatic_ipc_leds_mem;
146147
type = IORESOURCE_MEM;
147148

148-
/* get GPIO base from PCI */
149-
res->start = simatic_ipc_get_membase0(PCI_DEVFN(13, 0));
150-
if (res->start == 0)
151-
return -ENODEV;
149+
err = p2sb_bar(NULL, 0, res);
150+
if (err)
151+
return err;
152152

153153
/* do the final address calculation */
154154
res->start = res->start + (0xC5 << 16);
155-
res->end += res->start;
155+
res->end = res->start + SZ_4K - 1;
156156

157157
simatic_ipc_led_memory = devm_ioremap_resource(dev, res);
158158
if (IS_ERR(simatic_ipc_led_memory))

0 commit comments

Comments
 (0)