Skip to content

Commit 48ace62

Browse files
arndbAndi Shyti
authored andcommitted
i2c: ocores: convert to ioport_map() for IORESOURCE_IO
There is at least one machine that uses this driver but does not have support for inb()/outb() instructions. Convert this to using ioport_map() so it can build on architectures that don't provide these but work correctly on machines that require using port I/O. Fixes: 47c21d2 ("i2c: add HAS_IOPORT dependencies") Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://lore.kernel.org/lkml/CAMuHMdVUQ2WgtpYPYfO2T=itMmZ7w=geREqDtsP8Q3ODh9rxdw@mail.gmail.com/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 47c21d2 commit 48ace62

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,6 @@ config I2C_NPCM
885885

886886
config I2C_OCORES
887887
tristate "OpenCores I2C Controller"
888-
depends on HAS_IOPORT
889888
help
890889
If you say yes to this option, support will be included for the
891890
OpenCores I2C controller. For details see

drivers/i2c/busses/i2c-ocores.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
struct ocores_i2c {
3434
void __iomem *base;
35-
int iobase;
3635
u32 reg_shift;
3736
u32 reg_io_width;
3837
unsigned long flags;
@@ -136,16 +135,6 @@ static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg)
136135
return ioread32be(i2c->base + (reg << i2c->reg_shift));
137136
}
138137

139-
static void oc_setreg_io_8(struct ocores_i2c *i2c, int reg, u8 value)
140-
{
141-
outb(value, i2c->iobase + reg);
142-
}
143-
144-
static inline u8 oc_getreg_io_8(struct ocores_i2c *i2c, int reg)
145-
{
146-
return inb(i2c->iobase + reg);
147-
}
148-
149138
static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
150139
{
151140
i2c->setreg(i2c, reg, value);
@@ -618,15 +607,19 @@ static int ocores_i2c_probe(struct platform_device *pdev)
618607
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
619608
if (!res)
620609
return -EINVAL;
621-
i2c->iobase = res->start;
622610
if (!devm_request_region(&pdev->dev, res->start,
623611
resource_size(res),
624612
pdev->name)) {
625613
dev_err(&pdev->dev, "Can't get I/O resource.\n");
626614
return -EBUSY;
627615
}
628-
i2c->setreg = oc_setreg_io_8;
629-
i2c->getreg = oc_getreg_io_8;
616+
i2c->base = devm_ioport_map(&pdev->dev, res->start,
617+
resource_size(res));
618+
if (!i2c->base) {
619+
dev_err(&pdev->dev, "Can't map I/O resource.\n");
620+
return -EBUSY;
621+
}
622+
i2c->reg_io_width = 1;
630623
}
631624

632625
pdata = dev_get_platdata(&pdev->dev);

0 commit comments

Comments
 (0)