@@ -30,29 +30,42 @@ static void pfc_iounmap(struct sh_pfc *pfc)
{
int k;
- for (k = 0; k < pfc->pdata->num_resources; k++)
+ for (k = 0; k < pfc->num_windows; k++)
if (pfc->window[k].virt)
iounmap(pfc->window[k].virt);
kfree(pfc->window);
+ pfc->num_windows = 0;
pfc->window = NULL;
}
-static int pfc_ioremap(struct sh_pfc *pfc)
+static int pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
{
+ unsigned int num_resources;
struct resource *res;
int k;
- if (!pfc->pdata->num_resources)
+ if (pdev->num_resources) {
+ num_resources = pdev->num_resources;
+ res = pdev->resource;
+ } else {
+ num_resources = pfc->pdata->num_resources;
+ res = pfc->pdata->resource;
+ }
+
+ if (num_resources == 0) {
+ pfc->num_windows = 0;
return 0;
+ }
- pfc->window = kzalloc(pfc->pdata->num_resources * sizeof(*pfc->window),
+ pfc->window = kzalloc(num_resources * sizeof(*pfc->window),
GFP_NOWAIT);
if (!pfc->window)
goto err1;
- for (k = 0; k < pfc->pdata->num_resources; k++) {
- res = pfc->pdata->resource + k;
+ pfc->num_windows = num_resources;
+
+ for (k = 0; k < num_resources; k++, res++) {
WARN_ON(resource_type(res) != IORESOURCE_MEM);
pfc->window[k].phys = res->start;
pfc->window[k].size = resource_size(res);
@@ -77,7 +90,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
int k;
/* scan through physical windows and convert address */
- for (k = 0; k < pfc->pdata->num_resources; k++) {
+ for (k = 0; k < pfc->num_windows; k++) {
window = pfc->window + k;
if (address < window->phys)
@@ -516,7 +529,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
pfc->pdata = pdata;
pfc->dev = &pdev->dev;
- ret = pfc_ioremap(pfc);
+ ret = pfc_ioremap(pfc, pdev);
if (unlikely(ret < 0))
return ret;
@@ -28,7 +28,9 @@ struct sh_pfc {
struct sh_pfc_platform_data *pdata;
spinlock_t lock;
+ unsigned int num_windows;
struct pfc_window *window;
+
struct sh_pfc_chip *gpio;
struct sh_pfc_pinctrl *pinctrl;
};