Commit fd0d5e73 authored by David S. Miller's avatar David S. Miller

Merge branch 'cpsw_cleanups'

George Cherian says:

====================
TI CPSW Cleanup

This series does some minimal cleanups.
	-Conversion of pr_*() to dev_*()
	-Convert kzalloc to devm_kzalloc.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents eb02a272 e1943128
...@@ -1808,25 +1808,25 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1808,25 +1808,25 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
return -EINVAL; return -EINVAL;
if (of_property_read_u32(node, "slaves", &prop)) { if (of_property_read_u32(node, "slaves", &prop)) {
pr_err("Missing slaves property in the DT.\n"); dev_err(&pdev->dev, "Missing slaves property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->slaves = prop; data->slaves = prop;
if (of_property_read_u32(node, "active_slave", &prop)) { if (of_property_read_u32(node, "active_slave", &prop)) {
pr_err("Missing active_slave property in the DT.\n"); dev_err(&pdev->dev, "Missing active_slave property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->active_slave = prop; data->active_slave = prop;
if (of_property_read_u32(node, "cpts_clock_mult", &prop)) { if (of_property_read_u32(node, "cpts_clock_mult", &prop)) {
pr_err("Missing cpts_clock_mult property in the DT.\n"); dev_err(&pdev->dev, "Missing cpts_clock_mult property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->cpts_clock_mult = prop; data->cpts_clock_mult = prop;
if (of_property_read_u32(node, "cpts_clock_shift", &prop)) { if (of_property_read_u32(node, "cpts_clock_shift", &prop)) {
pr_err("Missing cpts_clock_shift property in the DT.\n"); dev_err(&pdev->dev, "Missing cpts_clock_shift property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->cpts_clock_shift = prop; data->cpts_clock_shift = prop;
...@@ -1838,31 +1838,31 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1838,31 +1838,31 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
return -ENOMEM; return -ENOMEM;
if (of_property_read_u32(node, "cpdma_channels", &prop)) { if (of_property_read_u32(node, "cpdma_channels", &prop)) {
pr_err("Missing cpdma_channels property in the DT.\n"); dev_err(&pdev->dev, "Missing cpdma_channels property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->channels = prop; data->channels = prop;
if (of_property_read_u32(node, "ale_entries", &prop)) { if (of_property_read_u32(node, "ale_entries", &prop)) {
pr_err("Missing ale_entries property in the DT.\n"); dev_err(&pdev->dev, "Missing ale_entries property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->ale_entries = prop; data->ale_entries = prop;
if (of_property_read_u32(node, "bd_ram_size", &prop)) { if (of_property_read_u32(node, "bd_ram_size", &prop)) {
pr_err("Missing bd_ram_size property in the DT.\n"); dev_err(&pdev->dev, "Missing bd_ram_size property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->bd_ram_size = prop; data->bd_ram_size = prop;
if (of_property_read_u32(node, "rx_descs", &prop)) { if (of_property_read_u32(node, "rx_descs", &prop)) {
pr_err("Missing rx_descs property in the DT.\n"); dev_err(&pdev->dev, "Missing rx_descs property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->rx_descs = prop; data->rx_descs = prop;
if (of_property_read_u32(node, "mac_control", &prop)) { if (of_property_read_u32(node, "mac_control", &prop)) {
pr_err("Missing mac_control property in the DT.\n"); dev_err(&pdev->dev, "Missing mac_control property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->mac_control = prop; data->mac_control = prop;
...@@ -1876,7 +1876,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1876,7 +1876,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
ret = of_platform_populate(node, NULL, NULL, &pdev->dev); ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
/* We do not want to force this, as in some cases may not have child */ /* We do not want to force this, as in some cases may not have child */
if (ret) if (ret)
pr_warn("Doesn't have any child node\n"); dev_warn(&pdev->dev, "Doesn't have any child node\n");
for_each_child_of_node(node, slave_node) { for_each_child_of_node(node, slave_node) {
struct cpsw_slave_data *slave_data = data->slave_data + i; struct cpsw_slave_data *slave_data = data->slave_data + i;
...@@ -1893,7 +1893,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1893,7 +1893,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
parp = of_get_property(slave_node, "phy_id", &lenp); parp = of_get_property(slave_node, "phy_id", &lenp);
if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
pr_err("Missing slave[%d] phy_id property\n", i); dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
return -EINVAL; return -EINVAL;
} }
mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
...@@ -1913,7 +1913,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1913,7 +1913,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
slave_data->phy_if = of_get_phy_mode(slave_node); slave_data->phy_if = of_get_phy_mode(slave_node);
if (slave_data->phy_if < 0) { if (slave_data->phy_if < 0) {
pr_err("Missing or malformed slave[%d] phy-mode property\n", dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
i); i);
return slave_data->phy_if; return slave_data->phy_if;
} }
...@@ -1921,9 +1921,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, ...@@ -1921,9 +1921,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
if (data->dual_emac) { if (data->dual_emac) {
if (of_property_read_u32(slave_node, "dual_emac_res_vlan", if (of_property_read_u32(slave_node, "dual_emac_res_vlan",
&prop)) { &prop)) {
pr_err("Missing dual_emac_res_vlan in DT.\n"); dev_err(&pdev->dev, "Missing dual_emac_res_vlan in DT.\n");
slave_data->dual_emac_res_vlan = i+1; slave_data->dual_emac_res_vlan = i+1;
pr_err("Using %d as Reserved VLAN for %d slave\n", dev_err(&pdev->dev, "Using %d as Reserved VLAN for %d slave\n",
slave_data->dual_emac_res_vlan, i); slave_data->dual_emac_res_vlan, i);
} else { } else {
slave_data->dual_emac_res_vlan = prop; slave_data->dual_emac_res_vlan = prop;
...@@ -1948,7 +1948,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev, ...@@ -1948,7 +1948,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
ndev = alloc_etherdev(sizeof(struct cpsw_priv)); ndev = alloc_etherdev(sizeof(struct cpsw_priv));
if (!ndev) { if (!ndev) {
pr_err("cpsw: error allocating net_device\n"); dev_err(&pdev->dev, "cpsw: error allocating net_device\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1964,10 +1964,10 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev, ...@@ -1964,10 +1964,10 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { if (is_valid_ether_addr(data->slave_data[1].mac_addr)) {
memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr,
ETH_ALEN); ETH_ALEN);
pr_info("cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr); dev_info(&pdev->dev, "cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr);
} else { } else {
random_ether_addr(priv_sl2->mac_addr); random_ether_addr(priv_sl2->mac_addr);
pr_info("cpsw: Random MACID = %pM\n", priv_sl2->mac_addr); dev_info(&pdev->dev, "cpsw: Random MACID = %pM\n", priv_sl2->mac_addr);
} }
memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN);
...@@ -2005,7 +2005,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev, ...@@ -2005,7 +2005,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
SET_NETDEV_DEV(ndev, &pdev->dev); SET_NETDEV_DEV(ndev, &pdev->dev);
ret = register_netdev(ndev); ret = register_netdev(ndev);
if (ret) { if (ret) {
pr_err("cpsw: error registering net device\n"); dev_err(&pdev->dev, "cpsw: error registering net device\n");
free_netdev(ndev); free_netdev(ndev);
ret = -ENODEV; ret = -ENODEV;
} }
...@@ -2027,7 +2027,7 @@ static int cpsw_probe(struct platform_device *pdev) ...@@ -2027,7 +2027,7 @@ static int cpsw_probe(struct platform_device *pdev)
ndev = alloc_etherdev(sizeof(struct cpsw_priv)); ndev = alloc_etherdev(sizeof(struct cpsw_priv));
if (!ndev) { if (!ndev) {
pr_err("error allocating net_device\n"); dev_err(&pdev->dev, "error allocating net_device\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -2042,7 +2042,7 @@ static int cpsw_probe(struct platform_device *pdev) ...@@ -2042,7 +2042,7 @@ static int cpsw_probe(struct platform_device *pdev)
priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL); priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL);
priv->irq_enabled = true; priv->irq_enabled = true;
if (!priv->cpts) { if (!priv->cpts) {
pr_err("error allocating cpts\n"); dev_err(&pdev->dev, "error allocating cpts\n");
goto clean_ndev_ret; goto clean_ndev_ret;
} }
...@@ -2055,7 +2055,7 @@ static int cpsw_probe(struct platform_device *pdev) ...@@ -2055,7 +2055,7 @@ static int cpsw_probe(struct platform_device *pdev)
pinctrl_pm_select_default_state(&pdev->dev); pinctrl_pm_select_default_state(&pdev->dev);
if (cpsw_probe_dt(&priv->data, pdev)) { if (cpsw_probe_dt(&priv->data, pdev)) {
pr_err("cpsw: platform data missing\n"); dev_err(&pdev->dev, "cpsw: platform data missing\n");
ret = -ENODEV; ret = -ENODEV;
goto clean_runtime_disable_ret; goto clean_runtime_disable_ret;
} }
...@@ -2063,10 +2063,10 @@ static int cpsw_probe(struct platform_device *pdev) ...@@ -2063,10 +2063,10 @@ static int cpsw_probe(struct platform_device *pdev)
if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN); memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
pr_info("Detected MACID = %pM\n", priv->mac_addr); dev_info(&pdev->dev, "Detected MACID = %pM\n", priv->mac_addr);
} else { } else {
eth_random_addr(priv->mac_addr); eth_random_addr(priv->mac_addr);
pr_info("Random MACID = %pM\n", priv->mac_addr); dev_info(&pdev->dev, "Random MACID = %pM\n", priv->mac_addr);
} }
memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
......
...@@ -158,9 +158,9 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, ...@@ -158,9 +158,9 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
int bitmap_size; int bitmap_size;
struct cpdma_desc_pool *pool; struct cpdma_desc_pool *pool;
pool = kzalloc(sizeof(*pool), GFP_KERNEL); pool = devm_kzalloc(dev, sizeof(*pool), GFP_KERNEL);
if (!pool) if (!pool)
return NULL; goto fail;
spin_lock_init(&pool->lock); spin_lock_init(&pool->lock);
...@@ -170,7 +170,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, ...@@ -170,7 +170,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
pool->num_desc = size / pool->desc_size; pool->num_desc = size / pool->desc_size;
bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long); bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long);
pool->bitmap = kzalloc(bitmap_size, GFP_KERNEL); pool->bitmap = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
if (!pool->bitmap) if (!pool->bitmap)
goto fail; goto fail;
...@@ -187,10 +187,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, ...@@ -187,10 +187,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
if (pool->iomap) if (pool->iomap)
return pool; return pool;
fail: fail:
kfree(pool->bitmap);
kfree(pool);
return NULL; return NULL;
} }
...@@ -203,7 +200,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool) ...@@ -203,7 +200,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
spin_lock_irqsave(&pool->lock, flags); spin_lock_irqsave(&pool->lock, flags);
WARN_ON(pool->used_desc); WARN_ON(pool->used_desc);
kfree(pool->bitmap);
if (pool->cpumap) { if (pool->cpumap) {
dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap, dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap,
pool->phys); pool->phys);
...@@ -211,7 +207,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool) ...@@ -211,7 +207,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
iounmap(pool->iomap); iounmap(pool->iomap);
} }
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irqrestore(&pool->lock, flags);
kfree(pool);
} }
static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool, static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool,
...@@ -276,7 +271,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params) ...@@ -276,7 +271,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
{ {
struct cpdma_ctlr *ctlr; struct cpdma_ctlr *ctlr;
ctlr = kzalloc(sizeof(*ctlr), GFP_KERNEL); ctlr = devm_kzalloc(params->dev, sizeof(*ctlr), GFP_KERNEL);
if (!ctlr) if (!ctlr)
return NULL; return NULL;
...@@ -468,7 +463,6 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr) ...@@ -468,7 +463,6 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
cpdma_desc_pool_destroy(ctlr->pool); cpdma_desc_pool_destroy(ctlr->pool);
spin_unlock_irqrestore(&ctlr->lock, flags); spin_unlock_irqrestore(&ctlr->lock, flags);
kfree(ctlr);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy); EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy);
...@@ -507,21 +501,22 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, ...@@ -507,21 +501,22 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
cpdma_handler_fn handler) cpdma_handler_fn handler)
{ {
struct cpdma_chan *chan; struct cpdma_chan *chan;
int ret, offset = (chan_num % CPDMA_MAX_CHANNELS) * 4; int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4;
unsigned long flags; unsigned long flags;
if (__chan_linear(chan_num) >= ctlr->num_chan) if (__chan_linear(chan_num) >= ctlr->num_chan)
return NULL; return NULL;
ret = -ENOMEM; chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
chan = kzalloc(sizeof(*chan), GFP_KERNEL);
if (!chan) if (!chan)
goto err_chan_alloc; return ERR_PTR(-ENOMEM);
spin_lock_irqsave(&ctlr->lock, flags); spin_lock_irqsave(&ctlr->lock, flags);
ret = -EBUSY; if (ctlr->channels[chan_num]) {
if (ctlr->channels[chan_num]) spin_unlock_irqrestore(&ctlr->lock, flags);
goto err_chan_busy; devm_kfree(ctlr->dev, chan);
return ERR_PTR(-EBUSY);
}
chan->ctlr = ctlr; chan->ctlr = ctlr;
chan->state = CPDMA_STATE_IDLE; chan->state = CPDMA_STATE_IDLE;
...@@ -551,12 +546,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num, ...@@ -551,12 +546,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
ctlr->channels[chan_num] = chan; ctlr->channels[chan_num] = chan;
spin_unlock_irqrestore(&ctlr->lock, flags); spin_unlock_irqrestore(&ctlr->lock, flags);
return chan; return chan;
err_chan_busy:
spin_unlock_irqrestore(&ctlr->lock, flags);
kfree(chan);
err_chan_alloc:
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(cpdma_chan_create); EXPORT_SYMBOL_GPL(cpdma_chan_create);
......
...@@ -303,7 +303,7 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data, ...@@ -303,7 +303,7 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
return -EINVAL; return -EINVAL;
if (of_property_read_u32(node, "bus_freq", &prop)) { if (of_property_read_u32(node, "bus_freq", &prop)) {
pr_err("Missing bus_freq property in the DT.\n"); dev_err(&pdev->dev, "Missing bus_freq property in the DT.\n");
return -EINVAL; return -EINVAL;
} }
data->bus_freq = prop; data->bus_freq = prop;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment