diff options
Diffstat (limited to 'drivers/sh/pfc/core.c')
-rw-r--r-- | drivers/sh/pfc/core.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c index cd8f09dcea95..b2e121d927a0 100644 --- a/drivers/sh/pfc/core.c +++ b/drivers/sh/pfc/core.c | |||
@@ -26,21 +26,33 @@ | |||
26 | 26 | ||
27 | #include "core.h" | 27 | #include "core.h" |
28 | 28 | ||
29 | static int sh_pfc_ioremap(struct sh_pfc *pfc) | 29 | static int sh_pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev) |
30 | { | 30 | { |
31 | unsigned int num_resources; | ||
31 | struct resource *res; | 32 | struct resource *res; |
32 | int k; | 33 | int k; |
33 | 34 | ||
34 | if (!pfc->pdata->num_resources) | 35 | if (pdev->num_resources) { |
36 | num_resources = pdev->num_resources; | ||
37 | res = pdev->resource; | ||
38 | } else { | ||
39 | num_resources = pfc->pdata->num_resources; | ||
40 | res = pfc->pdata->resource; | ||
41 | } | ||
42 | |||
43 | if (num_resources == 0) { | ||
44 | pfc->num_windows = 0; | ||
35 | return 0; | 45 | return 0; |
46 | } | ||
36 | 47 | ||
37 | pfc->window = devm_kzalloc(pfc->dev, pfc->pdata->num_resources * | 48 | pfc->window = devm_kzalloc(pfc->dev, num_resources * |
38 | sizeof(*pfc->window), GFP_NOWAIT); | 49 | sizeof(*pfc->window), GFP_NOWAIT); |
39 | if (!pfc->window) | 50 | if (!pfc->window) |
40 | return -ENOMEM; | 51 | return -ENOMEM; |
41 | 52 | ||
42 | for (k = 0; k < pfc->pdata->num_resources; k++) { | 53 | pfc->num_windows = num_resources; |
43 | res = pfc->pdata->resource + k; | 54 | |
55 | for (k = 0; k < num_resources; k++, res++) { | ||
44 | WARN_ON(resource_type(res) != IORESOURCE_MEM); | 56 | WARN_ON(resource_type(res) != IORESOURCE_MEM); |
45 | pfc->window[k].phys = res->start; | 57 | pfc->window[k].phys = res->start; |
46 | pfc->window[k].size = resource_size(res); | 58 | pfc->window[k].size = resource_size(res); |
@@ -60,7 +72,7 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc, | |||
60 | int k; | 72 | int k; |
61 | 73 | ||
62 | /* scan through physical windows and convert address */ | 74 | /* scan through physical windows and convert address */ |
63 | for (k = 0; k < pfc->pdata->num_resources; k++) { | 75 | for (k = 0; k < pfc->num_windows; k++) { |
64 | window = pfc->window + k; | 76 | window = pfc->window + k; |
65 | 77 | ||
66 | if (address < window->phys) | 78 | if (address < window->phys) |
@@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev) | |||
498 | pfc->pdata = pdata; | 510 | pfc->pdata = pdata; |
499 | pfc->dev = &pdev->dev; | 511 | pfc->dev = &pdev->dev; |
500 | 512 | ||
501 | ret = sh_pfc_ioremap(pfc); | 513 | ret = sh_pfc_ioremap(pfc, pdev); |
502 | if (unlikely(ret < 0)) | 514 | if (unlikely(ret < 0)) |
503 | return ret; | 515 | return ret; |
504 | 516 | ||