forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/saa7134/saa7134-alsa.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * SAA713x ALSA support for V4L
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation, version 2
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
134 */
145
156 #include "saa7134.h"
....@@ -261,7 +252,8 @@
261252 return err;
262253 }
263254
264
-static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages)
255
+static int saa7134_alsa_dma_init(struct saa7134_dev *dev,
256
+ unsigned long nr_pages)
265257 {
266258 struct saa7134_dmasound *dma = &dev->dmasound;
267259 struct page *pg;
....@@ -269,11 +261,11 @@
269261
270262 dma->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
271263 if (NULL == dma->vaddr) {
272
- pr_debug("vmalloc_32(%d pages) failed\n", nr_pages);
264
+ pr_debug("vmalloc_32(%lu pages) failed\n", nr_pages);
273265 return -ENOMEM;
274266 }
275267
276
- pr_debug("vmalloc is at addr %p, size=%d\n",
268
+ pr_debug("vmalloc is at addr %p, size=%lu\n",
277269 dma->vaddr, nr_pages << PAGE_SHIFT);
278270
279271 memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
....@@ -306,7 +298,7 @@
306298 struct saa7134_dmasound *dma = &dev->dmasound;
307299
308300 dma->sglen = dma_map_sg(&dev->pci->dev, dma->sglist,
309
- dma->nr_pages, PCI_DMA_FROMDEVICE);
301
+ dma->nr_pages, DMA_FROM_DEVICE);
310302
311303 if (0 == dma->sglen) {
312304 pr_warn("%s: saa7134_alsa_map_sg failed\n", __func__);
....@@ -322,7 +314,7 @@
322314 if (!dma->sglen)
323315 return 0;
324316
325
- dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->sglen, PCI_DMA_FROMDEVICE);
317
+ dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->nr_pages, DMA_FROM_DEVICE);
326318 dma->sglen = 0;
327319 return 0;
328320 }
....@@ -874,7 +866,6 @@
874866 static const struct snd_pcm_ops snd_card_saa7134_capture_ops = {
875867 .open = snd_card_saa7134_capture_open,
876868 .close = snd_card_saa7134_capture_close,
877
- .ioctl = snd_pcm_lib_ioctl,
878869 .hw_params = snd_card_saa7134_hw_params,
879870 .hw_free = snd_card_saa7134_hw_free,
880871 .prepare = snd_card_saa7134_capture_prepare,
....@@ -901,7 +892,7 @@
901892 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_saa7134_capture_ops);
902893 pcm->private_data = saa7134;
903894 pcm->info_flags = 0;
904
- strcpy(pcm->name, "SAA7134 PCM");
895
+ strscpy(pcm->name, "SAA7134 PCM", sizeof(pcm->name));
905896 return 0;
906897 }
907898
....@@ -1074,7 +1065,7 @@
10741065 unsigned int idx;
10751066 int err, addr;
10761067
1077
- strcpy(card->mixername, "SAA7134 Mixer");
1068
+ strscpy(card->mixername, "SAA7134 Mixer", sizeof(card->mixername));
10781069
10791070 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) {
10801071 kcontrol = snd_ctl_new1(&snd_saa7134_volume_controls[idx],
....@@ -1138,7 +1129,7 @@
11381129 if (err < 0)
11391130 return err;
11401131
1141
- strcpy(card->driver, "SAA7134");
1132
+ strscpy(card->driver, "SAA7134", sizeof(card->driver));
11421133
11431134 /* Card "creation" */
11441135
....@@ -1178,7 +1169,7 @@
11781169
11791170 /* End of "creation" */
11801171
1181
- strcpy(card->shortname, "SAA7134");
1172
+ strscpy(card->shortname, "SAA7134", sizeof(card->shortname));
11821173 sprintf(card->longname, "%s at 0x%lx irq %d",
11831174 chip->dev->name, chip->iobase, chip->irq);
11841175
....@@ -1223,16 +1214,14 @@
12231214
12241215 static int saa7134_alsa_init(void)
12251216 {
1226
- struct saa7134_dev *dev = NULL;
1227
- struct list_head *list;
1217
+ struct saa7134_dev *dev;
12281218
12291219 saa7134_dmasound_init = alsa_device_init;
12301220 saa7134_dmasound_exit = alsa_device_exit;
12311221
12321222 pr_info("saa7134 ALSA driver for DMA sound loaded\n");
12331223
1234
- list_for_each(list,&saa7134_devlist) {
1235
- dev = list_entry(list, struct saa7134_dev, devlist);
1224
+ list_for_each_entry(dev, &saa7134_devlist, devlist) {
12361225 if (dev->pci->device == PCI_DEVICE_ID_PHILIPS_SAA7130)
12371226 pr_info("%s/alsa: %s doesn't support digital audio\n",
12381227 dev->name, saa7134_boards[dev->board].name);
....@@ -1240,7 +1229,7 @@
12401229 alsa_device_init(dev);
12411230 }
12421231
1243
- if (dev == NULL)
1232
+ if (list_empty(&saa7134_devlist))
12441233 pr_info("saa7134 ALSA: no saa7134 cards found\n");
12451234
12461235 return 0;