Skip to content

Commit abaed89

Browse files
committed
gpio: sch: Switch to memory mapped IO accessors
Convert driver to use memory mapped IO accessors. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: William Breathitt Gray <[email protected]> Acked-by: Linus Walleij <[email protected]>
1 parent d8a26a1 commit abaed89

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

drivers/gpio/gpio-sch.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
struct sch_gpio {
4040
struct gpio_chip chip;
41+
void __iomem *regs;
4142
spinlock_t lock;
42-
unsigned short iobase;
4343
unsigned short resume_base;
4444

4545
/* GPE handling */
@@ -75,7 +75,7 @@ static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned int gpio, unsigned in
7575
offset = sch_gpio_offset(sch, gpio, reg);
7676
bit = sch_gpio_bit(sch, gpio);
7777

78-
reg_val = !!(inb(sch->iobase + offset) & BIT(bit));
78+
reg_val = !!(ioread8(sch->regs + offset) & BIT(bit));
7979

8080
return reg_val;
8181
}
@@ -89,12 +89,14 @@ static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned int gpio, unsigned i
8989
offset = sch_gpio_offset(sch, gpio, reg);
9090
bit = sch_gpio_bit(sch, gpio);
9191

92-
reg_val = inb(sch->iobase + offset);
92+
reg_val = ioread8(sch->regs + offset);
9393

9494
if (val)
95-
outb(reg_val | BIT(bit), sch->iobase + offset);
95+
reg_val |= BIT(bit);
9696
else
97-
outb((reg_val & ~BIT(bit)), sch->iobase + offset);
97+
reg_val &= ~BIT(bit);
98+
99+
iowrite8(reg_val, sch->regs + offset);
98100
}
99101

100102
static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned int gpio_num)
@@ -267,8 +269,8 @@ static u32 sch_gpio_gpe_handler(acpi_handle gpe_device, u32 gpe, void *context)
267269

268270
spin_lock_irqsave(&sch->lock, flags);
269271

270-
core_status = inl(sch->iobase + CORE_BANK_OFFSET + GTS);
271-
resume_status = inl(sch->iobase + RESUME_BANK_OFFSET + GTS);
272+
core_status = ioread32(sch->regs + CORE_BANK_OFFSET + GTS);
273+
resume_status = ioread32(sch->regs + RESUME_BANK_OFFSET + GTS);
272274

273275
spin_unlock_irqrestore(&sch->lock, flags);
274276

@@ -319,9 +321,11 @@ static int sch_gpio_install_gpe_handler(struct sch_gpio *sch)
319321

320322
static int sch_gpio_probe(struct platform_device *pdev)
321323
{
324+
struct device *dev = &pdev->dev;
322325
struct gpio_irq_chip *girq;
323326
struct sch_gpio *sch;
324327
struct resource *res;
328+
void __iomem *regs;
325329
int ret;
326330

327331
sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL);
@@ -332,12 +336,13 @@ static int sch_gpio_probe(struct platform_device *pdev)
332336
if (!res)
333337
return -EBUSY;
334338

335-
if (!devm_request_region(&pdev->dev, res->start, resource_size(res),
336-
pdev->name))
339+
regs = devm_ioport_map(dev, res->start, resource_size(res));
340+
if (!regs)
337341
return -EBUSY;
338342

343+
sch->regs = regs;
344+
339345
spin_lock_init(&sch->lock);
340-
sch->iobase = res->start;
341346
sch->chip = sch_gpio_chip;
342347
sch->chip.label = dev_name(&pdev->dev);
343348
sch->chip.parent = &pdev->dev;

0 commit comments

Comments
 (0)