aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/ohci1394.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-03-24 15:49:01 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-04-18 11:55:30 -0400
commitd09c68038306442e3566366b6988a6dd83481251 (patch)
tree1effe6065feb07c458e337a8fa0f06c49da24b32 /drivers/ieee1394/ohci1394.c
parente351c4d069254b1267b66a3b101ece7547178485 (diff)
ieee1394: ohci1394: unroll a macro with return
We don't want to hide something like return in a preprocessor macro. Unroll the macro and use a goto, which also reduces the size of ohci1394.ko. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394/ohci1394.c')
-rw-r--r--drivers/ieee1394/ohci1394.c92
1 files changed, 54 insertions, 38 deletions
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 4665a6fb07d8..a660222fc532 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -2984,13 +2984,6 @@ static struct hpsb_host_driver ohci1394_driver = {
2984 * PCI Driver Interface functions * 2984 * PCI Driver Interface functions *
2985 ***********************************/ 2985 ***********************************/
2986 2986
2987#define FAIL(err, fmt, args...) \
2988do { \
2989 PRINT_G(KERN_ERR, fmt , ## args); \
2990 ohci1394_pci_remove(dev); \
2991 return err; \
2992} while (0)
2993
2994#ifdef CONFIG_PPC_PMAC 2987#ifdef CONFIG_PPC_PMAC
2995static void ohci1394_pmac_on(struct pci_dev *dev) 2988static void ohci1394_pmac_on(struct pci_dev *dev)
2996{ 2989{
@@ -3026,15 +3019,21 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3026 struct hpsb_host *host; 3019 struct hpsb_host *host;
3027 struct ti_ohci *ohci; /* shortcut to currently handled device */ 3020 struct ti_ohci *ohci; /* shortcut to currently handled device */
3028 resource_size_t ohci_base; 3021 resource_size_t ohci_base;
3022 int err = -ENOMEM;
3029 3023
3030 ohci1394_pmac_on(dev); 3024 ohci1394_pmac_on(dev);
3031 if (pci_enable_device(dev)) 3025 if (pci_enable_device(dev)) {
3032 FAIL(-ENXIO, "Failed to enable OHCI hardware"); 3026 PRINT_G(KERN_ERR, "Failed to enable OHCI hardware");
3027 err = -ENXIO;
3028 goto err;
3029 }
3033 pci_set_master(dev); 3030 pci_set_master(dev);
3034 3031
3035 host = hpsb_alloc_host(&ohci1394_driver, sizeof(struct ti_ohci), &dev->dev); 3032 host = hpsb_alloc_host(&ohci1394_driver, sizeof(struct ti_ohci), &dev->dev);
3036 if (!host) FAIL(-ENOMEM, "Failed to allocate host structure"); 3033 if (!host) {
3037 3034 PRINT_G(KERN_ERR, "Failed to allocate host structure");
3035 goto err;
3036 }
3038 ohci = host->hostdata; 3037 ohci = host->hostdata;
3039 ohci->dev = dev; 3038 ohci->dev = dev;
3040 ohci->host = host; 3039 ohci->host = host;
@@ -3083,15 +3082,20 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3083 (unsigned long long)pci_resource_len(dev, 0)); 3082 (unsigned long long)pci_resource_len(dev, 0));
3084 3083
3085 if (!request_mem_region(ohci_base, OHCI1394_REGISTER_SIZE, 3084 if (!request_mem_region(ohci_base, OHCI1394_REGISTER_SIZE,
3086 OHCI1394_DRIVER_NAME)) 3085 OHCI1394_DRIVER_NAME)) {
3087 FAIL(-ENOMEM, "MMIO resource (0x%llx - 0x%llx) unavailable", 3086 PRINT_G(KERN_ERR, "MMIO resource (0x%llx - 0x%llx) unavailable",
3088 (unsigned long long)ohci_base, 3087 (unsigned long long)ohci_base,
3089 (unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE); 3088 (unsigned long long)ohci_base + OHCI1394_REGISTER_SIZE);
3089 goto err;
3090 }
3090 ohci->init_state = OHCI_INIT_HAVE_MEM_REGION; 3091 ohci->init_state = OHCI_INIT_HAVE_MEM_REGION;
3091 3092
3092 ohci->registers = ioremap(ohci_base, OHCI1394_REGISTER_SIZE); 3093 ohci->registers = ioremap(ohci_base, OHCI1394_REGISTER_SIZE);
3093 if (ohci->registers == NULL) 3094 if (ohci->registers == NULL) {
3094 FAIL(-ENXIO, "Failed to remap registers - card not accessible"); 3095 PRINT_G(KERN_ERR, "Failed to remap registers");
3096 err = -ENXIO;
3097 goto err;
3098 }
3095 ohci->init_state = OHCI_INIT_HAVE_IOMAPPING; 3099 ohci->init_state = OHCI_INIT_HAVE_IOMAPPING;
3096 DBGMSG("Remapped memory spaces reg 0x%p", ohci->registers); 3100 DBGMSG("Remapped memory spaces reg 0x%p", ohci->registers);
3097 3101
@@ -3099,16 +3103,20 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3099 ohci->csr_config_rom_cpu = 3103 ohci->csr_config_rom_cpu =
3100 pci_alloc_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN, 3104 pci_alloc_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN,
3101 &ohci->csr_config_rom_bus); 3105 &ohci->csr_config_rom_bus);
3102 if (ohci->csr_config_rom_cpu == NULL) 3106 if (ohci->csr_config_rom_cpu == NULL) {
3103 FAIL(-ENOMEM, "Failed to allocate buffer config rom"); 3107 PRINT_G(KERN_ERR, "Failed to allocate buffer config rom");
3108 goto err;
3109 }
3104 ohci->init_state = OHCI_INIT_HAVE_CONFIG_ROM_BUFFER; 3110 ohci->init_state = OHCI_INIT_HAVE_CONFIG_ROM_BUFFER;
3105 3111
3106 /* self-id dma buffer allocation */ 3112 /* self-id dma buffer allocation */
3107 ohci->selfid_buf_cpu = 3113 ohci->selfid_buf_cpu =
3108 pci_alloc_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE, 3114 pci_alloc_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE,
3109 &ohci->selfid_buf_bus); 3115 &ohci->selfid_buf_bus);
3110 if (ohci->selfid_buf_cpu == NULL) 3116 if (ohci->selfid_buf_cpu == NULL) {
3111 FAIL(-ENOMEM, "Failed to allocate DMA buffer for self-id packets"); 3117 PRINT_G(KERN_ERR, "Failed to allocate self-ID buffer");
3118 goto err;
3119 }
3112 ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER; 3120 ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER;
3113 3121
3114 if ((unsigned long)ohci->selfid_buf_cpu & 0x1fff) 3122 if ((unsigned long)ohci->selfid_buf_cpu & 0x1fff)
@@ -3124,28 +3132,32 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3124 if (alloc_dma_rcv_ctx(ohci, &ohci->ar_req_context, 3132 if (alloc_dma_rcv_ctx(ohci, &ohci->ar_req_context,
3125 DMA_CTX_ASYNC_REQ, 0, AR_REQ_NUM_DESC, 3133 DMA_CTX_ASYNC_REQ, 0, AR_REQ_NUM_DESC,
3126 AR_REQ_BUF_SIZE, AR_REQ_SPLIT_BUF_SIZE, 3134 AR_REQ_BUF_SIZE, AR_REQ_SPLIT_BUF_SIZE,
3127 OHCI1394_AsReqRcvContextBase) < 0) 3135 OHCI1394_AsReqRcvContextBase) < 0) {
3128 FAIL(-ENOMEM, "Failed to allocate AR Req context"); 3136 PRINT_G(KERN_ERR, "Failed to allocate AR Req context");
3129 3137 goto err;
3138 }
3130 /* AR DMA response context allocation */ 3139 /* AR DMA response context allocation */
3131 if (alloc_dma_rcv_ctx(ohci, &ohci->ar_resp_context, 3140 if (alloc_dma_rcv_ctx(ohci, &ohci->ar_resp_context,
3132 DMA_CTX_ASYNC_RESP, 0, AR_RESP_NUM_DESC, 3141 DMA_CTX_ASYNC_RESP, 0, AR_RESP_NUM_DESC,
3133 AR_RESP_BUF_SIZE, AR_RESP_SPLIT_BUF_SIZE, 3142 AR_RESP_BUF_SIZE, AR_RESP_SPLIT_BUF_SIZE,
3134 OHCI1394_AsRspRcvContextBase) < 0) 3143 OHCI1394_AsRspRcvContextBase) < 0) {
3135 FAIL(-ENOMEM, "Failed to allocate AR Resp context"); 3144 PRINT_G(KERN_ERR, "Failed to allocate AR Resp context");
3136 3145 goto err;
3146 }
3137 /* AT DMA request context */ 3147 /* AT DMA request context */
3138 if (alloc_dma_trm_ctx(ohci, &ohci->at_req_context, 3148 if (alloc_dma_trm_ctx(ohci, &ohci->at_req_context,
3139 DMA_CTX_ASYNC_REQ, 0, AT_REQ_NUM_DESC, 3149 DMA_CTX_ASYNC_REQ, 0, AT_REQ_NUM_DESC,
3140 OHCI1394_AsReqTrContextBase) < 0) 3150 OHCI1394_AsReqTrContextBase) < 0) {
3141 FAIL(-ENOMEM, "Failed to allocate AT Req context"); 3151 PRINT_G(KERN_ERR, "Failed to allocate AT Req context");
3142 3152 goto err;
3153 }
3143 /* AT DMA response context */ 3154 /* AT DMA response context */
3144 if (alloc_dma_trm_ctx(ohci, &ohci->at_resp_context, 3155 if (alloc_dma_trm_ctx(ohci, &ohci->at_resp_context,
3145 DMA_CTX_ASYNC_RESP, 1, AT_RESP_NUM_DESC, 3156 DMA_CTX_ASYNC_RESP, 1, AT_RESP_NUM_DESC,
3146 OHCI1394_AsRspTrContextBase) < 0) 3157 OHCI1394_AsRspTrContextBase) < 0) {
3147 FAIL(-ENOMEM, "Failed to allocate AT Resp context"); 3158 PRINT_G(KERN_ERR, "Failed to allocate AT Resp context");
3148 3159 goto err;
3160 }
3149 /* Start off with a soft reset, to clear everything to a sane 3161 /* Start off with a soft reset, to clear everything to a sane
3150 * state. */ 3162 * state. */
3151 ohci_soft_reset(ohci); 3163 ohci_soft_reset(ohci);
@@ -3188,9 +3200,10 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3188 * by that point. 3200 * by that point.
3189 */ 3201 */
3190 if (request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED, 3202 if (request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED,
3191 OHCI1394_DRIVER_NAME, ohci)) 3203 OHCI1394_DRIVER_NAME, ohci)) {
3192 FAIL(-ENOMEM, "Failed to allocate shared interrupt %d", dev->irq); 3204 PRINT_G(KERN_ERR, "Failed to allocate interrupt %d", dev->irq);
3193 3205 goto err;
3206 }
3194 ohci->init_state = OHCI_INIT_HAVE_IRQ; 3207 ohci->init_state = OHCI_INIT_HAVE_IRQ;
3195 ohci_initialize(ohci); 3208 ohci_initialize(ohci);
3196 3209
@@ -3210,13 +3223,16 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3210 host->middle_addr_space = OHCI1394_MIDDLE_ADDRESS_SPACE; 3223 host->middle_addr_space = OHCI1394_MIDDLE_ADDRESS_SPACE;
3211 3224
3212 /* Tell the highlevel this host is ready */ 3225 /* Tell the highlevel this host is ready */
3213 if (hpsb_add_host(host)) 3226 if (hpsb_add_host(host)) {
3214 FAIL(-ENOMEM, "Failed to register host with highlevel"); 3227 PRINT_G(KERN_ERR, "Failed to register host with highlevel");
3215 3228 goto err;
3229 }
3216 ohci->init_state = OHCI_INIT_DONE; 3230 ohci->init_state = OHCI_INIT_DONE;
3217 3231
3218 return 0; 3232 return 0;
3219#undef FAIL 3233err:
3234 ohci1394_pci_remove(dev);
3235 return err;
3220} 3236}
3221 3237
3222static void ohci1394_pci_remove(struct pci_dev *dev) 3238static void ohci1394_pci_remove(struct pci_dev *dev)