aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-05-15 13:42:20 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-15 13:42:20 -0400
commitfd0d5e7368306b467fbce0ad9f6e680bdcc5c386 (patch)
tree8ac9dba90ca6379ff00fc855725750c86457ffc0
parenteb02a272c97b6e25d8e5fcf1ea93923e6f155595 (diff)
parente194312854edc22a2faf1931b3c0608fe20cb969 (diff)
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: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/cpsw.c50
-rw-r--r--drivers/net/ethernet/ti/davinci_cpdma.c35
-rw-r--r--drivers/net/ethernet/ti/davinci_mdio.c2
3 files changed, 38 insertions, 49 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index e3d871055d63..52bcc5d9bc67 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1808,25 +1808,25 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1808 return -EINVAL; 1808 return -EINVAL;
1809 1809
1810 if (of_property_read_u32(node, "slaves", &prop)) { 1810 if (of_property_read_u32(node, "slaves", &prop)) {
1811 pr_err("Missing slaves property in the DT.\n"); 1811 dev_err(&pdev->dev, "Missing slaves property in the DT.\n");
1812 return -EINVAL; 1812 return -EINVAL;
1813 } 1813 }
1814 data->slaves = prop; 1814 data->slaves = prop;
1815 1815
1816 if (of_property_read_u32(node, "active_slave", &prop)) { 1816 if (of_property_read_u32(node, "active_slave", &prop)) {
1817 pr_err("Missing active_slave property in the DT.\n"); 1817 dev_err(&pdev->dev, "Missing active_slave property in the DT.\n");
1818 return -EINVAL; 1818 return -EINVAL;
1819 } 1819 }
1820 data->active_slave = prop; 1820 data->active_slave = prop;
1821 1821
1822 if (of_property_read_u32(node, "cpts_clock_mult", &prop)) { 1822 if (of_property_read_u32(node, "cpts_clock_mult", &prop)) {
1823 pr_err("Missing cpts_clock_mult property in the DT.\n"); 1823 dev_err(&pdev->dev, "Missing cpts_clock_mult property in the DT.\n");
1824 return -EINVAL; 1824 return -EINVAL;
1825 } 1825 }
1826 data->cpts_clock_mult = prop; 1826 data->cpts_clock_mult = prop;
1827 1827
1828 if (of_property_read_u32(node, "cpts_clock_shift", &prop)) { 1828 if (of_property_read_u32(node, "cpts_clock_shift", &prop)) {
1829 pr_err("Missing cpts_clock_shift property in the DT.\n"); 1829 dev_err(&pdev->dev, "Missing cpts_clock_shift property in the DT.\n");
1830 return -EINVAL; 1830 return -EINVAL;
1831 } 1831 }
1832 data->cpts_clock_shift = prop; 1832 data->cpts_clock_shift = prop;
@@ -1838,31 +1838,31 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1838 return -ENOMEM; 1838 return -ENOMEM;
1839 1839
1840 if (of_property_read_u32(node, "cpdma_channels", &prop)) { 1840 if (of_property_read_u32(node, "cpdma_channels", &prop)) {
1841 pr_err("Missing cpdma_channels property in the DT.\n"); 1841 dev_err(&pdev->dev, "Missing cpdma_channels property in the DT.\n");
1842 return -EINVAL; 1842 return -EINVAL;
1843 } 1843 }
1844 data->channels = prop; 1844 data->channels = prop;
1845 1845
1846 if (of_property_read_u32(node, "ale_entries", &prop)) { 1846 if (of_property_read_u32(node, "ale_entries", &prop)) {
1847 pr_err("Missing ale_entries property in the DT.\n"); 1847 dev_err(&pdev->dev, "Missing ale_entries property in the DT.\n");
1848 return -EINVAL; 1848 return -EINVAL;
1849 } 1849 }
1850 data->ale_entries = prop; 1850 data->ale_entries = prop;
1851 1851
1852 if (of_property_read_u32(node, "bd_ram_size", &prop)) { 1852 if (of_property_read_u32(node, "bd_ram_size", &prop)) {
1853 pr_err("Missing bd_ram_size property in the DT.\n"); 1853 dev_err(&pdev->dev, "Missing bd_ram_size property in the DT.\n");
1854 return -EINVAL; 1854 return -EINVAL;
1855 } 1855 }
1856 data->bd_ram_size = prop; 1856 data->bd_ram_size = prop;
1857 1857
1858 if (of_property_read_u32(node, "rx_descs", &prop)) { 1858 if (of_property_read_u32(node, "rx_descs", &prop)) {
1859 pr_err("Missing rx_descs property in the DT.\n"); 1859 dev_err(&pdev->dev, "Missing rx_descs property in the DT.\n");
1860 return -EINVAL; 1860 return -EINVAL;
1861 } 1861 }
1862 data->rx_descs = prop; 1862 data->rx_descs = prop;
1863 1863
1864 if (of_property_read_u32(node, "mac_control", &prop)) { 1864 if (of_property_read_u32(node, "mac_control", &prop)) {
1865 pr_err("Missing mac_control property in the DT.\n"); 1865 dev_err(&pdev->dev, "Missing mac_control property in the DT.\n");
1866 return -EINVAL; 1866 return -EINVAL;
1867 } 1867 }
1868 data->mac_control = prop; 1868 data->mac_control = prop;
@@ -1876,7 +1876,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1876 ret = of_platform_populate(node, NULL, NULL, &pdev->dev); 1876 ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
1877 /* We do not want to force this, as in some cases may not have child */ 1877 /* We do not want to force this, as in some cases may not have child */
1878 if (ret) 1878 if (ret)
1879 pr_warn("Doesn't have any child node\n"); 1879 dev_warn(&pdev->dev, "Doesn't have any child node\n");
1880 1880
1881 for_each_child_of_node(node, slave_node) { 1881 for_each_child_of_node(node, slave_node) {
1882 struct cpsw_slave_data *slave_data = data->slave_data + i; 1882 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 1893
1894 parp = of_get_property(slave_node, "phy_id", &lenp); 1894 parp = of_get_property(slave_node, "phy_id", &lenp);
1895 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 1895 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
1896 pr_err("Missing slave[%d] phy_id property\n", i); 1896 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
1897 return -EINVAL; 1897 return -EINVAL;
1898 } 1898 }
1899 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 1899 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
@@ -1913,18 +1913,18 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1913 1913
1914 slave_data->phy_if = of_get_phy_mode(slave_node); 1914 slave_data->phy_if = of_get_phy_mode(slave_node);
1915 if (slave_data->phy_if < 0) { 1915 if (slave_data->phy_if < 0) {
1916 pr_err("Missing or malformed slave[%d] phy-mode property\n", 1916 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
1917 i); 1917 i);
1918 return slave_data->phy_if; 1918 return slave_data->phy_if;
1919 } 1919 }
1920 1920
1921 if (data->dual_emac) { 1921 if (data->dual_emac) {
1922 if (of_property_read_u32(slave_node, "dual_emac_res_vlan", 1922 if (of_property_read_u32(slave_node, "dual_emac_res_vlan",
1923 &prop)) { 1923 &prop)) {
1924 pr_err("Missing dual_emac_res_vlan in DT.\n"); 1924 dev_err(&pdev->dev, "Missing dual_emac_res_vlan in DT.\n");
1925 slave_data->dual_emac_res_vlan = i+1; 1925 slave_data->dual_emac_res_vlan = i+1;
1926 pr_err("Using %d as Reserved VLAN for %d slave\n", 1926 dev_err(&pdev->dev, "Using %d as Reserved VLAN for %d slave\n",
1927 slave_data->dual_emac_res_vlan, i); 1927 slave_data->dual_emac_res_vlan, i);
1928 } else { 1928 } else {
1929 slave_data->dual_emac_res_vlan = prop; 1929 slave_data->dual_emac_res_vlan = prop;
1930 } 1930 }
@@ -1948,7 +1948,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
1948 1948
1949 ndev = alloc_etherdev(sizeof(struct cpsw_priv)); 1949 ndev = alloc_etherdev(sizeof(struct cpsw_priv));
1950 if (!ndev) { 1950 if (!ndev) {
1951 pr_err("cpsw: error allocating net_device\n"); 1951 dev_err(&pdev->dev, "cpsw: error allocating net_device\n");
1952 return -ENOMEM; 1952 return -ENOMEM;
1953 } 1953 }
1954 1954
@@ -1964,10 +1964,10 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
1964 if (is_valid_ether_addr(data->slave_data[1].mac_addr)) { 1964 if (is_valid_ether_addr(data->slave_data[1].mac_addr)) {
1965 memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr, 1965 memcpy(priv_sl2->mac_addr, data->slave_data[1].mac_addr,
1966 ETH_ALEN); 1966 ETH_ALEN);
1967 pr_info("cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr); 1967 dev_info(&pdev->dev, "cpsw: Detected MACID = %pM\n", priv_sl2->mac_addr);
1968 } else { 1968 } else {
1969 random_ether_addr(priv_sl2->mac_addr); 1969 random_ether_addr(priv_sl2->mac_addr);
1970 pr_info("cpsw: Random MACID = %pM\n", priv_sl2->mac_addr); 1970 dev_info(&pdev->dev, "cpsw: Random MACID = %pM\n", priv_sl2->mac_addr);
1971 } 1971 }
1972 memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN); 1972 memcpy(ndev->dev_addr, priv_sl2->mac_addr, ETH_ALEN);
1973 1973
@@ -2005,7 +2005,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
2005 SET_NETDEV_DEV(ndev, &pdev->dev); 2005 SET_NETDEV_DEV(ndev, &pdev->dev);
2006 ret = register_netdev(ndev); 2006 ret = register_netdev(ndev);
2007 if (ret) { 2007 if (ret) {
2008 pr_err("cpsw: error registering net device\n"); 2008 dev_err(&pdev->dev, "cpsw: error registering net device\n");
2009 free_netdev(ndev); 2009 free_netdev(ndev);
2010 ret = -ENODEV; 2010 ret = -ENODEV;
2011 } 2011 }
@@ -2027,7 +2027,7 @@ static int cpsw_probe(struct platform_device *pdev)
2027 2027
2028 ndev = alloc_etherdev(sizeof(struct cpsw_priv)); 2028 ndev = alloc_etherdev(sizeof(struct cpsw_priv));
2029 if (!ndev) { 2029 if (!ndev) {
2030 pr_err("error allocating net_device\n"); 2030 dev_err(&pdev->dev, "error allocating net_device\n");
2031 return -ENOMEM; 2031 return -ENOMEM;
2032 } 2032 }
2033 2033
@@ -2042,7 +2042,7 @@ static int cpsw_probe(struct platform_device *pdev)
2042 priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL); 2042 priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL);
2043 priv->irq_enabled = true; 2043 priv->irq_enabled = true;
2044 if (!priv->cpts) { 2044 if (!priv->cpts) {
2045 pr_err("error allocating cpts\n"); 2045 dev_err(&pdev->dev, "error allocating cpts\n");
2046 goto clean_ndev_ret; 2046 goto clean_ndev_ret;
2047 } 2047 }
2048 2048
@@ -2055,7 +2055,7 @@ static int cpsw_probe(struct platform_device *pdev)
2055 pinctrl_pm_select_default_state(&pdev->dev); 2055 pinctrl_pm_select_default_state(&pdev->dev);
2056 2056
2057 if (cpsw_probe_dt(&priv->data, pdev)) { 2057 if (cpsw_probe_dt(&priv->data, pdev)) {
2058 pr_err("cpsw: platform data missing\n"); 2058 dev_err(&pdev->dev, "cpsw: platform data missing\n");
2059 ret = -ENODEV; 2059 ret = -ENODEV;
2060 goto clean_runtime_disable_ret; 2060 goto clean_runtime_disable_ret;
2061 } 2061 }
@@ -2063,10 +2063,10 @@ static int cpsw_probe(struct platform_device *pdev)
2063 2063
2064 if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { 2064 if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
2065 memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN); 2065 memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
2066 pr_info("Detected MACID = %pM\n", priv->mac_addr); 2066 dev_info(&pdev->dev, "Detected MACID = %pM\n", priv->mac_addr);
2067 } else { 2067 } else {
2068 eth_random_addr(priv->mac_addr); 2068 eth_random_addr(priv->mac_addr);
2069 pr_info("Random MACID = %pM\n", priv->mac_addr); 2069 dev_info(&pdev->dev, "Random MACID = %pM\n", priv->mac_addr);
2070 } 2070 }
2071 2071
2072 memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); 2072 memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 88ef27067bf2..539dbdecd310 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -158,9 +158,9 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
158 int bitmap_size; 158 int bitmap_size;
159 struct cpdma_desc_pool *pool; 159 struct cpdma_desc_pool *pool;
160 160
161 pool = kzalloc(sizeof(*pool), GFP_KERNEL); 161 pool = devm_kzalloc(dev, sizeof(*pool), GFP_KERNEL);
162 if (!pool) 162 if (!pool)
163 return NULL; 163 goto fail;
164 164
165 spin_lock_init(&pool->lock); 165 spin_lock_init(&pool->lock);
166 166
@@ -170,7 +170,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
170 pool->num_desc = size / pool->desc_size; 170 pool->num_desc = size / pool->desc_size;
171 171
172 bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long); 172 bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long);
173 pool->bitmap = kzalloc(bitmap_size, GFP_KERNEL); 173 pool->bitmap = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
174 if (!pool->bitmap) 174 if (!pool->bitmap)
175 goto fail; 175 goto fail;
176 176
@@ -187,10 +187,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
187 187
188 if (pool->iomap) 188 if (pool->iomap)
189 return pool; 189 return pool;
190
191fail: 190fail:
192 kfree(pool->bitmap);
193 kfree(pool);
194 return NULL; 191 return NULL;
195} 192}
196 193
@@ -203,7 +200,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
203 200
204 spin_lock_irqsave(&pool->lock, flags); 201 spin_lock_irqsave(&pool->lock, flags);
205 WARN_ON(pool->used_desc); 202 WARN_ON(pool->used_desc);
206 kfree(pool->bitmap);
207 if (pool->cpumap) { 203 if (pool->cpumap) {
208 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap, 204 dma_free_coherent(pool->dev, pool->mem_size, pool->cpumap,
209 pool->phys); 205 pool->phys);
@@ -211,7 +207,6 @@ static void cpdma_desc_pool_destroy(struct cpdma_desc_pool *pool)
211 iounmap(pool->iomap); 207 iounmap(pool->iomap);
212 } 208 }
213 spin_unlock_irqrestore(&pool->lock, flags); 209 spin_unlock_irqrestore(&pool->lock, flags);
214 kfree(pool);
215} 210}
216 211
217static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool, 212static 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{ 271{
277 struct cpdma_ctlr *ctlr; 272 struct cpdma_ctlr *ctlr;
278 273
279 ctlr = kzalloc(sizeof(*ctlr), GFP_KERNEL); 274 ctlr = devm_kzalloc(params->dev, sizeof(*ctlr), GFP_KERNEL);
280 if (!ctlr) 275 if (!ctlr)
281 return NULL; 276 return NULL;
282 277
@@ -468,7 +463,6 @@ int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr)
468 463
469 cpdma_desc_pool_destroy(ctlr->pool); 464 cpdma_desc_pool_destroy(ctlr->pool);
470 spin_unlock_irqrestore(&ctlr->lock, flags); 465 spin_unlock_irqrestore(&ctlr->lock, flags);
471 kfree(ctlr);
472 return ret; 466 return ret;
473} 467}
474EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy); 468EXPORT_SYMBOL_GPL(cpdma_ctlr_destroy);
@@ -507,21 +501,22 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
507 cpdma_handler_fn handler) 501 cpdma_handler_fn handler)
508{ 502{
509 struct cpdma_chan *chan; 503 struct cpdma_chan *chan;
510 int ret, offset = (chan_num % CPDMA_MAX_CHANNELS) * 4; 504 int offset = (chan_num % CPDMA_MAX_CHANNELS) * 4;
511 unsigned long flags; 505 unsigned long flags;
512 506
513 if (__chan_linear(chan_num) >= ctlr->num_chan) 507 if (__chan_linear(chan_num) >= ctlr->num_chan)
514 return NULL; 508 return NULL;
515 509
516 ret = -ENOMEM; 510 chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
517 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
518 if (!chan) 511 if (!chan)
519 goto err_chan_alloc; 512 return ERR_PTR(-ENOMEM);
520 513
521 spin_lock_irqsave(&ctlr->lock, flags); 514 spin_lock_irqsave(&ctlr->lock, flags);
522 ret = -EBUSY; 515 if (ctlr->channels[chan_num]) {
523 if (ctlr->channels[chan_num]) 516 spin_unlock_irqrestore(&ctlr->lock, flags);
524 goto err_chan_busy; 517 devm_kfree(ctlr->dev, chan);
518 return ERR_PTR(-EBUSY);
519 }
525 520
526 chan->ctlr = ctlr; 521 chan->ctlr = ctlr;
527 chan->state = CPDMA_STATE_IDLE; 522 chan->state = CPDMA_STATE_IDLE;
@@ -551,12 +546,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
551 ctlr->channels[chan_num] = chan; 546 ctlr->channels[chan_num] = chan;
552 spin_unlock_irqrestore(&ctlr->lock, flags); 547 spin_unlock_irqrestore(&ctlr->lock, flags);
553 return chan; 548 return chan;
554
555err_chan_busy:
556 spin_unlock_irqrestore(&ctlr->lock, flags);
557 kfree(chan);
558err_chan_alloc:
559 return ERR_PTR(ret);
560} 549}
561EXPORT_SYMBOL_GPL(cpdma_chan_create); 550EXPORT_SYMBOL_GPL(cpdma_chan_create);
562 551
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 34e97eca561c..735dc53d4b01 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -303,7 +303,7 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
303 return -EINVAL; 303 return -EINVAL;
304 304
305 if (of_property_read_u32(node, "bus_freq", &prop)) { 305 if (of_property_read_u32(node, "bus_freq", &prop)) {
306 pr_err("Missing bus_freq property in the DT.\n"); 306 dev_err(&pdev->dev, "Missing bus_freq property in the DT.\n");
307 return -EINVAL; 307 return -EINVAL;
308 } 308 }
309 data->bus_freq = prop; 309 data->bus_freq = prop;