staging: unisys: decouple visor_memregion_{read, write}()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jes Sorensen 2015-05-05 18:36:30 -04:00 committed by Greg Kroah-Hartman
parent c37df5f0a0
commit 213e6a6132
1 changed files with 10 additions and 18 deletions

View File

@ -124,27 +124,15 @@ visor_memregion_resize(struct memregion *memregion, ulong newsize)
}
EXPORT_SYMBOL_GPL(visor_memregion_resize);
static int
memregion_readwrite(BOOL is_write,
struct memregion *memregion, ulong offset,
void *local, ulong nbytes)
{
if (offset + nbytes > memregion->nbytes)
return -EIO;
if (is_write)
memcpy_toio(memregion->mapped + offset, local, nbytes);
else
memcpy_fromio(local, memregion->mapped + offset, nbytes);
return 0;
}
int
visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
ulong nbytes)
{
return memregion_readwrite(FALSE, memregion, offset, dest, nbytes);
if (offset + nbytes > memregion->nbytes)
return -EIO;
memcpy_fromio(dest, memregion->mapped + offset, nbytes);
return 0;
}
EXPORT_SYMBOL_GPL(visor_memregion_read);
@ -152,7 +140,11 @@ int
visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
ulong nbytes)
{
return memregion_readwrite(TRUE, memregion, offset, src, nbytes);
if (offset + nbytes > memregion->nbytes)
return -EIO;
memcpy_toio(memregion->mapped + offset, src, nbytes);
return 0;
}
EXPORT_SYMBOL_GPL(visor_memregion_write);