Skip to content

Commit 77510eb

Browse files
claudiubezneacristibirsan
authored andcommitted
usb: gadget: udc: atmel: use of_find_matching_node_and_match
Instead of trying to match every possible compatible use of_find_matching_node_and_match() and pass the compatible array. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent 09dd2f6 commit 77510eb

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

drivers/usb/gadget/udc/atmel_usba_udc.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,12 @@ static const struct of_device_id atmel_udc_dt_ids[] = {
20512051

20522052
MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
20532053

2054+
static const struct of_device_id atmel_pmc_dt_ids[] = {
2055+
{ .compatible = "atmel,at91sam9g45-pmc" },
2056+
{ .compatible = "atmel,at91sam9rl-pmc" },
2057+
{ .compatible = "atmel,at91sam9x5-pmc" },
2058+
};
2059+
20542060
static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
20552061
struct usba_udc *udc)
20562062
{
@@ -2066,13 +2072,17 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
20662072
return ERR_PTR(-EINVAL);
20672073

20682074
udc->errata = match->data;
2069-
udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
2070-
if (IS_ERR(udc->pmc))
2071-
udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9rl-pmc");
2072-
if (IS_ERR(udc->pmc))
2073-
udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc");
2074-
if (udc->errata && IS_ERR(udc->pmc))
2075-
return ERR_CAST(udc->pmc);
2075+
if (udc->errata) {
2076+
pp = of_find_matching_node_and_match(NULL, atmel_pmc_dt_ids,
2077+
NULL);
2078+
if (!pp)
2079+
return ERR_PTR(-ENODEV);
2080+
2081+
udc->pmc = syscon_node_to_regmap(pp);
2082+
of_node_put(pp);
2083+
if (IS_ERR(udc->pmc))
2084+
return ERR_CAST(udc->pmc);
2085+
}
20762086

20772087
udc->num_ep = 0;
20782088

0 commit comments

Comments
 (0)