* [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO
@ 2024-04-08 9:28 Arnd Bergmann
2024-04-09 10:38 ` Peter Korsgaard
2024-04-10 13:31 ` Andi Shyti
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2024-04-08 9:28 UTC (permalink / raw)
To: Andi Shyti, Peter Korsgaard, Andrew Lunn
Cc: Arnd Bergmann, Geert Uytterhoeven, Wolfram Sang, Jarkko Nikula,
Geert Uytterhoeven, Niklas Schnelle, Samuel Holland,
Gregor Herburger, linux-i2c, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
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: 53f44c1005ba ("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>
---
drivers/i2c/busses/Kconfig | 1 -
drivers/i2c/busses/i2c-ocores.c | 21 +++++++--------------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 2d5e74ac9ea0..64c985ec0fae 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -886,7 +886,6 @@ config I2C_NPCM
config I2C_OCORES
tristate "OpenCores I2C Controller"
- depends on HAS_IOPORT
help
If you say yes to this option, support will be included for the
OpenCores I2C controller. For details see
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index e106af83cef4..56a4dabf5a38 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -32,7 +32,6 @@
*/
struct ocores_i2c {
void __iomem *base;
- int iobase;
u32 reg_shift;
u32 reg_io_width;
unsigned long flags;
@@ -136,16 +135,6 @@ static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg)
return ioread32be(i2c->base + (reg << i2c->reg_shift));
}
-static void oc_setreg_io_8(struct ocores_i2c *i2c, int reg, u8 value)
-{
- outb(value, i2c->iobase + reg);
-}
-
-static inline u8 oc_getreg_io_8(struct ocores_i2c *i2c, int reg)
-{
- return inb(i2c->iobase + reg);
-}
-
static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
{
i2c->setreg(i2c, reg, value);
@@ -618,15 +607,19 @@ static int ocores_i2c_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res)
return -EINVAL;
- i2c->iobase = res->start;
if (!devm_request_region(&pdev->dev, res->start,
resource_size(res),
pdev->name)) {
dev_err(&pdev->dev, "Can't get I/O resource.\n");
return -EBUSY;
}
- i2c->setreg = oc_setreg_io_8;
- i2c->getreg = oc_getreg_io_8;
+ i2c->base = devm_ioport_map(&pdev->dev, res->start,
+ resource_size(res));
+ if (!i2c->base) {
+ dev_err(&pdev->dev, "Can't map I/O resource.\n");
+ return -EBUSY;
+ }
+ i2c->reg_io_width = 1;
}
pdata = dev_get_platdata(&pdev->dev);
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO
2024-04-08 9:28 [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO Arnd Bergmann
@ 2024-04-09 10:38 ` Peter Korsgaard
2024-04-10 13:31 ` Andi Shyti
1 sibling, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2024-04-09 10:38 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andi Shyti, Andrew Lunn, Arnd Bergmann, Geert Uytterhoeven,
Wolfram Sang, Jarkko Nikula, Geert Uytterhoeven, Niklas Schnelle,
Samuel Holland, Gregor Herburger, linux-i2c, linux-kernel
>>>>> "Arnd" == Arnd Bergmann <arnd@kernel.org> writes:
> From: Arnd Bergmann <arnd@arndb.de>
> 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: 53f44c1005ba ("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>
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO
2024-04-08 9:28 [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO Arnd Bergmann
2024-04-09 10:38 ` Peter Korsgaard
@ 2024-04-10 13:31 ` Andi Shyti
2024-04-11 8:07 ` Arnd Bergmann
1 sibling, 1 reply; 4+ messages in thread
From: Andi Shyti @ 2024-04-10 13:31 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Peter Korsgaard, Andrew Lunn, Arnd Bergmann, Geert Uytterhoeven,
Wolfram Sang, Jarkko Nikula, Geert Uytterhoeven, Niklas Schnelle,
Samuel Holland, Gregor Herburger, linux-i2c, linux-kernel
Hi Arnd,
On Mon, Apr 08, 2024 at 11:28:36AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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: 53f44c1005ba ("i2c: add HAS_IOPORT dependencies")
I had to update this Fixes tag as I have done a rebase.
> 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>
This will go through i2c/i2c-host and sent in the merge window
pull request.
Applied to i2c/i2c-host on
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
Thank you,
Andi
Patches applied
===============
[1/1] i2c: ocores: convert to ioport_map() for IORESOURCE_IO
commit: a43939d2d96aec5fcb77d0abd75bab5e6ab006d3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO
2024-04-10 13:31 ` Andi Shyti
@ 2024-04-11 8:07 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2024-04-11 8:07 UTC (permalink / raw)
To: Andi Shyti, Arnd Bergmann
Cc: Peter Korsgaard, Andrew Lunn, Geert Uytterhoeven, Wolfram Sang,
Jarkko Nikula, Geert Uytterhoeven, Niklas Schnelle,
Samuel Holland, Gregor Herburger, linux-i2c, linux-kernel
On Wed, Apr 10, 2024, at 15:31, Andi Shyti wrote:
> Hi Arnd,
>
> On Mon, Apr 08, 2024 at 11:28:36AM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> 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: 53f44c1005ba ("i2c: add HAS_IOPORT dependencies")
>
> I had to update this Fixes tag as I have done a rebase.
>
Ok, thanks for merging.
In case you do another rebase, you could also move this patch
ahead of the other one to avoid adding and then removing the
dependency again.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-11 8:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08 9:28 [PATCH] i2c: ocores: convert to ioport_map() for IORESOURCE_IO Arnd Bergmann
2024-04-09 10:38 ` Peter Korsgaard
2024-04-10 13:31 ` Andi Shyti
2024-04-11 8:07 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox