| .. | .. |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | if (io_port == 1) { |
|---|
| 80 | 80 | /* auto-detect */ |
|---|
| 81 | | - if (!(io_port = pci_resource_start(chip->pci, 2))) |
|---|
| 81 | + io_port = pci_resource_start(chip->pci, 2); |
|---|
| 82 | + if (!io_port) |
|---|
| 82 | 83 | return -ENODEV; |
|---|
| 83 | 84 | } |
|---|
| 84 | 85 | } else { |
|---|
| .. | .. |
|---|
| 87 | 88 | for (io_port = 0x201; io_port <= 0x205; io_port++) { |
|---|
| 88 | 89 | if (io_port == 0x203) |
|---|
| 89 | 90 | continue; |
|---|
| 90 | | - if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL) |
|---|
| 91 | + r = request_region(io_port, 1, "YMFPCI gameport"); |
|---|
| 92 | + if (r) |
|---|
| 91 | 93 | break; |
|---|
| 92 | 94 | } |
|---|
| 93 | 95 | if (!r) { |
|---|
| .. | .. |
|---|
| 108 | 110 | } |
|---|
| 109 | 111 | } |
|---|
| 110 | 112 | |
|---|
| 111 | | - if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) { |
|---|
| 112 | | - dev_err(chip->card->dev, |
|---|
| 113 | | - "joystick port %#x is in use.\n", io_port); |
|---|
| 114 | | - return -EBUSY; |
|---|
| 113 | + if (!r) { |
|---|
| 114 | + r = request_region(io_port, 1, "YMFPCI gameport"); |
|---|
| 115 | + if (!r) { |
|---|
| 116 | + dev_err(chip->card->dev, |
|---|
| 117 | + "joystick port %#x is in use.\n", io_port); |
|---|
| 118 | + return -EBUSY; |
|---|
| 119 | + } |
|---|
| 115 | 120 | } |
|---|
| 116 | 121 | |
|---|
| 117 | 122 | chip->gameport = gp = gameport_allocate_port(); |
|---|
| .. | .. |
|---|
| 199 | 204 | /* auto-detect */ |
|---|
| 200 | 205 | fm_port[dev] = pci_resource_start(pci, 1); |
|---|
| 201 | 206 | } |
|---|
| 202 | | - if (fm_port[dev] > 0 && |
|---|
| 203 | | - (fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3")) != NULL) { |
|---|
| 207 | + if (fm_port[dev] > 0) |
|---|
| 208 | + fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3"); |
|---|
| 209 | + if (fm_res) { |
|---|
| 204 | 210 | legacy_ctrl |= YMFPCI_LEGACY_FMEN; |
|---|
| 205 | 211 | pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]); |
|---|
| 206 | 212 | } |
|---|
| .. | .. |
|---|
| 208 | 214 | /* auto-detect */ |
|---|
| 209 | 215 | mpu_port[dev] = pci_resource_start(pci, 1) + 0x20; |
|---|
| 210 | 216 | } |
|---|
| 211 | | - if (mpu_port[dev] > 0 && |
|---|
| 212 | | - (mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401")) != NULL) { |
|---|
| 217 | + if (mpu_port[dev] > 0) |
|---|
| 218 | + mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401"); |
|---|
| 219 | + if (mpu_res) { |
|---|
| 213 | 220 | legacy_ctrl |= YMFPCI_LEGACY_MEN; |
|---|
| 214 | 221 | pci_write_config_word(pci, PCIR_DSXG_MPU401BASE, mpu_port[dev]); |
|---|
| 215 | 222 | } |
|---|
| .. | .. |
|---|
| 221 | 228 | case 0x3a8: legacy_ctrl2 |= 3; break; |
|---|
| 222 | 229 | default: fm_port[dev] = 0; break; |
|---|
| 223 | 230 | } |
|---|
| 224 | | - if (fm_port[dev] > 0 && |
|---|
| 225 | | - (fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3")) != NULL) { |
|---|
| 231 | + if (fm_port[dev] > 0) |
|---|
| 232 | + fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3"); |
|---|
| 233 | + if (fm_res) { |
|---|
| 226 | 234 | legacy_ctrl |= YMFPCI_LEGACY_FMEN; |
|---|
| 227 | 235 | } else { |
|---|
| 228 | 236 | legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO; |
|---|
| .. | .. |
|---|
| 235 | 243 | case 0x334: legacy_ctrl2 |= 3 << 4; break; |
|---|
| 236 | 244 | default: mpu_port[dev] = 0; break; |
|---|
| 237 | 245 | } |
|---|
| 238 | | - if (mpu_port[dev] > 0 && |
|---|
| 239 | | - (mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401")) != NULL) { |
|---|
| 246 | + if (mpu_port[dev] > 0) |
|---|
| 247 | + mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401"); |
|---|
| 248 | + if (mpu_res) { |
|---|
| 240 | 249 | legacy_ctrl |= YMFPCI_LEGACY_MEN; |
|---|
| 241 | 250 | } else { |
|---|
| 242 | 251 | legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO; |
|---|
| .. | .. |
|---|
| 250 | 259 | pci_read_config_word(pci, PCIR_DSXG_LEGACY, &old_legacy_ctrl); |
|---|
| 251 | 260 | pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); |
|---|
| 252 | 261 | pci_write_config_word(pci, PCIR_DSXG_ELEGACY, legacy_ctrl2); |
|---|
| 253 | | - if ((err = snd_ymfpci_create(card, pci, |
|---|
| 254 | | - old_legacy_ctrl, |
|---|
| 255 | | - &chip)) < 0) { |
|---|
| 262 | + err = snd_ymfpci_create(card, pci, old_legacy_ctrl, &chip); |
|---|
| 263 | + if (err < 0) { |
|---|
| 256 | 264 | release_and_free_resource(mpu_res); |
|---|
| 257 | 265 | release_and_free_resource(fm_res); |
|---|
| 258 | 266 | goto free_card; |
|---|
| .. | .. |
|---|
| 293 | 301 | goto free_card; |
|---|
| 294 | 302 | |
|---|
| 295 | 303 | if (chip->mpu_res) { |
|---|
| 296 | | - if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, |
|---|
| 297 | | - mpu_port[dev], |
|---|
| 298 | | - MPU401_INFO_INTEGRATED | |
|---|
| 299 | | - MPU401_INFO_IRQ_HOOK, |
|---|
| 300 | | - -1, &chip->rawmidi)) < 0) { |
|---|
| 304 | + err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, |
|---|
| 305 | + mpu_port[dev], |
|---|
| 306 | + MPU401_INFO_INTEGRATED | |
|---|
| 307 | + MPU401_INFO_IRQ_HOOK, |
|---|
| 308 | + -1, &chip->rawmidi); |
|---|
| 309 | + if (err < 0) { |
|---|
| 301 | 310 | dev_warn(card->dev, |
|---|
| 302 | 311 | "cannot initialize MPU401 at 0x%lx, skipping...\n", |
|---|
| 303 | 312 | mpu_port[dev]); |
|---|
| .. | .. |
|---|
| 306 | 315 | } |
|---|
| 307 | 316 | } |
|---|
| 308 | 317 | if (chip->fm_res) { |
|---|
| 309 | | - if ((err = snd_opl3_create(card, |
|---|
| 310 | | - fm_port[dev], |
|---|
| 311 | | - fm_port[dev] + 2, |
|---|
| 312 | | - OPL3_HW_OPL3, 1, &opl3)) < 0) { |
|---|
| 318 | + err = snd_opl3_create(card, |
|---|
| 319 | + fm_port[dev], |
|---|
| 320 | + fm_port[dev] + 2, |
|---|
| 321 | + OPL3_HW_OPL3, 1, &opl3); |
|---|
| 322 | + if (err < 0) { |
|---|
| 313 | 323 | dev_warn(card->dev, |
|---|
| 314 | 324 | "cannot initialize FM OPL3 at 0x%lx, skipping...\n", |
|---|
| 315 | 325 | fm_port[dev]); |
|---|
| 316 | 326 | legacy_ctrl &= ~YMFPCI_LEGACY_FMEN; |
|---|
| 317 | 327 | pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); |
|---|
| 318 | | - } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { |
|---|
| 319 | | - dev_err(card->dev, "cannot create opl3 hwdep\n"); |
|---|
| 320 | | - goto free_card; |
|---|
| 328 | + } else { |
|---|
| 329 | + err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); |
|---|
| 330 | + if (err < 0) { |
|---|
| 331 | + dev_err(card->dev, "cannot create opl3 hwdep\n"); |
|---|
| 332 | + goto free_card; |
|---|
| 333 | + } |
|---|
| 321 | 334 | } |
|---|
| 322 | 335 | } |
|---|
| 323 | 336 | |
|---|