mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-21 18:25:26 -04:00
net: stmmac: loongson1: provide match data struct
Provide a structure for match data rather than using the function pointer as match data. This allows stronger type-checking for the function itself, and allows extensions to the match data. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Keguang Zhang <keguang.zhang@gmail.com> Tested-by: Keguang Zhang <keguang.zhang@gmail.com> # on LS1B & LS1C Link: https://patch.msgid.link/E1uRqE9-004c7G-CB@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
c8e32755ba
commit
b1cffac479
@@ -46,6 +46,10 @@ struct ls1x_dwmac {
|
||||
struct regmap *regmap;
|
||||
};
|
||||
|
||||
struct ls1x_data {
|
||||
int (*init)(struct platform_device *pdev, void *bsp_priv);
|
||||
};
|
||||
|
||||
static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
|
||||
{
|
||||
struct ls1x_dwmac *dwmac = priv;
|
||||
@@ -143,9 +147,9 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct plat_stmmacenet_data *plat_dat;
|
||||
struct stmmac_resources stmmac_res;
|
||||
const struct ls1x_data *data;
|
||||
struct regmap *regmap;
|
||||
struct ls1x_dwmac *dwmac;
|
||||
int (*init)(struct platform_device *pdev, void *priv);
|
||||
int ret;
|
||||
|
||||
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
|
||||
@@ -159,8 +163,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
|
||||
"Unable to find syscon\n");
|
||||
|
||||
init = of_device_get_match_data(&pdev->dev);
|
||||
if (!init) {
|
||||
data = of_device_get_match_data(&pdev->dev);
|
||||
if (!data) {
|
||||
dev_err(&pdev->dev, "No of match data provided\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -175,21 +179,29 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
|
||||
"dt configuration failed\n");
|
||||
|
||||
plat_dat->bsp_priv = dwmac;
|
||||
plat_dat->init = init;
|
||||
plat_dat->init = data->init;
|
||||
dwmac->plat_dat = plat_dat;
|
||||
dwmac->regmap = regmap;
|
||||
|
||||
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
|
||||
}
|
||||
|
||||
static const struct ls1x_data ls1b_dwmac_data = {
|
||||
.init = ls1b_dwmac_syscon_init,
|
||||
};
|
||||
|
||||
static const struct ls1x_data ls1c_dwmac_data = {
|
||||
.init = ls1c_dwmac_syscon_init,
|
||||
};
|
||||
|
||||
static const struct of_device_id ls1x_dwmac_match[] = {
|
||||
{
|
||||
.compatible = "loongson,ls1b-gmac",
|
||||
.data = &ls1b_dwmac_syscon_init,
|
||||
.data = &ls1b_dwmac_data,
|
||||
},
|
||||
{
|
||||
.compatible = "loongson,ls1c-emac",
|
||||
.data = &ls1c_dwmac_syscon_init,
|
||||
.data = &ls1c_dwmac_data,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user