Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 355349
b: refs/heads/master
c: 973931a
h: refs/heads/master
i:
  355347: 4494747
v: v3
  • Loading branch information
Laurent Pinchart authored and Simon Horman committed Jan 25, 2013
1 parent c04a33d commit c5132c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 40ee6fce7a0d3a2b2a1f2a14900af98a49a9ff40
refs/heads/master: 973931ae0a2dad57e23ce0ca2fab5abed9cf0d9a
26 changes: 19 additions & 7 deletions trunk/drivers/sh/pfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,33 @@

#include "core.h"

static int sh_pfc_ioremap(struct sh_pfc *pfc)
static int sh_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 = devm_kzalloc(pfc->dev, pfc->pdata->num_resources *
pfc->window = devm_kzalloc(pfc->dev, num_resources *
sizeof(*pfc->window), GFP_NOWAIT);
if (!pfc->window)
return -ENOMEM;

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);
Expand All @@ -60,7 +72,7 @@ static void __iomem *sh_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)
Expand Down Expand Up @@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
pfc->pdata = pdata;
pfc->dev = &pdev->dev;

ret = sh_pfc_ioremap(pfc);
ret = sh_pfc_ioremap(pfc, pdev);
if (unlikely(ret < 0))
return ret;

Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/sh/pfc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ struct sh_pfc {
struct sh_pfc_platform_data *pdata;
spinlock_t lock;

unsigned int num_windows;
struct sh_pfc_window *window;

struct sh_pfc_chip *gpio;
struct sh_pfc_pinctrl *pinctrl;
};
Expand Down

0 comments on commit c5132c5

Please sign in to comment.