| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for the Conexant CX25821 PCIe bridge |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2009 Conexant Systems Inc. |
|---|
| 5 | 6 | * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com> |
|---|
| 6 | 7 | * 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 | | - * |
|---|
| 17 | 8 | */ |
|---|
| 18 | 9 | |
|---|
| 19 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 62 | 53 | struct cx25821_riscmem risc; |
|---|
| 63 | 54 | void *vaddr; |
|---|
| 64 | 55 | struct scatterlist *sglist; |
|---|
| 65 | | - int sglen; |
|---|
| 66 | | - int nr_pages; |
|---|
| 56 | + int sglen; |
|---|
| 57 | + unsigned long nr_pages; |
|---|
| 67 | 58 | }; |
|---|
| 68 | 59 | |
|---|
| 69 | 60 | struct cx25821_audio_dev { |
|---|
| .. | .. |
|---|
| 120 | 111 | MODULE_PARM_DESC(debug, "enable debug messages"); |
|---|
| 121 | 112 | |
|---|
| 122 | 113 | /**************************************************************************** |
|---|
| 123 | | - Module specific funtions |
|---|
| 114 | + Module specific functions |
|---|
| 124 | 115 | ****************************************************************************/ |
|---|
| 125 | 116 | /* Constants taken from cx88-reg.h */ |
|---|
| 126 | 117 | #define AUD_INT_DN_RISCI1 (1 << 0) |
|---|
| .. | .. |
|---|
| 140 | 131 | #define PCI_MSK_AUD_EXT (1 << 4) |
|---|
| 141 | 132 | #define PCI_MSK_AUD_INT (1 << 3) |
|---|
| 142 | 133 | |
|---|
| 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) |
|---|
| 144 | 136 | { |
|---|
| 145 | 137 | struct cx25821_audio_buffer *buf = chip->buf; |
|---|
| 146 | 138 | struct page *pg; |
|---|
| .. | .. |
|---|
| 148 | 140 | |
|---|
| 149 | 141 | buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); |
|---|
| 150 | 142 | 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); |
|---|
| 152 | 144 | return -ENOMEM; |
|---|
| 153 | 145 | } |
|---|
| 154 | 146 | |
|---|
| 155 | | - dprintk(1, "vmalloc is at addr 0x%p, size=%d\n", |
|---|
| 147 | + dprintk(1, "vmalloc is at addr 0x%p, size=%lu\n", |
|---|
| 156 | 148 | buf->vaddr, |
|---|
| 157 | 149 | nr_pages << PAGE_SHIFT); |
|---|
| 158 | 150 | |
|---|
| .. | .. |
|---|
| 186 | 178 | struct cx25821_audio_buffer *buf = dev->buf; |
|---|
| 187 | 179 | |
|---|
| 188 | 180 | buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, |
|---|
| 189 | | - buf->nr_pages, PCI_DMA_FROMDEVICE); |
|---|
| 181 | + buf->nr_pages, DMA_FROM_DEVICE); |
|---|
| 190 | 182 | |
|---|
| 191 | 183 | if (0 == buf->sglen) { |
|---|
| 192 | 184 | pr_warn("%s: cx25821_alsa_map_sg failed\n", __func__); |
|---|
| .. | .. |
|---|
| 202 | 194 | if (!buf->sglen) |
|---|
| 203 | 195 | return 0; |
|---|
| 204 | 196 | |
|---|
| 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); |
|---|
| 206 | 198 | buf->sglen = 0; |
|---|
| 207 | 199 | return 0; |
|---|
| 208 | 200 | } |
|---|
| .. | .. |
|---|
| 648 | 640 | static const struct snd_pcm_ops snd_cx25821_pcm_ops = { |
|---|
| 649 | 641 | .open = snd_cx25821_pcm_open, |
|---|
| 650 | 642 | .close = snd_cx25821_close, |
|---|
| 651 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 652 | 643 | .hw_params = snd_cx25821_hw_params, |
|---|
| 653 | 644 | .hw_free = snd_cx25821_hw_free, |
|---|
| 654 | 645 | .prepare = snd_cx25821_prepare, |
|---|
| .. | .. |
|---|
| 674 | 665 | } |
|---|
| 675 | 666 | pcm->private_data = chip; |
|---|
| 676 | 667 | pcm->info_flags = 0; |
|---|
| 677 | | - strcpy(pcm->name, name); |
|---|
| 668 | + strscpy(pcm->name, name, sizeof(pcm->name)); |
|---|
| 678 | 669 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx25821_pcm_ops); |
|---|
| 679 | 670 | |
|---|
| 680 | 671 | return 0; |
|---|
| .. | .. |
|---|
| 725 | 716 | return err; |
|---|
| 726 | 717 | } |
|---|
| 727 | 718 | |
|---|
| 728 | | - strcpy(card->driver, "cx25821"); |
|---|
| 719 | + strscpy(card->driver, "cx25821", sizeof(card->driver)); |
|---|
| 729 | 720 | |
|---|
| 730 | 721 | /* Card "creation" */ |
|---|
| 731 | 722 | chip = card->private_data; |
|---|
| .. | .. |
|---|
| 754 | 745 | goto error; |
|---|
| 755 | 746 | } |
|---|
| 756 | 747 | |
|---|
| 757 | | - strcpy(card->shortname, "cx25821"); |
|---|
| 748 | + strscpy(card->shortname, "cx25821", sizeof(card->shortname)); |
|---|
| 758 | 749 | sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name, |
|---|
| 759 | 750 | chip->iobase, chip->irq); |
|---|
| 760 | | - strcpy(card->mixername, "CX25821"); |
|---|
| 751 | + strscpy(card->mixername, "CX25821", sizeof(card->mixername)); |
|---|
| 761 | 752 | |
|---|
| 762 | 753 | pr_info("%s/%i: ALSA support for cx25821 boards\n", card->driver, |
|---|
| 763 | 754 | devno); |
|---|