hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/sound/pci/ymfpci/ymfpci.c
....@@ -78,7 +78,8 @@
7878
7979 if (io_port == 1) {
8080 /* 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)
8283 return -ENODEV;
8384 }
8485 } else {
....@@ -87,7 +88,8 @@
8788 for (io_port = 0x201; io_port <= 0x205; io_port++) {
8889 if (io_port == 0x203)
8990 continue;
90
- if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL)
91
+ r = request_region(io_port, 1, "YMFPCI gameport");
92
+ if (r)
9193 break;
9294 }
9395 if (!r) {
....@@ -108,10 +110,13 @@
108110 }
109111 }
110112
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
+ }
115120 }
116121
117122 chip->gameport = gp = gameport_allocate_port();
....@@ -199,8 +204,9 @@
199204 /* auto-detect */
200205 fm_port[dev] = pci_resource_start(pci, 1);
201206 }
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) {
204210 legacy_ctrl |= YMFPCI_LEGACY_FMEN;
205211 pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]);
206212 }
....@@ -208,8 +214,9 @@
208214 /* auto-detect */
209215 mpu_port[dev] = pci_resource_start(pci, 1) + 0x20;
210216 }
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) {
213220 legacy_ctrl |= YMFPCI_LEGACY_MEN;
214221 pci_write_config_word(pci, PCIR_DSXG_MPU401BASE, mpu_port[dev]);
215222 }
....@@ -221,8 +228,9 @@
221228 case 0x3a8: legacy_ctrl2 |= 3; break;
222229 default: fm_port[dev] = 0; break;
223230 }
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) {
226234 legacy_ctrl |= YMFPCI_LEGACY_FMEN;
227235 } else {
228236 legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO;
....@@ -235,8 +243,9 @@
235243 case 0x334: legacy_ctrl2 |= 3 << 4; break;
236244 default: mpu_port[dev] = 0; break;
237245 }
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) {
240249 legacy_ctrl |= YMFPCI_LEGACY_MEN;
241250 } else {
242251 legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO;
....@@ -250,9 +259,8 @@
250259 pci_read_config_word(pci, PCIR_DSXG_LEGACY, &old_legacy_ctrl);
251260 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
252261 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) {
256264 release_and_free_resource(mpu_res);
257265 release_and_free_resource(fm_res);
258266 goto free_card;
....@@ -293,11 +301,12 @@
293301 goto free_card;
294302
295303 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) {
301310 dev_warn(card->dev,
302311 "cannot initialize MPU401 at 0x%lx, skipping...\n",
303312 mpu_port[dev]);
....@@ -306,18 +315,22 @@
306315 }
307316 }
308317 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) {
313323 dev_warn(card->dev,
314324 "cannot initialize FM OPL3 at 0x%lx, skipping...\n",
315325 fm_port[dev]);
316326 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
317327 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
+ }
321334 }
322335 }
323336