Use dcr_host_t.base in dcr_unmap()
With the base stored in dcr_host_t, there's no need for callers to pass the dcr_n into dcr_unmap(). In fact this removes the possibility of them passing the incorrect value, which would then be iounmap()'ed. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
parent
83f34df4e7
commit
cdbd3865ac
@ -126,13 +126,13 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(dcr_map);
|
EXPORT_SYMBOL_GPL(dcr_map);
|
||||||
|
|
||||||
void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
|
void dcr_unmap(dcr_host_t host, unsigned int dcr_c)
|
||||||
{
|
{
|
||||||
dcr_host_t h = host;
|
dcr_host_t h = host;
|
||||||
|
|
||||||
if (h.token == NULL)
|
if (h.token == NULL)
|
||||||
return;
|
return;
|
||||||
h.token += dcr_n * h.stride;
|
h.token += host.base * h.stride;
|
||||||
iounmap(h.token);
|
iounmap(h.token);
|
||||||
h.token = NULL;
|
h.token = NULL;
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ static int __devinit mal_probe(struct of_device *ofdev,
|
|||||||
fail2:
|
fail2:
|
||||||
dma_free_coherent(&ofdev->dev, bd_size, mal->bd_virt, mal->bd_dma);
|
dma_free_coherent(&ofdev->dev, bd_size, mal->bd_virt, mal->bd_dma);
|
||||||
fail_unmap:
|
fail_unmap:
|
||||||
dcr_unmap(mal->dcr_host, dcr_base, 0x100);
|
dcr_unmap(mal->dcr_host, 0x100);
|
||||||
fail:
|
fail:
|
||||||
kfree(mal);
|
kfree(mal);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
|
extern dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
|
||||||
unsigned int dcr_c);
|
unsigned int dcr_c);
|
||||||
extern void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c);
|
extern void dcr_unmap(dcr_host_t host, unsigned int dcr_c);
|
||||||
|
|
||||||
static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
|
static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ typedef struct {
|
|||||||
#define DCR_MAP_OK(host) (1)
|
#define DCR_MAP_OK(host) (1)
|
||||||
|
|
||||||
#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
|
#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
|
||||||
#define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
|
#define dcr_unmap(host, dcr_c) do {} while (0)
|
||||||
#define dcr_read(host, dcr_n) mfdcr(dcr_n + host.base)
|
#define dcr_read(host, dcr_n) mfdcr(dcr_n + host.base)
|
||||||
#define dcr_write(host, dcr_n, value) mtdcr(dcr_n + host.base, value)
|
#define dcr_write(host, dcr_n, value) mtdcr(dcr_n + host.base, value)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user