From: Ioana Radulescu Date: Sun, 29 Oct 2017 08:20:40 +0000 (+0000) Subject: staging: fsl-dpaa2/eth: Split function X-Git-Tag: v4.19~2226^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=308f64e7e2736fa24eb81f6454ee5b7efa5c5d39;p=platform%2Fkernel%2Flinux-rpi.git staging: fsl-dpaa2/eth: Split function Since setup_dpni() became a bit too long, move the buffer layout configuration to a separate function. Signed-off-by: Ioana Radulescu Signed-off-by: Bogdan Purcareata Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 5d2bd18..92faaaf 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -1776,42 +1776,12 @@ static void free_dpbp(struct dpaa2_eth_priv *priv) fsl_mc_object_free(priv->dpbp_dev); } -/* Configure the DPNI object this interface is associated with */ -static int setup_dpni(struct fsl_mc_device *ls_dev) +static int set_buffer_layout(struct dpaa2_eth_priv *priv) { - struct device *dev = &ls_dev->dev; - struct dpaa2_eth_priv *priv; - struct net_device *net_dev; + struct device *dev = priv->net_dev->dev.parent; struct dpni_buffer_layout buf_layout = {0}; int err; - net_dev = dev_get_drvdata(dev); - priv = netdev_priv(net_dev); - - /* get a handle for the DPNI object */ - err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token); - if (err) { - dev_err(dev, "dpni_open() failed\n"); - return err; - } - - ls_dev->mc_io = priv->mc_io; - ls_dev->mc_handle = priv->mc_token; - - err = dpni_reset(priv->mc_io, 0, priv->mc_token); - if (err) { - dev_err(dev, "dpni_reset() failed\n"); - goto close; - } - - err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token, - &priv->dpni_attrs); - if (err) { - dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err); - goto close; - } - - /* Configure buffer layouts */ /* rx buffer */ buf_layout.pass_parser_result = true; buf_layout.pass_frame_status = true; @@ -1825,7 +1795,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev) DPNI_QUEUE_RX, &buf_layout); if (err) { dev_err(dev, "dpni_set_buffer_layout(RX) failed\n"); - goto close; + return err; } /* tx buffer */ @@ -1835,7 +1805,7 @@ static int setup_dpni(struct fsl_mc_device *ls_dev) DPNI_QUEUE_TX, &buf_layout); if (err) { dev_err(dev, "dpni_set_buffer_layout(TX) failed\n"); - goto close; + return err; } /* tx-confirm buffer */ @@ -1844,9 +1814,50 @@ static int setup_dpni(struct fsl_mc_device *ls_dev) DPNI_QUEUE_TX_CONFIRM, &buf_layout); if (err) { dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n"); + return err; + } + + return 0; +} + +/* Configure the DPNI object this interface is associated with */ +static int setup_dpni(struct fsl_mc_device *ls_dev) +{ + struct device *dev = &ls_dev->dev; + struct dpaa2_eth_priv *priv; + struct net_device *net_dev; + int err; + + net_dev = dev_get_drvdata(dev); + priv = netdev_priv(net_dev); + + /* get a handle for the DPNI object */ + err = dpni_open(priv->mc_io, 0, ls_dev->obj_desc.id, &priv->mc_token); + if (err) { + dev_err(dev, "dpni_open() failed\n"); + return err; + } + + ls_dev->mc_io = priv->mc_io; + ls_dev->mc_handle = priv->mc_token; + + err = dpni_reset(priv->mc_io, 0, priv->mc_token); + if (err) { + dev_err(dev, "dpni_reset() failed\n"); goto close; } + err = dpni_get_attributes(priv->mc_io, 0, priv->mc_token, + &priv->dpni_attrs); + if (err) { + dev_err(dev, "dpni_get_attributes() failed (err=%d)\n", err); + goto close; + } + + err = set_buffer_layout(priv); + if (err) + goto close; + /* Now that we've set our tx buffer layout, retrieve the minimum * required tx data offset. */