Skip to content

Commit

Permalink
pinctrl: sunxi: Libraryse the driver
Browse files Browse the repository at this point in the history
This will allow to have multiple drivers using the same core code, and
eventually, retire pinctrl-sunxi-pins.h

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
  • Loading branch information
Maxime Ripard committed May 4, 2014
1 parent 4409caf commit 2284ba6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
21 changes: 14 additions & 7 deletions drivers/pinctrl/sunxi/pinctrl-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,10 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
return 0;
}

static int sunxi_pinctrl_probe(struct platform_device *pdev)
int sunxi_pinctrl_init(struct platform_device *pdev,
const struct sunxi_pinctrl_desc *desc)
{
struct device_node *node = pdev->dev.of_node;
const struct of_device_id *device;
struct pinctrl_pin_desc *pins;
struct sunxi_pinctrl *pctl;
struct reset_control *rstc;
Expand All @@ -810,11 +810,7 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
if (IS_ERR(pctl->membase))
return PTR_ERR(pctl->membase);

device = of_match_device(sunxi_pinctrl_match, &pdev->dev);
if (!device)
return -ENODEV;

pctl->desc = device->data;
pctl->desc = desc;

ret = sunxi_pinctrl_build_state(pdev);
if (ret) {
Expand Down Expand Up @@ -940,6 +936,17 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
return ret;
}

static int sunxi_pinctrl_probe(struct platform_device *pdev)
{
const struct of_device_id *device;

device = of_match_device(sunxi_pinctrl_match, &pdev->dev);
if (!device)
return -ENODEV;

return sunxi_pinctrl_init(pdev, device->data);
}

static struct platform_driver sunxi_pinctrl_driver = {
.probe = sunxi_pinctrl_probe,
.driver = {
Expand Down
3 changes: 3 additions & 0 deletions drivers/pinctrl/sunxi/pinctrl-sunxi.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,7 @@ static inline u32 sunxi_irq_status_offset(u16 irq)
return irq_num * IRQ_STATUS_IRQ_BITS;
}

int sunxi_pinctrl_init(struct platform_device *pdev,
const struct sunxi_pinctrl_desc *desc);

#endif /* __PINCTRL_SUNXI_H */

0 comments on commit 2284ba6

Please sign in to comment.