mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 16:37:50 +00:00
can: m_can: Move allocation of net device to probe
With the version no longer required to allocate the net device, it can be moved to probe and the alloc_m_can_dev() function can be simplified. Therefore, move the allocation of net device to probe and change alloc_m_can_dev() to setup_m_can_dev(). Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
b25abca6aa
commit
5e520edd91
1 changed files with 13 additions and 17 deletions
|
@ -1247,25 +1247,20 @@ static bool m_can_niso_supported(const struct m_can_priv *priv)
|
||||||
return !niso_timeout;
|
return !niso_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct net_device *alloc_m_can_dev(struct platform_device *pdev,
|
static int m_can_dev_setup(struct platform_device *pdev, struct net_device *dev,
|
||||||
void __iomem *addr, u32 tx_fifo_size)
|
void __iomem *addr)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
|
||||||
struct m_can_priv *priv;
|
struct m_can_priv *priv;
|
||||||
int m_can_version;
|
int m_can_version;
|
||||||
|
|
||||||
m_can_version = m_can_check_core_release(addr);
|
m_can_version = m_can_check_core_release(addr);
|
||||||
/* return if unsupported version */
|
/* return if unsupported version */
|
||||||
if (!m_can_version) {
|
if (!m_can_version) {
|
||||||
dev = NULL;
|
dev_err(&pdev->dev, "Unsupported version number: %2d",
|
||||||
goto return_dev;
|
m_can_version);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = alloc_candev(sizeof(*priv), tx_fifo_size);
|
|
||||||
if (!dev) {
|
|
||||||
dev = NULL;
|
|
||||||
goto return_dev;
|
|
||||||
}
|
|
||||||
priv = netdev_priv(dev);
|
priv = netdev_priv(dev);
|
||||||
netif_napi_add(dev, &priv->napi, m_can_poll, M_CAN_NAPI_WEIGHT);
|
netif_napi_add(dev, &priv->napi, m_can_poll, M_CAN_NAPI_WEIGHT);
|
||||||
|
|
||||||
|
@ -1307,16 +1302,12 @@ static struct net_device *alloc_m_can_dev(struct platform_device *pdev,
|
||||||
: 0);
|
: 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Unsupported device: free candev */
|
|
||||||
free_m_can_dev(dev);
|
|
||||||
dev_err(&pdev->dev, "Unsupported version number: %2d",
|
dev_err(&pdev->dev, "Unsupported version number: %2d",
|
||||||
priv->version);
|
priv->version);
|
||||||
dev = NULL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return_dev:
|
return 0;
|
||||||
return dev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int m_can_open(struct net_device *dev)
|
static int m_can_open(struct net_device *dev)
|
||||||
|
@ -1656,11 +1647,16 @@ static int m_can_plat_probe(struct platform_device *pdev)
|
||||||
tx_fifo_size = mram_config_vals[7];
|
tx_fifo_size = mram_config_vals[7];
|
||||||
|
|
||||||
/* allocate the m_can device */
|
/* allocate the m_can device */
|
||||||
dev = alloc_m_can_dev(pdev, addr, tx_fifo_size);
|
dev = alloc_candev(sizeof(*priv), tx_fifo_size);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto disable_cclk_ret;
|
goto disable_cclk_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = m_can_dev_setup(pdev, dev, addr);
|
||||||
|
if (ret)
|
||||||
|
goto failed_free_dev;
|
||||||
|
|
||||||
priv = netdev_priv(dev);
|
priv = netdev_priv(dev);
|
||||||
dev->irq = irq;
|
dev->irq = irq;
|
||||||
priv->device = &pdev->dev;
|
priv->device = &pdev->dev;
|
||||||
|
|
Loading…
Reference in a new issue