aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Einon <mark.einon@gmail.com>2011-10-23 05:22:49 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-23 05:35:12 -0400
commit5da2b1581a24af6a50d40737c44a9ae13d3097b3 (patch)
tree22c7a4f66a98cd32b0e9f8cbc854b636c68a77c6
parent36f2771a70c44b3fbc1be34d5a82e8472437c7ca (diff)
staging: et131x: Remove more forward declarations
Moved functions in et131x.c file to remove the following forward declarations: et131x_soft_reset et131x_isr_handler et131x_device_alloc Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/et131x/et131x.c505
1 files changed, 251 insertions, 254 deletions
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 29476350fca8..44fff21ae50d 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -576,13 +576,10 @@ struct et131x_adapter {
576 struct net_device_stats net_stats; 576 struct net_device_stats net_stats;
577}; 577};
578 578
579void et131x_soft_reset(struct et131x_adapter *adapter);
580void et131x_isr_handler(struct work_struct *work);
581void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); 579void et1310_setup_device_for_multicast(struct et131x_adapter *adapter);
582void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); 580void et1310_setup_device_for_unicast(struct et131x_adapter *adapter);
583void et131x_up(struct net_device *netdev); 581void et131x_up(struct net_device *netdev);
584void et131x_down(struct net_device *netdev); 582void et131x_down(struct net_device *netdev);
585struct net_device *et131x_device_alloc(void);
586void et131x_enable_txrx(struct net_device *netdev); 583void et131x_enable_txrx(struct net_device *netdev);
587void et131x_disable_txrx(struct net_device *netdev); 584void et131x_disable_txrx(struct net_device *netdev);
588int et1310_in_phy_coma(struct et131x_adapter *adapter); 585int et1310_in_phy_coma(struct et131x_adapter *adapter);
@@ -1970,6 +1967,21 @@ void et131x_adapter_setup(struct et131x_adapter *adapter)
1970} 1967}
1971 1968
1972/** 1969/**
1970 * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
1971 * @adapter: pointer to our private adapter structure
1972 */
1973void et131x_soft_reset(struct et131x_adapter *adapter)
1974{
1975 /* Disable MAC Core */
1976 writel(0xc00f0000, &adapter->regs->mac.cfg1);
1977
1978 /* Set everything to a reset value */
1979 writel(0x7F, &adapter->regs->global.sw_reset);
1980 writel(0x000f0000, &adapter->regs->mac.cfg1);
1981 writel(0x00000000, &adapter->regs->mac.cfg1);
1982}
1983
1984/**
1973 * et1310_enable_phy_coma - called when network cable is unplugged 1985 * et1310_enable_phy_coma - called when network cable is unplugged
1974 * @adapter: pointer to our adapter structure 1986 * @adapter: pointer to our adapter structure
1975 * 1987 *
@@ -4097,21 +4109,6 @@ void et131x_error_timer_handler(unsigned long data)
4097} 4109}
4098 4110
4099/** 4111/**
4100 * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
4101 * @adapter: pointer to our private adapter structure
4102 */
4103void et131x_soft_reset(struct et131x_adapter *adapter)
4104{
4105 /* Disable MAC Core */
4106 writel(0xc00f0000, &adapter->regs->mac.cfg1);
4107
4108 /* Set everything to a reset value */
4109 writel(0x7F, &adapter->regs->global.sw_reset);
4110 writel(0x000f0000, &adapter->regs->mac.cfg1);
4111 writel(0x00000000, &adapter->regs->mac.cfg1);
4112}
4113
4114/**
4115 * et131x_adapter_memory_alloc 4112 * et131x_adapter_memory_alloc
4116 * @adapter: pointer to our private adapter structure 4113 * @adapter: pointer to our private adapter structure
4117 * 4114 *
@@ -4365,200 +4362,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter)
4365} 4362}
4366 4363
4367/** 4364/**
4368 * et131x_pci_setup - Perform device initialization
4369 * @pdev: a pointer to the device's pci_dev structure
4370 * @ent: this device's entry in the pci_device_id table
4371 *
4372 * Returns 0 on success, errno on failure (as defined in errno.h)
4373 *
4374 * Registered in the pci_driver structure, this function is called when the
4375 * PCI subsystem finds a new PCI device which matches the information
4376 * contained in the pci_device_id table. This routine is the equivalent to
4377 * a device insertion routine.
4378 */
4379static int __devinit et131x_pci_setup(struct pci_dev *pdev,
4380 const struct pci_device_id *ent)
4381{
4382 int result;
4383 struct net_device *netdev;
4384 struct et131x_adapter *adapter;
4385 int ii;
4386
4387 result = pci_enable_device(pdev);
4388 if (result) {
4389 dev_err(&pdev->dev, "pci_enable_device() failed\n");
4390 goto err_out;
4391 }
4392
4393 /* Perform some basic PCI checks */
4394 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
4395 dev_err(&pdev->dev, "Can't find PCI device's base address\n");
4396 goto err_disable;
4397 }
4398
4399 if (pci_request_regions(pdev, DRIVER_NAME)) {
4400 dev_err(&pdev->dev, "Can't get PCI resources\n");
4401 goto err_disable;
4402 }
4403
4404 pci_set_master(pdev);
4405
4406 /* Check the DMA addressing support of this device */
4407 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
4408 result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
4409 if (result) {
4410 dev_err(&pdev->dev,
4411 "Unable to obtain 64 bit DMA for consistent allocations\n");
4412 goto err_release_res;
4413 }
4414 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
4415 result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
4416 if (result) {
4417 dev_err(&pdev->dev,
4418 "Unable to obtain 32 bit DMA for consistent allocations\n");
4419 goto err_release_res;
4420 }
4421 } else {
4422 dev_err(&pdev->dev, "No usable DMA addressing method\n");
4423 result = -EIO;
4424 goto err_release_res;
4425 }
4426
4427 /* Allocate netdev and private adapter structs */
4428 netdev = et131x_device_alloc();
4429 if (!netdev) {
4430 dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
4431 result = -ENOMEM;
4432 goto err_release_res;
4433 }
4434
4435 SET_NETDEV_DEV(netdev, &pdev->dev);
4436 et131x_set_ethtool_ops(netdev);
4437
4438 adapter = et131x_adapter_init(netdev, pdev);
4439
4440 /* Initialise the PCI setup for the device */
4441 et131x_pci_init(adapter, pdev);
4442
4443 /* Map the bus-relative registers to system virtual memory */
4444 adapter->regs = pci_ioremap_bar(pdev, 0);
4445 if (!adapter->regs) {
4446 dev_err(&pdev->dev, "Cannot map device registers\n");
4447 result = -ENOMEM;
4448 goto err_free_dev;
4449 }
4450
4451 /* If Phy COMA mode was enabled when we went down, disable it here. */
4452 writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr);
4453
4454 /* Issue a global reset to the et1310 */
4455 et131x_soft_reset(adapter);
4456
4457 /* Disable all interrupts (paranoid) */
4458 et131x_disable_interrupts(adapter);
4459
4460 /* Allocate DMA memory */
4461 result = et131x_adapter_memory_alloc(adapter);
4462 if (result) {
4463 dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
4464 goto err_iounmap;
4465 }
4466
4467 /* Init send data structures */
4468 et131x_init_send(adapter);
4469
4470 /* Set up the task structure for the ISR's deferred handler */
4471 INIT_WORK(&adapter->task, et131x_isr_handler);
4472
4473 /* Copy address into the net_device struct */
4474 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
4475
4476 /* Init variable for counting how long we do not have link status */
4477 adapter->boot_coma = 0;
4478 et1310_disable_phy_coma(adapter);
4479
4480 /* Setup the mii_bus struct */
4481 adapter->mii_bus = mdiobus_alloc();
4482 if (!adapter->mii_bus) {
4483 dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n");
4484 goto err_mem_free;
4485 }
4486
4487 adapter->mii_bus->name = "et131x_eth_mii";
4488 snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
4489 (adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
4490 adapter->mii_bus->priv = netdev;
4491 adapter->mii_bus->read = et131x_mdio_read;
4492 adapter->mii_bus->write = et131x_mdio_write;
4493 adapter->mii_bus->reset = et131x_mdio_reset;
4494 adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
4495 if (!adapter->mii_bus->irq) {
4496 dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
4497 goto err_mdio_free;
4498 }
4499
4500 for (ii = 0; ii < PHY_MAX_ADDR; ii++)
4501 adapter->mii_bus->irq[ii] = PHY_POLL;
4502
4503 if (mdiobus_register(adapter->mii_bus)) {
4504 dev_err(&pdev->dev, "failed to register MII bus\n");
4505 mdiobus_free(adapter->mii_bus);
4506 goto err_mdio_free_irq;
4507 }
4508
4509 if (et131x_mii_probe(netdev)) {
4510 dev_err(&pdev->dev, "failed to probe MII bus\n");
4511 goto err_mdio_unregister;
4512 }
4513
4514 /* Setup et1310 as per the documentation */
4515 et131x_adapter_setup(adapter);
4516
4517 /* We can enable interrupts now
4518 *
4519 * NOTE - Because registration of interrupt handler is done in the
4520 * device's open(), defer enabling device interrupts to that
4521 * point
4522 */
4523
4524 /* Register the net_device struct with the Linux network layer */
4525 result = register_netdev(netdev);
4526 if (result != 0) {
4527 dev_err(&pdev->dev, "register_netdev() failed\n");
4528 goto err_mdio_unregister;
4529 }
4530
4531 /* Register the net_device struct with the PCI subsystem. Save a copy
4532 * of the PCI config space for this device now that the device has
4533 * been initialized, just in case it needs to be quickly restored.
4534 */
4535 pci_set_drvdata(pdev, netdev);
4536 pci_save_state(adapter->pdev);
4537
4538 return result;
4539
4540err_mdio_unregister:
4541 mdiobus_unregister(adapter->mii_bus);
4542err_mdio_free_irq:
4543 kfree(adapter->mii_bus->irq);
4544err_mdio_free:
4545 mdiobus_free(adapter->mii_bus);
4546err_mem_free:
4547 et131x_adapter_memory_free(adapter);
4548err_iounmap:
4549 iounmap(adapter->regs);
4550err_free_dev:
4551 pci_dev_put(pdev);
4552 free_netdev(netdev);
4553err_release_res:
4554 pci_release_regions(pdev);
4555err_disable:
4556 pci_disable_device(pdev);
4557err_out:
4558 return result;
4559}
4560
4561/**
4562 * et131x_pci_remove 4365 * et131x_pci_remove
4563 * @pdev: a pointer to the device's pci_dev structure 4366 * @pdev: a pointer to the device's pci_dev structure
4564 * 4367 *
@@ -4614,48 +4417,6 @@ static int et131x_resume(struct device *dev)
4614 return 0; 4417 return 0;
4615} 4418}
4616 4419
4617static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
4618#define ET131X_PM_OPS (&et131x_pm_ops)
4619#else
4620#define ET131X_PM_OPS NULL
4621#endif
4622
4623static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
4624 { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
4625 { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
4626 {0,}
4627};
4628MODULE_DEVICE_TABLE(pci, et131x_pci_table);
4629
4630static struct pci_driver et131x_driver = {
4631 .name = DRIVER_NAME,
4632 .id_table = et131x_pci_table,
4633 .probe = et131x_pci_setup,
4634 .remove = __devexit_p(et131x_pci_remove),
4635 .driver.pm = ET131X_PM_OPS,
4636};
4637
4638/**
4639 * et131x_init_module - The "main" entry point called on driver initialization
4640 *
4641 * Returns 0 on success, errno on failure (as defined in errno.h)
4642 */
4643static int __init et131x_init_module(void)
4644{
4645 return pci_register_driver(&et131x_driver);
4646}
4647
4648/**
4649 * et131x_cleanup_module - The entry point called on driver cleanup
4650 */
4651static void __exit et131x_cleanup_module(void)
4652{
4653 pci_unregister_driver(&et131x_driver);
4654}
4655
4656module_init(et131x_init_module);
4657module_exit(et131x_cleanup_module);
4658
4659/* ISR functions */ 4420/* ISR functions */
4660 4421
4661/** 4422/**
@@ -5528,3 +5289,239 @@ struct net_device *et131x_device_alloc(void)
5528 return netdev; 5289 return netdev;
5529} 5290}
5530 5291
5292/**
5293 * et131x_pci_setup - Perform device initialization
5294 * @pdev: a pointer to the device's pci_dev structure
5295 * @ent: this device's entry in the pci_device_id table
5296 *
5297 * Returns 0 on success, errno on failure (as defined in errno.h)
5298 *
5299 * Registered in the pci_driver structure, this function is called when the
5300 * PCI subsystem finds a new PCI device which matches the information
5301 * contained in the pci_device_id table. This routine is the equivalent to
5302 * a device insertion routine.
5303 */
5304static int __devinit et131x_pci_setup(struct pci_dev *pdev,
5305 const struct pci_device_id *ent)
5306{
5307 int result;
5308 struct net_device *netdev;
5309 struct et131x_adapter *adapter;
5310 int ii;
5311
5312 result = pci_enable_device(pdev);
5313 if (result) {
5314 dev_err(&pdev->dev, "pci_enable_device() failed\n");
5315 goto err_out;
5316 }
5317
5318 /* Perform some basic PCI checks */
5319 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
5320 dev_err(&pdev->dev, "Can't find PCI device's base address\n");
5321 goto err_disable;
5322 }
5323
5324 if (pci_request_regions(pdev, DRIVER_NAME)) {
5325 dev_err(&pdev->dev, "Can't get PCI resources\n");
5326 goto err_disable;
5327 }
5328
5329 pci_set_master(pdev);
5330
5331 /* Check the DMA addressing support of this device */
5332 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
5333 result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
5334 if (result) {
5335 dev_err(&pdev->dev,
5336 "Unable to obtain 64 bit DMA for consistent allocations\n");
5337 goto err_release_res;
5338 }
5339 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
5340 result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
5341 if (result) {
5342 dev_err(&pdev->dev,
5343 "Unable to obtain 32 bit DMA for consistent allocations\n");
5344 goto err_release_res;
5345 }
5346 } else {
5347 dev_err(&pdev->dev, "No usable DMA addressing method\n");
5348 result = -EIO;
5349 goto err_release_res;
5350 }
5351
5352 /* Allocate netdev and private adapter structs */
5353 netdev = et131x_device_alloc();
5354 if (!netdev) {
5355 dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
5356 result = -ENOMEM;
5357 goto err_release_res;
5358 }
5359
5360 SET_NETDEV_DEV(netdev, &pdev->dev);
5361 et131x_set_ethtool_ops(netdev);
5362
5363 adapter = et131x_adapter_init(netdev, pdev);
5364
5365 /* Initialise the PCI setup for the device */
5366 et131x_pci_init(adapter, pdev);
5367
5368 /* Map the bus-relative registers to system virtual memory */
5369 adapter->regs = pci_ioremap_bar(pdev, 0);
5370 if (!adapter->regs) {
5371 dev_err(&pdev->dev, "Cannot map device registers\n");
5372 result = -ENOMEM;
5373 goto err_free_dev;
5374 }
5375
5376 /* If Phy COMA mode was enabled when we went down, disable it here. */
5377 writel(ET_PMCSR_INIT, &adapter->regs->global.pm_csr);
5378
5379 /* Issue a global reset to the et1310 */
5380 et131x_soft_reset(adapter);
5381
5382 /* Disable all interrupts (paranoid) */
5383 et131x_disable_interrupts(adapter);
5384
5385 /* Allocate DMA memory */
5386 result = et131x_adapter_memory_alloc(adapter);
5387 if (result) {
5388 dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
5389 goto err_iounmap;
5390 }
5391
5392 /* Init send data structures */
5393 et131x_init_send(adapter);
5394
5395 /* Set up the task structure for the ISR's deferred handler */
5396 INIT_WORK(&adapter->task, et131x_isr_handler);
5397
5398 /* Copy address into the net_device struct */
5399 memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
5400
5401 /* Init variable for counting how long we do not have link status */
5402 adapter->boot_coma = 0;
5403 et1310_disable_phy_coma(adapter);
5404
5405 /* Setup the mii_bus struct */
5406 adapter->mii_bus = mdiobus_alloc();
5407 if (!adapter->mii_bus) {
5408 dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n");
5409 goto err_mem_free;
5410 }
5411
5412 adapter->mii_bus->name = "et131x_eth_mii";
5413 snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
5414 (adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
5415 adapter->mii_bus->priv = netdev;
5416 adapter->mii_bus->read = et131x_mdio_read;
5417 adapter->mii_bus->write = et131x_mdio_write;
5418 adapter->mii_bus->reset = et131x_mdio_reset;
5419 adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
5420 if (!adapter->mii_bus->irq) {
5421 dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
5422 goto err_mdio_free;
5423 }
5424
5425 for (ii = 0; ii < PHY_MAX_ADDR; ii++)
5426 adapter->mii_bus->irq[ii] = PHY_POLL;
5427
5428 if (mdiobus_register(adapter->mii_bus)) {
5429 dev_err(&pdev->dev, "failed to register MII bus\n");
5430 mdiobus_free(adapter->mii_bus);
5431 goto err_mdio_free_irq;
5432 }
5433
5434 if (et131x_mii_probe(netdev)) {
5435 dev_err(&pdev->dev, "failed to probe MII bus\n");
5436 goto err_mdio_unregister;
5437 }
5438
5439 /* Setup et1310 as per the documentation */
5440 et131x_adapter_setup(adapter);
5441
5442 /* We can enable interrupts now
5443 *
5444 * NOTE - Because registration of interrupt handler is done in the
5445 * device's open(), defer enabling device interrupts to that
5446 * point
5447 */
5448
5449 /* Register the net_device struct with the Linux network layer */
5450 result = register_netdev(netdev);
5451 if (result != 0) {
5452 dev_err(&pdev->dev, "register_netdev() failed\n");
5453 goto err_mdio_unregister;
5454 }
5455
5456 /* Register the net_device struct with the PCI subsystem. Save a copy
5457 * of the PCI config space for this device now that the device has
5458 * been initialized, just in case it needs to be quickly restored.
5459 */
5460 pci_set_drvdata(pdev, netdev);
5461 pci_save_state(adapter->pdev);
5462
5463 return result;
5464
5465err_mdio_unregister:
5466 mdiobus_unregister(adapter->mii_bus);
5467err_mdio_free_irq:
5468 kfree(adapter->mii_bus->irq);
5469err_mdio_free:
5470 mdiobus_free(adapter->mii_bus);
5471err_mem_free:
5472 et131x_adapter_memory_free(adapter);
5473err_iounmap:
5474 iounmap(adapter->regs);
5475err_free_dev:
5476 pci_dev_put(pdev);
5477 free_netdev(netdev);
5478err_release_res:
5479 pci_release_regions(pdev);
5480err_disable:
5481 pci_disable_device(pdev);
5482err_out:
5483 return result;
5484}
5485
5486static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
5487#define ET131X_PM_OPS (&et131x_pm_ops)
5488#else
5489#define ET131X_PM_OPS NULL
5490#endif
5491
5492static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
5493 { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
5494 { PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
5495 {0,}
5496};
5497MODULE_DEVICE_TABLE(pci, et131x_pci_table);
5498
5499static struct pci_driver et131x_driver = {
5500 .name = DRIVER_NAME,
5501 .id_table = et131x_pci_table,
5502 .probe = et131x_pci_setup,
5503 .remove = __devexit_p(et131x_pci_remove),
5504 .driver.pm = ET131X_PM_OPS,
5505};
5506
5507/**
5508 * et131x_init_module - The "main" entry point called on driver initialization
5509 *
5510 * Returns 0 on success, errno on failure (as defined in errno.h)
5511 */
5512static int __init et131x_init_module(void)
5513{
5514 return pci_register_driver(&et131x_driver);
5515}
5516
5517/**
5518 * et131x_cleanup_module - The entry point called on driver cleanup
5519 */
5520static void __exit et131x_cleanup_module(void)
5521{
5522 pci_unregister_driver(&et131x_driver);
5523}
5524
5525module_init(et131x_init_module);
5526module_exit(et131x_cleanup_module);
5527