forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/media/pci/cx25821/cx25821-alsa.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for the Conexant CX25821 PCIe bridge
34 *
45 * Copyright (C) 2009 Conexant Systems Inc.
56 * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
67 * Based on SAA713x ALSA driver and CX88 driver
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, version 2
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
178 */
189
1910 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -62,8 +53,8 @@
6253 struct cx25821_riscmem risc;
6354 void *vaddr;
6455 struct scatterlist *sglist;
65
- int sglen;
66
- int nr_pages;
56
+ int sglen;
57
+ unsigned long nr_pages;
6758 };
6859
6960 struct cx25821_audio_dev {
....@@ -120,7 +111,7 @@
120111 MODULE_PARM_DESC(debug, "enable debug messages");
121112
122113 /****************************************************************************
123
- Module specific funtions
114
+ Module specific functions
124115 ****************************************************************************/
125116 /* Constants taken from cx88-reg.h */
126117 #define AUD_INT_DN_RISCI1 (1 << 0)
....@@ -140,7 +131,8 @@
140131 #define PCI_MSK_AUD_EXT (1 << 4)
141132 #define PCI_MSK_AUD_INT (1 << 3)
142133
143
-static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages)
134
+static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip,
135
+ unsigned long nr_pages)
144136 {
145137 struct cx25821_audio_buffer *buf = chip->buf;
146138 struct page *pg;
....@@ -148,11 +140,11 @@
148140
149141 buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
150142 if (NULL == buf->vaddr) {
151
- dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages);
143
+ dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages);
152144 return -ENOMEM;
153145 }
154146
155
- dprintk(1, "vmalloc is at addr 0x%p, size=%d\n",
147
+ dprintk(1, "vmalloc is at addr 0x%p, size=%lu\n",
156148 buf->vaddr,
157149 nr_pages << PAGE_SHIFT);
158150
....@@ -186,7 +178,7 @@
186178 struct cx25821_audio_buffer *buf = dev->buf;
187179
188180 buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
189
- buf->nr_pages, PCI_DMA_FROMDEVICE);
181
+ buf->nr_pages, DMA_FROM_DEVICE);
190182
191183 if (0 == buf->sglen) {
192184 pr_warn("%s: cx25821_alsa_map_sg failed\n", __func__);
....@@ -202,7 +194,7 @@
202194 if (!buf->sglen)
203195 return 0;
204196
205
- dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE);
197
+ dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, DMA_FROM_DEVICE);
206198 buf->sglen = 0;
207199 return 0;
208200 }
....@@ -648,7 +640,6 @@
648640 static const struct snd_pcm_ops snd_cx25821_pcm_ops = {
649641 .open = snd_cx25821_pcm_open,
650642 .close = snd_cx25821_close,
651
- .ioctl = snd_pcm_lib_ioctl,
652643 .hw_params = snd_cx25821_hw_params,
653644 .hw_free = snd_cx25821_hw_free,
654645 .prepare = snd_cx25821_prepare,
....@@ -674,7 +665,7 @@
674665 }
675666 pcm->private_data = chip;
676667 pcm->info_flags = 0;
677
- strcpy(pcm->name, name);
668
+ strscpy(pcm->name, name, sizeof(pcm->name));
678669 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx25821_pcm_ops);
679670
680671 return 0;
....@@ -725,7 +716,7 @@
725716 return err;
726717 }
727718
728
- strcpy(card->driver, "cx25821");
719
+ strscpy(card->driver, "cx25821", sizeof(card->driver));
729720
730721 /* Card "creation" */
731722 chip = card->private_data;
....@@ -754,10 +745,10 @@
754745 goto error;
755746 }
756747
757
- strcpy(card->shortname, "cx25821");
748
+ strscpy(card->shortname, "cx25821", sizeof(card->shortname));
758749 sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name,
759750 chip->iobase, chip->irq);
760
- strcpy(card->mixername, "CX25821");
751
+ strscpy(card->mixername, "CX25821", sizeof(card->mixername));
761752
762753 pr_info("%s/%i: ALSA support for cx25821 boards\n", card->driver,
763754 devno);