diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2011-10-11 13:22:16 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2011-10-14 13:01:17 -0400 |
commit | c2036033604060adc85098bd0e7179a6b2a7b48c (patch) | |
tree | d0a10dedbc40d11d6a359ba5650da370b75047ca /drivers/ata/libata-sff.c | |
parent | e9f7cd51ccfa4d77ca1c01fd50c1c6af55ded1c9 (diff) |
libata: reduce ata_pci_[sff,bmdma]_init_one() size
Turn both helpers (which are used only during LLDs initialization
time and thus are not performance sensitive) into wrappers around
the new ata_pci_init_one() function, this cuts 20 LOC and saves
~1.1k of the output code size (x86-64):
text data bss dec hex filename
21392 0 19 21411 53a3 drivers/ata/libata-sff.o.before
20256 0 19 20275 4f33 drivers/ata/libata-sff.o.after
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r-- | drivers/ata/libata-sff.c | 111 |
1 files changed, 46 insertions, 65 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 2487ea7a507a..1c79a9575fe6 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -2507,31 +2507,10 @@ static const struct ata_port_info *ata_sff_find_valid_pi( | |||
2507 | return NULL; | 2507 | return NULL; |
2508 | } | 2508 | } |
2509 | 2509 | ||
2510 | /** | 2510 | static int ata_pci_init_one(struct pci_dev *pdev, |
2511 | * ata_pci_sff_init_one - Initialize/register PIO-only PCI IDE controller | 2511 | const struct ata_port_info * const *ppi, |
2512 | * @pdev: Controller to be initialized | 2512 | struct scsi_host_template *sht, void *host_priv, |
2513 | * @ppi: array of port_info, must be enough for two ports | 2513 | int hflags, bool bmdma) |
2514 | * @sht: scsi_host_template to use when registering the host | ||
2515 | * @host_priv: host private_data | ||
2516 | * @hflag: host flags | ||
2517 | * | ||
2518 | * This is a helper function which can be called from a driver's | ||
2519 | * xxx_init_one() probe function if the hardware uses traditional | ||
2520 | * IDE taskfile registers and is PIO only. | ||
2521 | * | ||
2522 | * ASSUMPTION: | ||
2523 | * Nobody makes a single channel controller that appears solely as | ||
2524 | * the secondary legacy port on PCI. | ||
2525 | * | ||
2526 | * LOCKING: | ||
2527 | * Inherited from PCI layer (may sleep). | ||
2528 | * | ||
2529 | * RETURNS: | ||
2530 | * Zero on success, negative on errno-based value on error. | ||
2531 | */ | ||
2532 | int ata_pci_sff_init_one(struct pci_dev *pdev, | ||
2533 | const struct ata_port_info * const *ppi, | ||
2534 | struct scsi_host_template *sht, void *host_priv, int hflag) | ||
2535 | { | 2514 | { |
2536 | struct device *dev = &pdev->dev; | 2515 | struct device *dev = &pdev->dev; |
2537 | const struct ata_port_info *pi; | 2516 | const struct ata_port_info *pi; |
@@ -2553,14 +2532,22 @@ int ata_pci_sff_init_one(struct pci_dev *pdev, | |||
2553 | if (rc) | 2532 | if (rc) |
2554 | goto out; | 2533 | goto out; |
2555 | 2534 | ||
2556 | /* prepare and activate SFF host */ | 2535 | if (bmdma) |
2557 | rc = ata_pci_sff_prepare_host(pdev, ppi, &host); | 2536 | /* prepare and activate BMDMA host */ |
2537 | rc = ata_pci_bmdma_prepare_host(pdev, ppi, &host); | ||
2538 | else | ||
2539 | /* prepare and activate SFF host */ | ||
2540 | rc = ata_pci_sff_prepare_host(pdev, ppi, &host); | ||
2558 | if (rc) | 2541 | if (rc) |
2559 | goto out; | 2542 | goto out; |
2560 | host->private_data = host_priv; | 2543 | host->private_data = host_priv; |
2561 | host->flags |= hflag; | 2544 | host->flags |= hflags; |
2562 | 2545 | ||
2563 | rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht); | 2546 | if (bmdma) { |
2547 | pci_set_master(pdev); | ||
2548 | rc = ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht); | ||
2549 | } else | ||
2550 | rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht); | ||
2564 | out: | 2551 | out: |
2565 | if (rc == 0) | 2552 | if (rc == 0) |
2566 | devres_remove_group(&pdev->dev, NULL); | 2553 | devres_remove_group(&pdev->dev, NULL); |
@@ -2569,6 +2556,35 @@ out: | |||
2569 | 2556 | ||
2570 | return rc; | 2557 | return rc; |
2571 | } | 2558 | } |
2559 | |||
2560 | /** | ||
2561 | * ata_pci_sff_init_one - Initialize/register PIO-only PCI IDE controller | ||
2562 | * @pdev: Controller to be initialized | ||
2563 | * @ppi: array of port_info, must be enough for two ports | ||
2564 | * @sht: scsi_host_template to use when registering the host | ||
2565 | * @host_priv: host private_data | ||
2566 | * @hflag: host flags | ||
2567 | * | ||
2568 | * This is a helper function which can be called from a driver's | ||
2569 | * xxx_init_one() probe function if the hardware uses traditional | ||
2570 | * IDE taskfile registers and is PIO only. | ||
2571 | * | ||
2572 | * ASSUMPTION: | ||
2573 | * Nobody makes a single channel controller that appears solely as | ||
2574 | * the secondary legacy port on PCI. | ||
2575 | * | ||
2576 | * LOCKING: | ||
2577 | * Inherited from PCI layer (may sleep). | ||
2578 | * | ||
2579 | * RETURNS: | ||
2580 | * Zero on success, negative on errno-based value on error. | ||
2581 | */ | ||
2582 | int ata_pci_sff_init_one(struct pci_dev *pdev, | ||
2583 | const struct ata_port_info * const *ppi, | ||
2584 | struct scsi_host_template *sht, void *host_priv, int hflag) | ||
2585 | { | ||
2586 | return ata_pci_init_one(pdev, ppi, sht, host_priv, hflag, 0); | ||
2587 | } | ||
2572 | EXPORT_SYMBOL_GPL(ata_pci_sff_init_one); | 2588 | EXPORT_SYMBOL_GPL(ata_pci_sff_init_one); |
2573 | 2589 | ||
2574 | #endif /* CONFIG_PCI */ | 2590 | #endif /* CONFIG_PCI */ |
@@ -3286,42 +3302,7 @@ int ata_pci_bmdma_init_one(struct pci_dev *pdev, | |||
3286 | struct scsi_host_template *sht, void *host_priv, | 3302 | struct scsi_host_template *sht, void *host_priv, |
3287 | int hflags) | 3303 | int hflags) |
3288 | { | 3304 | { |
3289 | struct device *dev = &pdev->dev; | 3305 | return ata_pci_init_one(pdev, ppi, sht, host_priv, hflags, 1); |
3290 | const struct ata_port_info *pi; | ||
3291 | struct ata_host *host = NULL; | ||
3292 | int rc; | ||
3293 | |||
3294 | DPRINTK("ENTER\n"); | ||
3295 | |||
3296 | pi = ata_sff_find_valid_pi(ppi); | ||
3297 | if (!pi) { | ||
3298 | dev_err(&pdev->dev, "no valid port_info specified\n"); | ||
3299 | return -EINVAL; | ||
3300 | } | ||
3301 | |||
3302 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | ||
3303 | return -ENOMEM; | ||
3304 | |||
3305 | rc = pcim_enable_device(pdev); | ||
3306 | if (rc) | ||
3307 | goto out; | ||
3308 | |||
3309 | /* prepare and activate BMDMA host */ | ||
3310 | rc = ata_pci_bmdma_prepare_host(pdev, ppi, &host); | ||
3311 | if (rc) | ||
3312 | goto out; | ||
3313 | host->private_data = host_priv; | ||
3314 | host->flags |= hflags; | ||
3315 | |||
3316 | pci_set_master(pdev); | ||
3317 | rc = ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht); | ||
3318 | out: | ||
3319 | if (rc == 0) | ||
3320 | devres_remove_group(&pdev->dev, NULL); | ||
3321 | else | ||
3322 | devres_release_group(&pdev->dev, NULL); | ||
3323 | |||
3324 | return rc; | ||
3325 | } | 3306 | } |
3326 | EXPORT_SYMBOL_GPL(ata_pci_bmdma_init_one); | 3307 | EXPORT_SYMBOL_GPL(ata_pci_bmdma_init_one); |
3327 | 3308 | ||