.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
---|
3 | 4 | * Creative Labs, Inc. |
---|
.. | .. |
---|
11 | 12 | * |
---|
12 | 13 | * TODO: |
---|
13 | 14 | * -- |
---|
14 | | - * |
---|
15 | | - * This program is free software; you can redistribute it and/or modify |
---|
16 | | - * it under the terms of the GNU General Public License as published by |
---|
17 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
18 | | - * (at your option) any later version. |
---|
19 | | - * |
---|
20 | | - * This program is distributed in the hope that it will be useful, |
---|
21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | | - * GNU General Public License for more details. |
---|
24 | | - * |
---|
25 | | - * You should have received a copy of the GNU General Public License |
---|
26 | | - * along with this program; if not, write to the Free Software |
---|
27 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
28 | | - * |
---|
29 | 15 | */ |
---|
30 | 16 | |
---|
31 | 17 | #include <linux/pci.h> |
---|
.. | .. |
---|
60 | 46 | * Tables |
---|
61 | 47 | */ |
---|
62 | 48 | |
---|
63 | | -static char *fxbuses[16] = { |
---|
| 49 | +static const char * const fxbuses[16] = { |
---|
64 | 50 | /* 0x00 */ "PCM Left", |
---|
65 | 51 | /* 0x01 */ "PCM Right", |
---|
66 | 52 | /* 0x02 */ "PCM Surround Left", |
---|
.. | .. |
---|
79 | 65 | /* 0x0f */ NULL |
---|
80 | 66 | }; |
---|
81 | 67 | |
---|
82 | | -static char *creative_ins[16] = { |
---|
| 68 | +static const char * const creative_ins[16] = { |
---|
83 | 69 | /* 0x00 */ "AC97 Left", |
---|
84 | 70 | /* 0x01 */ "AC97 Right", |
---|
85 | 71 | /* 0x02 */ "TTL IEC958 Left", |
---|
.. | .. |
---|
98 | 84 | /* 0x0f */ NULL |
---|
99 | 85 | }; |
---|
100 | 86 | |
---|
101 | | -static char *audigy_ins[16] = { |
---|
| 87 | +static const char * const audigy_ins[16] = { |
---|
102 | 88 | /* 0x00 */ "AC97 Left", |
---|
103 | 89 | /* 0x01 */ "AC97 Right", |
---|
104 | 90 | /* 0x02 */ "Audigy CD Left", |
---|
.. | .. |
---|
117 | 103 | /* 0x0f */ NULL |
---|
118 | 104 | }; |
---|
119 | 105 | |
---|
120 | | -static char *creative_outs[32] = { |
---|
| 106 | +static const char * const creative_outs[32] = { |
---|
121 | 107 | /* 0x00 */ "AC97 Left", |
---|
122 | 108 | /* 0x01 */ "AC97 Right", |
---|
123 | 109 | /* 0x02 */ "Optical IEC958 Left", |
---|
.. | .. |
---|
152 | 138 | /* 0x1f */ NULL, |
---|
153 | 139 | }; |
---|
154 | 140 | |
---|
155 | | -static char *audigy_outs[32] = { |
---|
| 141 | +static const char * const audigy_outs[32] = { |
---|
156 | 142 | /* 0x00 */ "Digital Front Left", |
---|
157 | 143 | /* 0x01 */ "Digital Front Right", |
---|
158 | 144 | /* 0x02 */ "Digital Center", |
---|
.. | .. |
---|
477 | 463 | u_int32_t *code; |
---|
478 | 464 | if (snd_BUG_ON(*ptr >= 512)) |
---|
479 | 465 | return; |
---|
480 | | - code = (u_int32_t __force *)icode->code + (*ptr) * 2; |
---|
| 466 | + code = icode->code + (*ptr) * 2; |
---|
481 | 467 | set_bit(*ptr, icode->code_valid); |
---|
482 | 468 | code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); |
---|
483 | 469 | code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff); |
---|
.. | .. |
---|
494 | 480 | u_int32_t *code; |
---|
495 | 481 | if (snd_BUG_ON(*ptr >= 1024)) |
---|
496 | 482 | return; |
---|
497 | | - code = (u_int32_t __force *)icode->code + (*ptr) * 2; |
---|
| 483 | + code = icode->code + (*ptr) * 2; |
---|
498 | 484 | set_bit(*ptr, icode->code_valid); |
---|
499 | 485 | code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); |
---|
500 | 486 | code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff); |
---|
.. | .. |
---|
527 | 513 | if (!test_bit(gpr, icode->gpr_valid)) |
---|
528 | 514 | continue; |
---|
529 | 515 | if (in_kernel) |
---|
530 | | - val = *(__force u32 *)&icode->gpr_map[gpr]; |
---|
531 | | - else if (get_user(val, &icode->gpr_map[gpr])) |
---|
| 516 | + val = icode->gpr_map[gpr]; |
---|
| 517 | + else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr])) |
---|
532 | 518 | return -EFAULT; |
---|
533 | 519 | snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val); |
---|
534 | 520 | } |
---|
.. | .. |
---|
544 | 530 | for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { |
---|
545 | 531 | set_bit(gpr, icode->gpr_valid); |
---|
546 | 532 | val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0); |
---|
547 | | - if (put_user(val, &icode->gpr_map[gpr])) |
---|
| 533 | + if (put_user(val, (__user u32 *)&icode->gpr_map[gpr])) |
---|
548 | 534 | return -EFAULT; |
---|
549 | 535 | } |
---|
550 | 536 | return 0; |
---|
.. | .. |
---|
561 | 547 | if (!test_bit(tram, icode->tram_valid)) |
---|
562 | 548 | continue; |
---|
563 | 549 | if (in_kernel) { |
---|
564 | | - val = *(__force u32 *)&icode->tram_data_map[tram]; |
---|
565 | | - addr = *(__force u32 *)&icode->tram_addr_map[tram]; |
---|
| 550 | + val = icode->tram_data_map[tram]; |
---|
| 551 | + addr = icode->tram_addr_map[tram]; |
---|
566 | 552 | } else { |
---|
567 | | - if (get_user(val, &icode->tram_data_map[tram]) || |
---|
568 | | - get_user(addr, &icode->tram_addr_map[tram])) |
---|
| 553 | + if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) || |
---|
| 554 | + get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram])) |
---|
569 | 555 | return -EFAULT; |
---|
570 | 556 | } |
---|
571 | 557 | snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, val); |
---|
.. | .. |
---|
595 | 581 | addr = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0) >> 12; |
---|
596 | 582 | addr |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20; |
---|
597 | 583 | } |
---|
598 | | - if (put_user(val, &icode->tram_data_map[tram]) || |
---|
599 | | - put_user(addr, &icode->tram_addr_map[tram])) |
---|
| 584 | + if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) || |
---|
| 585 | + put_user(addr, (__user u32 *)&icode->tram_addr_map[tram])) |
---|
600 | 586 | return -EFAULT; |
---|
601 | 587 | } |
---|
602 | 588 | return 0; |
---|
.. | .. |
---|
612 | 598 | if (!test_bit(pc / 2, icode->code_valid)) |
---|
613 | 599 | continue; |
---|
614 | 600 | if (in_kernel) { |
---|
615 | | - lo = *(__force u32 *)&icode->code[pc + 0]; |
---|
616 | | - hi = *(__force u32 *)&icode->code[pc + 1]; |
---|
| 601 | + lo = icode->code[pc + 0]; |
---|
| 602 | + hi = icode->code[pc + 1]; |
---|
617 | 603 | } else { |
---|
618 | | - if (get_user(lo, &icode->code[pc + 0]) || |
---|
619 | | - get_user(hi, &icode->code[pc + 1])) |
---|
| 604 | + if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) || |
---|
| 605 | + get_user(hi, (__user u32 *)&icode->code[pc + 1])) |
---|
620 | 606 | return -EFAULT; |
---|
621 | 607 | } |
---|
622 | 608 | snd_emu10k1_efx_write(emu, pc + 0, lo); |
---|
.. | .. |
---|
633 | 619 | memset(icode->code_valid, 0, sizeof(icode->code_valid)); |
---|
634 | 620 | for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { |
---|
635 | 621 | set_bit(pc / 2, icode->code_valid); |
---|
636 | | - if (put_user(snd_emu10k1_efx_read(emu, pc + 0), &icode->code[pc + 0])) |
---|
| 622 | + if (put_user(snd_emu10k1_efx_read(emu, pc + 0), |
---|
| 623 | + (__user u32 *)&icode->code[pc + 0])) |
---|
637 | 624 | return -EFAULT; |
---|
638 | | - if (put_user(snd_emu10k1_efx_read(emu, pc + 1), &icode->code[pc + 1])) |
---|
| 625 | + if (put_user(snd_emu10k1_efx_read(emu, pc + 1), |
---|
| 626 | + (__user u32 *)&icode->code[pc + 1])) |
---|
639 | 627 | return -EFAULT; |
---|
640 | 628 | } |
---|
641 | 629 | return 0; |
---|
642 | 630 | } |
---|
643 | 631 | |
---|
644 | 632 | static struct snd_emu10k1_fx8010_ctl * |
---|
645 | | -snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) |
---|
| 633 | +snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, |
---|
| 634 | + struct emu10k1_ctl_elem_id *_id) |
---|
646 | 635 | { |
---|
| 636 | + struct snd_ctl_elem_id *id = (struct snd_ctl_elem_id *)_id; |
---|
647 | 637 | struct snd_emu10k1_fx8010_ctl *ctl; |
---|
648 | 638 | struct snd_kcontrol *kcontrol; |
---|
649 | 639 | |
---|
.. | .. |
---|
686 | 676 | } |
---|
687 | 677 | |
---|
688 | 678 | static int copy_gctl(struct snd_emu10k1 *emu, |
---|
689 | | - struct snd_emu10k1_fx8010_control_gpr *gctl, |
---|
690 | | - struct snd_emu10k1_fx8010_control_gpr __user *_gctl, |
---|
| 679 | + struct snd_emu10k1_fx8010_control_gpr *dst, |
---|
| 680 | + struct snd_emu10k1_fx8010_control_gpr *src, |
---|
691 | 681 | int idx, bool in_kernel) |
---|
692 | 682 | { |
---|
693 | | - struct snd_emu10k1_fx8010_control_old_gpr __user *octl; |
---|
| 683 | + struct snd_emu10k1_fx8010_control_gpr __user *_src; |
---|
| 684 | + struct snd_emu10k1_fx8010_control_old_gpr *octl; |
---|
| 685 | + struct snd_emu10k1_fx8010_control_old_gpr __user *_octl; |
---|
694 | 686 | |
---|
| 687 | + _src = (struct snd_emu10k1_fx8010_control_gpr __user *)src; |
---|
695 | 688 | if (emu->support_tlv) { |
---|
696 | 689 | if (in_kernel) |
---|
697 | | - memcpy(gctl, (__force void *)&_gctl[idx], sizeof(*gctl)); |
---|
698 | | - else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl))) |
---|
| 690 | + *dst = src[idx]; |
---|
| 691 | + else if (copy_from_user(dst, &_src[idx], sizeof(*src))) |
---|
699 | 692 | return -EFAULT; |
---|
700 | 693 | return 0; |
---|
701 | 694 | } |
---|
702 | 695 | |
---|
703 | | - octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; |
---|
| 696 | + octl = (struct snd_emu10k1_fx8010_control_old_gpr *)src; |
---|
| 697 | + _octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)octl; |
---|
704 | 698 | if (in_kernel) |
---|
705 | | - memcpy(gctl, (__force void *)&octl[idx], sizeof(*octl)); |
---|
706 | | - else if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) |
---|
| 699 | + memcpy(dst, &octl[idx], sizeof(*octl)); |
---|
| 700 | + else if (copy_from_user(dst, &_octl[idx], sizeof(*octl))) |
---|
707 | 701 | return -EFAULT; |
---|
708 | | - gctl->tlv = NULL; |
---|
| 702 | + dst->tlv = NULL; |
---|
709 | 703 | return 0; |
---|
710 | 704 | } |
---|
711 | 705 | |
---|
712 | 706 | static int copy_gctl_to_user(struct snd_emu10k1 *emu, |
---|
713 | | - struct snd_emu10k1_fx8010_control_gpr __user *_gctl, |
---|
714 | | - struct snd_emu10k1_fx8010_control_gpr *gctl, |
---|
| 707 | + struct snd_emu10k1_fx8010_control_gpr *dst, |
---|
| 708 | + struct snd_emu10k1_fx8010_control_gpr *src, |
---|
715 | 709 | int idx) |
---|
716 | 710 | { |
---|
| 711 | + struct snd_emu10k1_fx8010_control_gpr __user *_dst; |
---|
717 | 712 | struct snd_emu10k1_fx8010_control_old_gpr __user *octl; |
---|
718 | 713 | |
---|
| 714 | + _dst = (struct snd_emu10k1_fx8010_control_gpr __user *)dst; |
---|
719 | 715 | if (emu->support_tlv) |
---|
720 | | - return copy_to_user(&_gctl[idx], gctl, sizeof(*gctl)); |
---|
| 716 | + return copy_to_user(&_dst[idx], src, sizeof(*src)); |
---|
721 | 717 | |
---|
722 | | - octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; |
---|
723 | | - return copy_to_user(&octl[idx], gctl, sizeof(*octl)); |
---|
| 718 | + octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)dst; |
---|
| 719 | + return copy_to_user(&octl[idx], src, sizeof(*octl)); |
---|
| 720 | +} |
---|
| 721 | + |
---|
| 722 | +static int copy_ctl_elem_id(const struct emu10k1_ctl_elem_id *list, int i, |
---|
| 723 | + struct emu10k1_ctl_elem_id *ret, bool in_kernel) |
---|
| 724 | +{ |
---|
| 725 | + struct emu10k1_ctl_elem_id __user *_id = |
---|
| 726 | + (struct emu10k1_ctl_elem_id __user *)&list[i]; |
---|
| 727 | + |
---|
| 728 | + if (in_kernel) |
---|
| 729 | + *ret = list[i]; |
---|
| 730 | + else if (copy_from_user(ret, _id, sizeof(*ret))) |
---|
| 731 | + return -EFAULT; |
---|
| 732 | + return 0; |
---|
724 | 733 | } |
---|
725 | 734 | |
---|
726 | 735 | static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, |
---|
.. | .. |
---|
728 | 737 | bool in_kernel) |
---|
729 | 738 | { |
---|
730 | 739 | unsigned int i; |
---|
731 | | - struct snd_ctl_elem_id __user *_id; |
---|
732 | | - struct snd_ctl_elem_id id; |
---|
| 740 | + struct emu10k1_ctl_elem_id id; |
---|
733 | 741 | struct snd_emu10k1_fx8010_control_gpr *gctl; |
---|
| 742 | + struct snd_ctl_elem_id *gctl_id; |
---|
734 | 743 | int err; |
---|
735 | 744 | |
---|
736 | | - for (i = 0, _id = icode->gpr_del_controls; |
---|
737 | | - i < icode->gpr_del_control_count; i++, _id++) { |
---|
738 | | - if (in_kernel) |
---|
739 | | - id = *(__force struct snd_ctl_elem_id *)_id; |
---|
740 | | - else if (copy_from_user(&id, _id, sizeof(id))) |
---|
741 | | - return -EFAULT; |
---|
| 745 | + for (i = 0; i < icode->gpr_del_control_count; i++) { |
---|
| 746 | + err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, |
---|
| 747 | + in_kernel); |
---|
| 748 | + if (err < 0) |
---|
| 749 | + return err; |
---|
742 | 750 | if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) |
---|
743 | 751 | return -ENOENT; |
---|
744 | 752 | } |
---|
.. | .. |
---|
754 | 762 | } |
---|
755 | 763 | if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) |
---|
756 | 764 | continue; |
---|
| 765 | + gctl_id = (struct snd_ctl_elem_id *)&gctl->id; |
---|
757 | 766 | down_read(&emu->card->controls_rwsem); |
---|
758 | | - if (snd_ctl_find_id(emu->card, &gctl->id) != NULL) { |
---|
| 767 | + if (snd_ctl_find_id(emu->card, gctl_id)) { |
---|
759 | 768 | up_read(&emu->card->controls_rwsem); |
---|
760 | 769 | err = -EEXIST; |
---|
761 | 770 | goto __error; |
---|
762 | 771 | } |
---|
763 | 772 | up_read(&emu->card->controls_rwsem); |
---|
764 | | - if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && |
---|
765 | | - gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { |
---|
| 773 | + if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && |
---|
| 774 | + gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { |
---|
766 | 775 | err = -EINVAL; |
---|
767 | 776 | goto __error; |
---|
768 | 777 | } |
---|
.. | .. |
---|
797 | 806 | { |
---|
798 | 807 | unsigned int i, j; |
---|
799 | 808 | struct snd_emu10k1_fx8010_control_gpr *gctl; |
---|
| 809 | + struct snd_ctl_elem_id *gctl_id; |
---|
800 | 810 | struct snd_emu10k1_fx8010_ctl *ctl, *nctl; |
---|
801 | 811 | struct snd_kcontrol_new knew; |
---|
802 | 812 | struct snd_kcontrol *kctl; |
---|
.. | .. |
---|
817 | 827 | err = -EFAULT; |
---|
818 | 828 | goto __error; |
---|
819 | 829 | } |
---|
820 | | - if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && |
---|
821 | | - gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { |
---|
| 830 | + gctl_id = (struct snd_ctl_elem_id *)&gctl->id; |
---|
| 831 | + if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER && |
---|
| 832 | + gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) { |
---|
822 | 833 | err = -EINVAL; |
---|
823 | 834 | goto __error; |
---|
824 | 835 | } |
---|
825 | | - if (! gctl->id.name[0]) { |
---|
| 836 | + if (!*gctl_id->name) { |
---|
826 | 837 | err = -EINVAL; |
---|
827 | 838 | goto __error; |
---|
828 | 839 | } |
---|
829 | 840 | ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); |
---|
830 | 841 | memset(&knew, 0, sizeof(knew)); |
---|
831 | | - knew.iface = gctl->id.iface; |
---|
832 | | - knew.name = gctl->id.name; |
---|
833 | | - knew.index = gctl->id.index; |
---|
834 | | - knew.device = gctl->id.device; |
---|
835 | | - knew.subdevice = gctl->id.subdevice; |
---|
| 842 | + knew.iface = gctl_id->iface; |
---|
| 843 | + knew.name = gctl_id->name; |
---|
| 844 | + knew.index = gctl_id->index; |
---|
| 845 | + knew.device = gctl_id->device; |
---|
| 846 | + knew.subdevice = gctl_id->subdevice; |
---|
836 | 847 | knew.info = snd_emu10k1_gpr_ctl_info; |
---|
837 | | - knew.tlv.p = copy_tlv((__force const unsigned int __user *)gctl->tlv, in_kernel); |
---|
| 848 | + knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel); |
---|
838 | 849 | if (knew.tlv.p) |
---|
839 | 850 | knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
---|
840 | 851 | SNDRV_CTL_ELEM_ACCESS_TLV_READ; |
---|
.. | .. |
---|
890 | 901 | bool in_kernel) |
---|
891 | 902 | { |
---|
892 | 903 | unsigned int i; |
---|
893 | | - struct snd_ctl_elem_id id; |
---|
894 | | - struct snd_ctl_elem_id __user *_id; |
---|
| 904 | + struct emu10k1_ctl_elem_id id; |
---|
895 | 905 | struct snd_emu10k1_fx8010_ctl *ctl; |
---|
896 | 906 | struct snd_card *card = emu->card; |
---|
| 907 | + int err; |
---|
897 | 908 | |
---|
898 | | - for (i = 0, _id = icode->gpr_del_controls; |
---|
899 | | - i < icode->gpr_del_control_count; i++, _id++) { |
---|
900 | | - if (in_kernel) |
---|
901 | | - id = *(__force struct snd_ctl_elem_id *)_id; |
---|
902 | | - else if (copy_from_user(&id, _id, sizeof(id))) |
---|
903 | | - return -EFAULT; |
---|
| 909 | + for (i = 0; i < icode->gpr_del_control_count; i++) { |
---|
| 910 | + err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id, |
---|
| 911 | + in_kernel); |
---|
| 912 | + if (err < 0) |
---|
| 913 | + return err; |
---|
904 | 914 | down_write(&card->controls_rwsem); |
---|
905 | 915 | ctl = snd_emu10k1_look_for_ctl(emu, &id); |
---|
906 | 916 | if (ctl) |
---|
.. | .. |
---|
929 | 939 | i < icode->gpr_list_control_count) { |
---|
930 | 940 | memset(gctl, 0, sizeof(*gctl)); |
---|
931 | 941 | id = &ctl->kcontrol->id; |
---|
932 | | - gctl->id.iface = id->iface; |
---|
| 942 | + gctl->id.iface = (__force int)id->iface; |
---|
933 | 943 | strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name)); |
---|
934 | 944 | gctl->id.index = id->index; |
---|
935 | 945 | gctl->id.device = id->device; |
---|
.. | .. |
---|
1107 | 1117 | snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, |
---|
1108 | 1118 | const char *name, int gpr, int defval) |
---|
1109 | 1119 | { |
---|
1110 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1120 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1111 | 1121 | strcpy(ctl->id.name, name); |
---|
1112 | 1122 | ctl->vcount = ctl->count = 1; |
---|
1113 | 1123 | ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; |
---|
.. | .. |
---|
1128 | 1138 | snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, |
---|
1129 | 1139 | const char *name, int gpr, int defval) |
---|
1130 | 1140 | { |
---|
1131 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1141 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1132 | 1142 | strcpy(ctl->id.name, name); |
---|
1133 | 1143 | ctl->vcount = ctl->count = 2; |
---|
1134 | 1144 | ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; |
---|
.. | .. |
---|
1150 | 1160 | snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, |
---|
1151 | 1161 | const char *name, int gpr, int defval) |
---|
1152 | 1162 | { |
---|
1153 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1163 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1154 | 1164 | strcpy(ctl->id.name, name); |
---|
1155 | 1165 | ctl->vcount = ctl->count = 1; |
---|
1156 | 1166 | ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; |
---|
.. | .. |
---|
1163 | 1173 | snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, |
---|
1164 | 1174 | const char *name, int gpr, int defval) |
---|
1165 | 1175 | { |
---|
1166 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1176 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1167 | 1177 | strcpy(ctl->id.name, name); |
---|
1168 | 1178 | ctl->vcount = ctl->count = 2; |
---|
1169 | 1179 | ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; |
---|
.. | .. |
---|
1216 | 1226 | if (!icode) |
---|
1217 | 1227 | return err; |
---|
1218 | 1228 | |
---|
1219 | | - icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, |
---|
1220 | | - sizeof(u_int32_t), GFP_KERNEL); |
---|
| 1229 | + icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024, |
---|
| 1230 | + sizeof(u_int32_t), GFP_KERNEL); |
---|
1221 | 1231 | if (!icode->gpr_map) |
---|
1222 | 1232 | goto __err_gpr; |
---|
1223 | 1233 | controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, |
---|
.. | .. |
---|
1225 | 1235 | if (!controls) |
---|
1226 | 1236 | goto __err_ctrls; |
---|
1227 | 1237 | |
---|
1228 | | - gpr_map = (u32 __force *)icode->gpr_map; |
---|
| 1238 | + gpr_map = icode->gpr_map; |
---|
1229 | 1239 | |
---|
1230 | 1240 | icode->tram_data_map = icode->gpr_map + 512; |
---|
1231 | 1241 | icode->tram_addr_map = icode->tram_data_map + 256; |
---|
.. | .. |
---|
1480 | 1490 | |
---|
1481 | 1491 | |
---|
1482 | 1492 | ctl = &controls[nctl + 0]; |
---|
1483 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1493 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1484 | 1494 | strcpy(ctl->id.name, "Tone Control - Bass"); |
---|
1485 | 1495 | ctl->vcount = 2; |
---|
1486 | 1496 | ctl->count = 10; |
---|
.. | .. |
---|
1489 | 1499 | ctl->value[0] = ctl->value[1] = 20; |
---|
1490 | 1500 | ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; |
---|
1491 | 1501 | ctl = &controls[nctl + 1]; |
---|
1492 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 1502 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
1493 | 1503 | strcpy(ctl->id.name, "Tone Control - Treble"); |
---|
1494 | 1504 | ctl->vcount = 2; |
---|
1495 | 1505 | ctl->count = 10; |
---|
.. | .. |
---|
1770 | 1780 | A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0); |
---|
1771 | 1781 | |
---|
1772 | 1782 | icode->gpr_add_control_count = nctl; |
---|
1773 | | - icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; |
---|
| 1783 | + icode->gpr_add_controls = controls; |
---|
1774 | 1784 | emu->support_tlv = 1; /* support TLV */ |
---|
1775 | 1785 | err = snd_emu10k1_icode_poke(emu, icode, true); |
---|
1776 | 1786 | emu->support_tlv = 0; /* clear again */ |
---|
.. | .. |
---|
1778 | 1788 | __err: |
---|
1779 | 1789 | kfree(controls); |
---|
1780 | 1790 | __err_ctrls: |
---|
1781 | | - kfree((void __force *)icode->gpr_map); |
---|
| 1791 | + kfree(icode->gpr_map); |
---|
1782 | 1792 | __err_gpr: |
---|
1783 | 1793 | kfree(icode); |
---|
1784 | 1794 | return err; |
---|
.. | .. |
---|
1851 | 1861 | if (!icode) |
---|
1852 | 1862 | return err; |
---|
1853 | 1863 | |
---|
1854 | | - icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512, |
---|
1855 | | - sizeof(u_int32_t), GFP_KERNEL); |
---|
| 1864 | + icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512, |
---|
| 1865 | + sizeof(u_int32_t), GFP_KERNEL); |
---|
1856 | 1866 | if (!icode->gpr_map) |
---|
1857 | 1867 | goto __err_gpr; |
---|
1858 | 1868 | |
---|
.. | .. |
---|
1866 | 1876 | if (!ipcm) |
---|
1867 | 1877 | goto __err_ipcm; |
---|
1868 | 1878 | |
---|
1869 | | - gpr_map = (u32 __force *)icode->gpr_map; |
---|
| 1879 | + gpr_map = icode->gpr_map; |
---|
1870 | 1880 | |
---|
1871 | 1881 | icode->tram_data_map = icode->gpr_map + 256; |
---|
1872 | 1882 | icode->tram_addr_map = icode->tram_data_map + 160; |
---|
.. | .. |
---|
2200 | 2210 | OP(icode, &ptr, iACC3, GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), GPR(playback + 5), C_00000000, C_00000000); /* LFE */ |
---|
2201 | 2211 | |
---|
2202 | 2212 | ctl = &controls[i + 0]; |
---|
2203 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 2213 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
2204 | 2214 | strcpy(ctl->id.name, "Tone Control - Bass"); |
---|
2205 | 2215 | ctl->vcount = 2; |
---|
2206 | 2216 | ctl->count = 10; |
---|
.. | .. |
---|
2210 | 2220 | ctl->tlv = snd_emu10k1_bass_treble_db_scale; |
---|
2211 | 2221 | ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; |
---|
2212 | 2222 | ctl = &controls[i + 1]; |
---|
2213 | | - ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
| 2223 | + ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER; |
---|
2214 | 2224 | strcpy(ctl->id.name, "Tone Control - Treble"); |
---|
2215 | 2225 | ctl->vcount = 2; |
---|
2216 | 2226 | ctl->count = 10; |
---|
.. | .. |
---|
2396 | 2406 | if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0) |
---|
2397 | 2407 | goto __err; |
---|
2398 | 2408 | icode->gpr_add_control_count = i; |
---|
2399 | | - icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; |
---|
| 2409 | + icode->gpr_add_controls = controls; |
---|
2400 | 2410 | emu->support_tlv = 1; /* support TLV */ |
---|
2401 | 2411 | err = snd_emu10k1_icode_poke(emu, icode, true); |
---|
2402 | 2412 | emu->support_tlv = 0; /* clear again */ |
---|
.. | .. |
---|
2407 | 2417 | __err_ipcm: |
---|
2408 | 2418 | kfree(controls); |
---|
2409 | 2419 | __err_ctrls: |
---|
2410 | | - kfree((void __force *)icode->gpr_map); |
---|
| 2420 | + kfree(icode->gpr_map); |
---|
2411 | 2421 | __err_gpr: |
---|
2412 | 2422 | kfree(icode); |
---|
2413 | 2423 | return err; |
---|
.. | .. |
---|
2478 | 2488 | } |
---|
2479 | 2489 | |
---|
2480 | 2490 | if (size > 0) { |
---|
2481 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), |
---|
| 2491 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &emu->pci->dev, |
---|
2482 | 2492 | size * 2, &emu->fx8010.etram_pages) < 0) |
---|
2483 | 2493 | return -ENOMEM; |
---|
2484 | 2494 | memset(emu->fx8010.etram_pages.area, 0, size * 2); |
---|
.. | .. |
---|
2497 | 2507 | return 0; |
---|
2498 | 2508 | } |
---|
2499 | 2509 | |
---|
2500 | | -static void copy_string(char *dst, char *src, char *null, int idx) |
---|
| 2510 | +static void copy_string(char *dst, const char *src, const char *null, int idx) |
---|
2501 | 2511 | { |
---|
2502 | 2512 | if (src == NULL) |
---|
2503 | 2513 | sprintf(dst, "%s %02X", null, idx); |
---|
.. | .. |
---|
2508 | 2518 | static void snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, |
---|
2509 | 2519 | struct snd_emu10k1_fx8010_info *info) |
---|
2510 | 2520 | { |
---|
2511 | | - char **fxbus, **extin, **extout; |
---|
| 2521 | + const char * const *fxbus, * const *extin, * const *extout; |
---|
2512 | 2522 | unsigned short fxbus_mask, extin_mask, extout_mask; |
---|
2513 | 2523 | int res; |
---|
2514 | 2524 | |
---|