From: Joachim Eastwood <manabian@gmail.com>
To: peppe.cavallaro@st.com, davem@davemloft.net
Cc: Joachim Eastwood <manabian@gmail.com>, netdev@vger.kernel.org
Subject: [PATCH net-next 4/8] stmmac: make stmmac_probe_config_dt return the platform data struct
Date: Fri, 17 Jul 2015 00:26:08 +0200 [thread overview]
Message-ID: <1437085572-11371-5-git-send-email-manabian@gmail.com> (raw)
In-Reply-To: <1437085572-11371-1-git-send-email-manabian@gmail.com>
Since stmmac_probe_config_dt() allocates the platform data structure
it is cleaner if it just returned this structure directly. This
function will later be used in the probe function in dwmac-* drivers.
Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 28 ++++++++++------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 94962d75b99a..ea467be93673 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -104,9 +104,8 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
* this function is to read the driver parameters from device-tree and
* set some private fields that will be used by the main at runtime.
*/
-static int stmmac_probe_config_dt(struct platform_device *pdev,
- struct plat_stmmacenet_data **plat_dat,
- const char **mac)
+static struct plat_stmmacenet_data *
+stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
{
struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat;
@@ -115,9 +114,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
- return -ENOMEM;
-
- *plat_dat = plat;
+ return ERR_PTR(-ENOMEM);
data = of_device_get_match_data(&pdev->dev);
if (data) {
@@ -156,7 +153,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
/* If phy-handle is not specified, check if we have a fixed-phy */
if (!plat->phy_node && of_phy_is_fixed_link(np)) {
if ((of_phy_register_fixed_link(np) < 0))
- return -ENODEV;
+ return ERR_PTR(-ENODEV);
plat->phy_node = of_node_get(np);
}
@@ -233,7 +230,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
GFP_KERNEL);
if (!dma_cfg) {
of_node_put(np);
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
}
plat->dma_cfg = dma_cfg;
of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
@@ -251,14 +248,13 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set.");
}
- return 0;
+ return plat;
}
#else
-static int stmmac_probe_config_dt(struct platform_device *pdev,
- struct plat_stmmacenet_data **plat,
- const char **mac)
+static struct plat_stmmacenet_data *
+stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
{
- return -ENOSYS;
+ return ERR_PTR(-ENOSYS);
}
#endif /* CONFIG_OF */
@@ -325,10 +321,10 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
return ret;
if (pdev->dev.of_node) {
- ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
- if (ret) {
+ plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+ if (IS_ERR(plat_dat)) {
dev_err(&pdev->dev, "dt configuration failed\n");
- return ret;
+ return PTR_ERR(plat_dat);
}
} else {
plat_dat = dev_get_platdata(&pdev->dev);
--
1.8.0
next prev parent reply other threads:[~2015-07-16 22:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 2/8] stmmac: clean up platform/of_match data retrieval Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 3/8] stmmac: introduce stmmac_get_platform_resources() Joachim Eastwood
2015-07-16 22:26 ` Joachim Eastwood [this message]
2015-07-16 22:26 ` [PATCH net-next 5/8] stmmac: export probe_config_dt() and get_platform_resources() Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 6/8] stmmac: add proper probe function to dwmac-lpc18xx Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 7/8] stmmac: add proper probe function to dwmac-meson Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 8/8] stmmac: drop custom_* fields from plat_stmmacenet_data Joachim Eastwood
2015-07-21 3:46 ` [PATCH net-next 0/8] stmmac clean up for 4.3 part1 David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437085572-11371-5-git-send-email-manabian@gmail.com \
--to=manabian@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).