forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/sound/pci/ymfpci/ymfpci.c
....@@ -1,22 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * The driver for the Yamaha's DS1/DS1E cards
34 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4
- *
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
205 */
216
227 #include <linux/init.h>
....@@ -93,7 +78,8 @@
9378
9479 if (io_port == 1) {
9580 /* auto-detect */
96
- if (!(io_port = pci_resource_start(chip->pci, 2)))
81
+ io_port = pci_resource_start(chip->pci, 2);
82
+ if (!io_port)
9783 return -ENODEV;
9884 }
9985 } else {
....@@ -102,7 +88,8 @@
10288 for (io_port = 0x201; io_port <= 0x205; io_port++) {
10389 if (io_port == 0x203)
10490 continue;
105
- if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL)
91
+ r = request_region(io_port, 1, "YMFPCI gameport");
92
+ if (r)
10693 break;
10794 }
10895 if (!r) {
....@@ -123,10 +110,13 @@
123110 }
124111 }
125112
126
- if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) {
127
- dev_err(chip->card->dev,
128
- "joystick port %#x is in use.\n", io_port);
129
- 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
+ }
130120 }
131121
132122 chip->gameport = gp = gameport_allocate_port();
....@@ -214,8 +204,9 @@
214204 /* auto-detect */
215205 fm_port[dev] = pci_resource_start(pci, 1);
216206 }
217
- if (fm_port[dev] > 0 &&
218
- (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) {
219210 legacy_ctrl |= YMFPCI_LEGACY_FMEN;
220211 pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]);
221212 }
....@@ -223,8 +214,9 @@
223214 /* auto-detect */
224215 mpu_port[dev] = pci_resource_start(pci, 1) + 0x20;
225216 }
226
- if (mpu_port[dev] > 0 &&
227
- (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) {
228220 legacy_ctrl |= YMFPCI_LEGACY_MEN;
229221 pci_write_config_word(pci, PCIR_DSXG_MPU401BASE, mpu_port[dev]);
230222 }
....@@ -236,8 +228,9 @@
236228 case 0x3a8: legacy_ctrl2 |= 3; break;
237229 default: fm_port[dev] = 0; break;
238230 }
239
- if (fm_port[dev] > 0 &&
240
- (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) {
241234 legacy_ctrl |= YMFPCI_LEGACY_FMEN;
242235 } else {
243236 legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO;
....@@ -250,8 +243,9 @@
250243 case 0x334: legacy_ctrl2 |= 3 << 4; break;
251244 default: mpu_port[dev] = 0; break;
252245 }
253
- if (mpu_port[dev] > 0 &&
254
- (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) {
255249 legacy_ctrl |= YMFPCI_LEGACY_MEN;
256250 } else {
257251 legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO;
....@@ -265,9 +259,8 @@
265259 pci_read_config_word(pci, PCIR_DSXG_LEGACY, &old_legacy_ctrl);
266260 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
267261 pci_write_config_word(pci, PCIR_DSXG_ELEGACY, legacy_ctrl2);
268
- if ((err = snd_ymfpci_create(card, pci,
269
- old_legacy_ctrl,
270
- &chip)) < 0) {
262
+ err = snd_ymfpci_create(card, pci, old_legacy_ctrl, &chip);
263
+ if (err < 0) {
271264 release_and_free_resource(mpu_res);
272265 release_and_free_resource(fm_res);
273266 goto free_card;
....@@ -308,11 +301,12 @@
308301 goto free_card;
309302
310303 if (chip->mpu_res) {
311
- if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
312
- mpu_port[dev],
313
- MPU401_INFO_INTEGRATED |
314
- MPU401_INFO_IRQ_HOOK,
315
- -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) {
316310 dev_warn(card->dev,
317311 "cannot initialize MPU401 at 0x%lx, skipping...\n",
318312 mpu_port[dev]);
....@@ -321,18 +315,22 @@
321315 }
322316 }
323317 if (chip->fm_res) {
324
- if ((err = snd_opl3_create(card,
325
- fm_port[dev],
326
- fm_port[dev] + 2,
327
- 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) {
328323 dev_warn(card->dev,
329324 "cannot initialize FM OPL3 at 0x%lx, skipping...\n",
330325 fm_port[dev]);
331326 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
332327 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
333
- } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
334
- dev_err(card->dev, "cannot create opl3 hwdep\n");
335
- 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
+ }
336334 }
337335 }
338336