Commit 3e66d013 authored by Christopher R. Baker's avatar Christopher R. Baker Committed by Marc Kleine-Budde

can: populate netdev::dev_id for udev discrimination

My objective is to be able to totally discriminate CAN ports on multi-port
cards via udev so as to rename them to semantically interesting/unique names
for my system (e.g., "ecuCAN" and "auxCAN" instead of "can0" and "can1").

The following patch assigns the dev_id field to match the channel number on all
multi-channel devices. I can only test my two-port Peak PCI card, but it works
as expected: ATTRS{dev_id} now expresses the port number and my udev rules now
unambiguously pick out and rename my individual CAN ports.
Signed-off-by: default avatarChristopher R. Baker <cbaker@rec.ri.cmu.edu>
Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> [PEAK PCAN-USB pro and EMS PCMCIA]
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent c971fa2a
...@@ -323,6 +323,7 @@ static int ems_pci_add_card(struct pci_dev *pdev, ...@@ -323,6 +323,7 @@ static int ems_pci_add_card(struct pci_dev *pdev,
priv->cdr = EMS_PCI_CDR; priv->cdr = EMS_PCI_CDR;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = i;
if (card->version == 1) if (card->version == 1)
/* reset int flag of pita */ /* reset int flag of pita */
......
...@@ -211,6 +211,7 @@ static int ems_pcmcia_add_card(struct pcmcia_device *pdev, unsigned long base) ...@@ -211,6 +211,7 @@ static int ems_pcmcia_add_card(struct pcmcia_device *pdev, unsigned long base)
priv = netdev_priv(dev); priv = netdev_priv(dev);
priv->priv = card; priv->priv = card;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = i;
priv->irq_flags = IRQF_SHARED; priv->irq_flags = IRQF_SHARED;
dev->irq = pdev->irq; dev->irq = pdev->irq;
......
...@@ -270,6 +270,7 @@ static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel, ...@@ -270,6 +270,7 @@ static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel,
priv->reg_base, board->conf_addr, dev->irq); priv->reg_base, board->conf_addr, dev->irq);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = channel;
/* Register SJA1000 device */ /* Register SJA1000 device */
err = register_sja1000dev(dev); err = register_sja1000dev(dev);
......
...@@ -642,6 +642,7 @@ static int peak_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -642,6 +642,7 @@ static int peak_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
icr |= chan->icr_mask; icr |= chan->icr_mask;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = i;
/* Create chain of SJA1000 devices */ /* Create chain of SJA1000 devices */
chan->prev_dev = pci_get_drvdata(pdev); chan->prev_dev = pci_get_drvdata(pdev);
......
...@@ -550,6 +550,7 @@ static int pcan_add_channels(struct pcan_pccard *card) ...@@ -550,6 +550,7 @@ static int pcan_add_channels(struct pcan_pccard *card)
priv = netdev_priv(netdev); priv = netdev_priv(netdev);
priv->priv = card; priv->priv = card;
SET_NETDEV_DEV(netdev, &pdev->dev); SET_NETDEV_DEV(netdev, &pdev->dev);
netdev->dev_id = i;
priv->irq_flags = IRQF_SHARED; priv->irq_flags = IRQF_SHARED;
netdev->irq = pdev->irq; netdev->irq = pdev->irq;
......
...@@ -587,6 +587,7 @@ static int plx_pci_add_card(struct pci_dev *pdev, ...@@ -587,6 +587,7 @@ static int plx_pci_add_card(struct pci_dev *pdev,
priv->cdr = ci->cdr; priv->cdr = ci->cdr;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->dev_id = i;
/* Register SJA1000 device */ /* Register SJA1000 device */
err = register_sja1000dev(dev); err = register_sja1000dev(dev);
......
...@@ -833,6 +833,7 @@ static int softing_pdev_probe(struct platform_device *pdev) ...@@ -833,6 +833,7 @@ static int softing_pdev_probe(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto netdev_failed; goto netdev_failed;
} }
netdev->dev_id = j;
priv = netdev_priv(card->net[j]); priv = netdev_priv(card->net[j]);
priv->index = j; priv->index = j;
ret = softing_netdev_register(netdev); ret = softing_netdev_register(netdev);
......
...@@ -1025,6 +1025,7 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index) ...@@ -1025,6 +1025,7 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index)
netdev->netdev_ops = &esd_usb2_netdev_ops; netdev->netdev_ops = &esd_usb2_netdev_ops;
SET_NETDEV_DEV(netdev, &intf->dev); SET_NETDEV_DEV(netdev, &intf->dev);
netdev->dev_id = index;
err = register_candev(netdev); err = register_candev(netdev);
if (err) { if (err) {
......
...@@ -1530,6 +1530,7 @@ static int kvaser_usb_init_one(struct usb_interface *intf, ...@@ -1530,6 +1530,7 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
netdev->netdev_ops = &kvaser_usb_netdev_ops; netdev->netdev_ops = &kvaser_usb_netdev_ops;
SET_NETDEV_DEV(netdev, &intf->dev); SET_NETDEV_DEV(netdev, &intf->dev);
netdev->dev_id = channel;
dev->nets[channel] = priv; dev->nets[channel] = priv;
......
...@@ -770,6 +770,7 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter, ...@@ -770,6 +770,7 @@ static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter,
usb_set_intfdata(intf, dev); usb_set_intfdata(intf, dev);
SET_NETDEV_DEV(netdev, &intf->dev); SET_NETDEV_DEV(netdev, &intf->dev);
netdev->dev_id = ctrl_idx;
err = register_candev(netdev); err = register_candev(netdev);
if (err) { if (err) {
......
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