Skip to content

Commit 6b17a59

Browse files
Thomas Reichingerkuba-moo
Thomas Reichinger
authored andcommitted
arcnet: restoring support for multiple Sohard Arcnet cards
Probe of Sohard Arcnet cards fails, if 2 or more cards are installed in a system. See kernel log: [ 2.759203] arcnet: arcnet loaded [ 2.763648] arcnet:com20020: COM20020 chipset support (by David Woodhouse et al.) [ 2.770585] arcnet:com20020_pci: COM20020 PCI support [ 2.772295] com20020 0000:02:00.0: enabling device (0000 -> 0003) [ 2.772354] (unnamed net_device) (uninitialized): PLX-PCI Controls ... [ 3.071301] com20020 0000:02:00.0 arc0-0 (uninitialized): PCI COM20020: station FFh found at F080h, IRQ 101. [ 3.071305] com20020 0000:02:00.0 arc0-0 (uninitialized): Using CKP 64 - data rate 2.5 Mb/s [ 3.071534] com20020 0000:07:00.0: enabling device (0000 -> 0003) [ 3.071581] (unnamed net_device) (uninitialized): PLX-PCI Controls ... [ 3.369501] com20020 0000:07:00.0: Led pci:green:tx:0-0 renamed to pci:green:tx:0-0_1 due to name collision [ 3.369535] com20020 0000:07:00.0: Led pci:red:recon:0-0 renamed to pci:red:recon:0-0_1 due to name collision [ 3.370586] com20020 0000:07:00.0 arc0-0 (uninitialized): PCI COM20020: station E1h found at C000h, IRQ 35. [ 3.370589] com20020 0000:07:00.0 arc0-0 (uninitialized): Using CKP 64 - data rate 2.5 Mb/s [ 3.370608] com20020: probe of 0000:07:00.0 failed with error -5 commit 5ef216c ("arcnet: com20020-pci: add rotary index support") changes the device name of all COM20020 based PCI cards, even if only some cards support this: snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i); The error happens because all Sohard Arcnet cards would be called arc0-0, since the Sohard Arcnet cards don't have a PLX rotary coder. I.e. EAE Arcnet cards have a PLX rotary coder, which sets the first decimal, ensuring unique devices names. This patch adds two new card feature flags to indicate which cards support LEDs and the PLX rotary coder. For EAE based cards the names still depend on the PLX rotary coder (untested, since missing EAE hardware). For Sohard based cards, this patch will result in devices being called arc0, arc1, ... (tested). Signed-off-by: Thomas Reichinger <[email protected]> Fixes: 5ef216c ("arcnet: com20020-pci: add rotary index support") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent db3fada commit 6b17a59

File tree

2 files changed

+48
-43
lines changed

2 files changed

+48
-43
lines changed

drivers/net/arcnet/arcdevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ do { \
186186
#define ARC_IS_5MBIT 1 /* card default speed is 5MBit */
187187
#define ARC_CAN_10MBIT 2 /* card uses COM20022, supporting 10MBit,
188188
but default is 2.5MBit. */
189+
#define ARC_HAS_LED 4 /* card has software controlled LEDs */
190+
#define ARC_HAS_ROTARY 8 /* card has rotary encoder */
189191

190192
/* information needed to define an encapsulation driver */
191193
struct ArcProto {

drivers/net/arcnet/com20020-pci.c

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
213213
if (!strncmp(ci->name, "EAE PLX-PCI FB2", 15))
214214
lp->backplane = 1;
215215

216-
/* Get the dev_id from the PLX rotary coder */
217-
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
218-
dev_id_mask = 0x3;
219-
dev->dev_id = (inb(priv->misc + ci->rotary) >> 4) & dev_id_mask;
220-
221-
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i);
216+
if (ci->flags & ARC_HAS_ROTARY) {
217+
/* Get the dev_id from the PLX rotary coder */
218+
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
219+
dev_id_mask = 0x3;
220+
dev->dev_id = (inb(priv->misc + ci->rotary) >> 4) & dev_id_mask;
221+
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i);
222+
}
222223

223224
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
224225
pr_err("IO address %Xh is empty!\n", ioaddr);
@@ -230,6 +231,10 @@ static int com20020pci_probe(struct pci_dev *pdev,
230231
goto err_free_arcdev;
231232
}
232233

