aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/pch_can.c
diff options
context:
space:
mode:
authorTomoya <tomoya-linux@dsn.okisemi.com>2010-12-12 15:24:22 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-13 15:24:26 -0500
commita6f6d6b51b110e661ae5f862d60c27da4970bec6 (patch)
tree8a0c98c4d4a5098d6f99baddaceae0e348d8308c /drivers/net/can/pch_can.c
parentc755145649fa73bd197ac1a73d141047c61b543a (diff)
pch_can: Move MSI processing to probe/remove processing
Currently, in case this driver is integrated as module, and when this module is re-installed, no interrupts is to be occurred. For the above issue, move MSI processing to open/release processing. Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can/pch_can.c')
-rw-r--r--drivers/net/can/pch_can.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index a1fd3be69a81..ace1fe790ce0 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -845,15 +845,6 @@ static int pch_can_open(struct net_device *ndev)
845 struct pch_can_priv *priv = netdev_priv(ndev); 845 struct pch_can_priv *priv = netdev_priv(ndev);
846 int retval; 846 int retval;
847 847
848 retval = pci_enable_msi(priv->dev);
849 if (retval) {
850 netdev_err(ndev, "PCH CAN opened without MSI\n");
851 priv->use_msi = 0;
852 } else {
853 netdev_err(ndev, "PCH CAN opened with MSI\n");
854 priv->use_msi = 1;
855 }
856
857 /* Regstering the interrupt. */ 848 /* Regstering the interrupt. */
858 retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED, 849 retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED,
859 ndev->name, ndev); 850 ndev->name, ndev);
@@ -879,9 +870,6 @@ static int pch_can_open(struct net_device *ndev)
879err_open_candev: 870err_open_candev:
880 free_irq(priv->dev->irq, ndev); 871 free_irq(priv->dev->irq, ndev);
881req_irq_err: 872req_irq_err:
882 if (priv->use_msi)
883 pci_disable_msi(priv->dev);
884
885 pch_can_release(priv); 873 pch_can_release(priv);
886 874
887 return retval; 875 return retval;
@@ -895,8 +883,6 @@ static int pch_close(struct net_device *ndev)
895 napi_disable(&priv->napi); 883 napi_disable(&priv->napi);
896 pch_can_release(priv); 884 pch_can_release(priv);
897 free_irq(priv->dev->irq, ndev); 885 free_irq(priv->dev->irq, ndev);
898 if (priv->use_msi)
899 pci_disable_msi(priv->dev);
900 close_candev(ndev); 886 close_candev(ndev);
901 priv->can.state = CAN_STATE_STOPPED; 887 priv->can.state = CAN_STATE_STOPPED;
902 return 0; 888 return 0;
@@ -975,12 +961,14 @@ static void __devexit pch_can_remove(struct pci_dev *pdev)
975 struct pch_can_priv *priv = netdev_priv(ndev); 961 struct pch_can_priv *priv = netdev_priv(ndev);
976 962
977 unregister_candev(priv->ndev); 963 unregister_candev(priv->ndev);
978 free_candev(priv->ndev);
979 pci_iounmap(pdev, priv->regs); 964 pci_iounmap(pdev, priv->regs);
965 if (priv->use_msi)
966 pci_disable_msi(priv->dev);
980 pci_release_regions(pdev); 967 pci_release_regions(pdev);
981 pci_disable_device(pdev); 968 pci_disable_device(pdev);
982 pci_set_drvdata(pdev, NULL); 969 pci_set_drvdata(pdev, NULL);
983 pch_can_reset(priv); 970 pch_can_reset(priv);
971 free_candev(priv->ndev);
984} 972}
985 973
986#ifdef CONFIG_PM 974#ifdef CONFIG_PM
@@ -1244,6 +1232,15 @@ static int __devinit pch_can_probe(struct pci_dev *pdev,
1244 1232
1245 netif_napi_add(ndev, &priv->napi, pch_can_poll, PCH_RX_OBJ_END); 1233 netif_napi_add(ndev, &priv->napi, pch_can_poll, PCH_RX_OBJ_END);
1246 1234
1235 rc = pci_enable_msi(priv->dev);
1236 if (rc) {
1237 netdev_err(ndev, "PCH CAN opened without MSI\n");
1238 priv->use_msi = 0;
1239 } else {
1240 netdev_err(ndev, "PCH CAN opened with MSI\n");
1241 priv->use_msi = 1;
1242 }
1243
1247 rc = register_candev(ndev); 1244 rc = register_candev(ndev);
1248 if (rc) { 1245 if (rc) {
1249 dev_err(&pdev->dev, "Failed register_candev %d\n", rc); 1246 dev_err(&pdev->dev, "Failed register_candev %d\n", rc);
@@ -1253,6 +1250,8 @@ static int __devinit pch_can_probe(struct pci_dev *pdev,
1253 return 0; 1250 return 0;
1254 1251
1255probe_exit_reg_candev: 1252probe_exit_reg_candev:
1253 if (priv->use_msi)
1254 pci_disable_msi(priv->dev);
1256 free_candev(ndev); 1255 free_candev(ndev);
1257probe_exit_alloc_candev: 1256probe_exit_alloc_candev:
1258 pci_iounmap(pdev, addr); 1257 pci_iounmap(pdev, addr);