Skip to content

Commit ed67b5d

Browse files
Russell King (Oracle)NipaLocal
authored andcommitted
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) <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 5c041cf commit ed67b5d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ struct ls1x_dwmac {
4646
struct regmap *regmap;
4747
};
4848

49+
struct ls1x_data {
50+
int (*init)(struct platform_device *pdev, void *bsp_priv);
51+
};
52+
4953
static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
5054
{
5155
struct ls1x_dwmac *dwmac = priv;
@@ -143,9 +147,9 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
143147
{
144148
struct plat_stmmacenet_data *plat_dat;
145149
struct stmmac_resources stmmac_res;
150+
const struct ls1x_data *data;
146151
struct regmap *regmap;
147152
struct ls1x_dwmac *dwmac;
148-
int (*init)(struct platform_device *pdev, void *priv);
149153
int ret;
150154

151155
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
@@ -159,8 +163,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
159163
return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
160164
"Unable to find syscon\n");
161165

162-
init = of_device_get_match_data(&pdev->dev);
163-
if (!init) {
166+
data = of_device_get_match_data(&pdev->dev);
167+
if (!data) {
164168
dev_err(&pdev->dev, "No of match data provided\n");
165169
return -EINVAL;
166170
}
@@ -175,21 +179,29 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
175179
"dt configuration failed\n");
176180

177181
plat_dat->bsp_priv = dwmac;
178-
plat_dat->init = init;
182+
plat_dat->init = data->init;
179183
dwmac->plat_dat = plat_dat;
180184
dwmac->regmap = regmap;
181185

182186
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
183187
}
184188

189+
static const struct ls1x_data ls1b_dwmac_data = {
190+
.init = ls1b_dwmac_syscon_init,
191+
};
192+
193+
static const struct ls1x_data ls1c_dwmac_data = {
194+
.init = ls1c_dwmac_syscon_init,
195+
};
196+
185197
static const struct of_device_id ls1x_dwmac_match[] = {
186198
{
187199
.compatible = "loongson,ls1b-gmac",
188-
.data = &ls1b_dwmac_syscon_init,
200+
.data = &ls1b_dwmac_data,
189201
},
190202
{
191203
.compatible = "loongson,ls1c-emac",
192-
.data = &ls1c_dwmac_syscon_init,
204+
.data = &ls1c_dwmac_data,
193205
},
194206
{ }
195207
};

0 commit comments

Comments
 (0)