234+
ret = com20020_found(dev, IRQF_SHARED);
235+
if (ret)
236+
goto err_free_arcdev;
237+
233238
card = devm_kzalloc(&pdev->dev, sizeof(struct com20020_dev),
234239
GFP_KERNEL);
235240
if (!card) {
@@ -239,41 +244,39 @@ static int com20020pci_probe(struct pci_dev *pdev,
239244

240245
card->index = i;
241246
card->pci_priv = priv;
242-
card->tx_led.brightness_set = led_tx_set;
243-
card->tx_led.default_trigger = devm_kasprintf(&pdev->dev,
244-
GFP_KERNEL, "arc%d-%d-tx",
245-
dev->dev_id, i);
246-
card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
247-
"pci:green:tx:%d-%d",
248-
dev->dev_id, i);
249-
250-
card->tx_led.dev = &dev->dev;
251-
card->recon_led.brightness_set = led_recon_set;
252-
card->recon_led.default_trigger = devm_kasprintf(&pdev->dev,
253-
GFP_KERNEL, "arc%d-%d-recon",
254-
dev->dev_id, i);
255-
card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
256-
"pci:red:recon:%d-%d",
257-
dev->dev_id, i);
258-
card->recon_led.dev = &dev->dev;
259-
card->dev = dev;
260-
261-
ret = devm_led_classdev_register(&pdev->dev, &card->tx_led);
262-
if (ret)
263-
goto err_free_arcdev;
264247

265-
ret = devm_led_classdev_register(&pdev->dev, &card->recon_led);
266-
if (ret)
267-
goto err_free_arcdev;
268-
269-
dev_set_drvdata(&dev->dev, card);
270-
271-
ret = com20020_found(dev, IRQF_SHARED);
272-
if (ret)
273-
goto err_free_arcdev;
274-
275-
devm_arcnet_led_init(dev, dev->dev_id, i);
248+
if (ci->flags & ARC_HAS_LED) {
249+
card->tx_led.brightness_set = led_tx_set;
250+
card->tx_led.default_trigger = devm_kasprintf(&pdev->dev,
251+
GFP_KERNEL, "arc%d-%d-tx",
252+
dev->dev_id, i);
253+
card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
254+
"pci:green:tx:%d-%d",
255+
dev->dev_id, i);
256+
257+
card->tx_led.dev = &dev->dev;
258+
card->recon_led.brightness_set = led_recon_set;
259+
card->recon_led.default_trigger = devm_kasprintf(&pdev->dev,
260+
GFP_KERNEL, "arc%d-%d-recon",
261+
dev->dev_id, i);
262+
card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
263+
"pci:red:recon:%d-%d",
264+
dev->dev_id, i);
265+
card->recon_led.dev = &dev->dev;
266+
267+
ret = devm_led_classdev_register(&pdev->dev, &card->tx_led);
268+
if (ret)
269+
goto err_free_arcdev;
270+
271+
ret = devm_led_classdev_register(&pdev->dev, &card->recon_led);
272+
if (ret)
273+
goto err_free_arcdev;
274+
275+
dev_set_drvdata(&dev->dev, card);
276+
devm_arcnet_led_init(dev, dev->dev_id, i);
277+
}
276278

279+
card->dev = dev;
277280
list_add(&card->list, &priv->list_dev);
278281
continue;
279282

@@ -329,7 +332,7 @@ static struct com20020_pci_card_info card_info_5mbit = {
329332
};
330333

331334
static struct com20020_pci_card_info card_info_sohard = {
332-
.name = "PLX-PCI",
335+
.name = "SOHARD SH ARC-PCI",
333336
.devcount = 1,
334337
/* SOHARD needs PCI base addr 4 */
335338
.chan_map_tbl = {
@@ -364,7 +367,7 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
364367
},
365368
},
366369
.rotary = 0x0,
367-
.flags = ARC_CAN_10MBIT,
370+
.flags = ARC_HAS_ROTARY | ARC_HAS_LED | ARC_CAN_10MBIT,
368371
};
369372

370373
static struct com20020_pci_card_info card_info_eae_ma1 = {
@@ -396,7 +399,7 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
396399
},
397400
},
398401
.rotary = 0x0,
399-
.flags = ARC_CAN_10MBIT,
402+
.flags = ARC_HAS_ROTARY | ARC_HAS_LED | ARC_CAN_10MBIT,
400403
};
401404

402405
static struct com20020_pci_card_info card_info_eae_fb2 = {
@@ -421,7 +424,7 @@ static struct com20020_pci_card_info card_info_eae_fb2 = {
421424
},
422425
},
423426
.rotary = 0x0,
424-
.flags = ARC_CAN_10MBIT,
427+
.flags = ARC_HAS_ROTARY | ARC_HAS_LED | ARC_CAN_10MBIT,
425428
};
426429

427430
static const struct pci_device_id com20020pci_id_table[] = {

0 commit comments

Comments
 (0)