Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: Drop soc-topology ABI v4 support

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

This patchset impacts UAPI.

The only known users of the soc-topology ABI v4 are Chromebook
configurations. Starting from kernel v5.4, all of them are making use of
soc-topology ABI v5. The patchset first removes obsolete code from the
Intel's skylake-driver - the driver of choice for the mentioned
Chromebooks - and then proceeds with removal of relevant soc-topology.c
and uapi bits.

Cezary Rojewski (4):
ASoC: Intel: Skylake: Remove soc-topology ABI v4 support
ASoC: topology: Remove ABI v4 support
ASoC: topology: Cleanup after ABI v4 support removal
ASoC: topology: Remove obsolete ABI v4 structs

include/uapi/sound/asoc.h | 56 ------
include/uapi/sound/skl-tplg-interface.h | 74 --------
sound/soc/intel/skylake/skl-topology.c | 169 -----------------
sound/soc/soc-topology.c | 241 ++----------------------
4 files changed, 18 insertions(+), 522 deletions(-)

--
2.25.1

+18 -522
-56
include/uapi/sound/asoc.h
··· 576 576 struct snd_soc_tplg_private priv; 577 577 } __attribute__((packed)); 578 578 579 - /* 580 - * Old version of ABI structs, supported for backward compatibility. 581 - */ 582 - 583 - /* Manifest v4 */ 584 - struct snd_soc_tplg_manifest_v4 { 585 - __le32 size; /* in bytes of this structure */ 586 - __le32 control_elems; /* number of control elements */ 587 - __le32 widget_elems; /* number of widget elements */ 588 - __le32 graph_elems; /* number of graph elements */ 589 - __le32 pcm_elems; /* number of PCM elements */ 590 - __le32 dai_link_elems; /* number of DAI link elements */ 591 - struct snd_soc_tplg_private priv; 592 - } __packed; 593 - 594 - /* Stream Capabilities v4 */ 595 - struct snd_soc_tplg_stream_caps_v4 { 596 - __le32 size; /* in bytes of this structure */ 597 - char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 598 - __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */ 599 - __le32 rates; /* supported rates SNDRV_PCM_RATE_* */ 600 - __le32 rate_min; /* min rate */ 601 - __le32 rate_max; /* max rate */ 602 - __le32 channels_min; /* min channels */ 603 - __le32 channels_max; /* max channels */ 604 - __le32 periods_min; /* min number of periods */ 605 - __le32 periods_max; /* max number of periods */ 606 - __le32 period_size_min; /* min period size bytes */ 607 - __le32 period_size_max; /* max period size bytes */ 608 - __le32 buffer_size_min; /* min buffer size bytes */ 609 - __le32 buffer_size_max; /* max buffer size bytes */ 610 - } __packed; 611 - 612 - /* PCM v4 */ 613 - struct snd_soc_tplg_pcm_v4 { 614 - __le32 size; /* in bytes of this structure */ 615 - char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 616 - char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 617 - __le32 pcm_id; /* unique ID - used to match with DAI link */ 618 - __le32 dai_id; /* unique ID - used to match */ 619 - __le32 playback; /* supports playback mode */ 620 - __le32 capture; /* supports capture mode */ 621 - __le32 compress; /* 1 = compressed; 0 = PCM */ 622 - struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ 623 - __le32 num_streams; /* number of streams */ 624 - struct snd_soc_tplg_stream_caps_v4 caps[2]; /* playback and capture for DAI */ 625 - } __packed; 626 - 627 - /* Physical link config v4 */ 628 - struct snd_soc_tplg_link_config_v4 { 629 - __le32 size; /* in bytes of this structure */ 630 - __le32 id; /* unique ID - used to match */ 631 - struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */ 632 - __le32 num_streams; /* number of streams */ 633 - } __packed; 634 - 635 579 #endif
-74
include/uapi/sound/skl-tplg-interface.h
··· 165 165 SKL_TYPE_DATA 166 166 }; 167 167 168 - /* v4 configuration data */ 169 - 170 - struct skl_dfw_v4_module_pin { 171 - __u16 module_id; 172 - __u16 instance_id; 173 - } __packed; 174 - 175 - struct skl_dfw_v4_module_fmt { 176 - __u32 channels; 177 - __u32 freq; 178 - __u32 bit_depth; 179 - __u32 valid_bit_depth; 180 - __u32 ch_cfg; 181 - __u32 interleaving_style; 182 - __u32 sample_type; 183 - __u32 ch_map; 184 - } __packed; 185 - 186 - struct skl_dfw_v4_module_caps { 187 - __u32 set_params:2; 188 - __u32 rsvd:30; 189 - __u32 param_id; 190 - __u32 caps_size; 191 - __u32 caps[HDA_SST_CFG_MAX]; 192 - } __packed; 193 - 194 - struct skl_dfw_v4_pipe { 195 - __u8 pipe_id; 196 - __u8 pipe_priority; 197 - __u16 conn_type:4; 198 - __u16 rsvd:4; 199 - __u16 memory_pages:8; 200 - } __packed; 201 - 202 - struct skl_dfw_v4_module { 203 - char uuid[SKL_UUID_STR_SZ]; 204 - 205 - __u16 module_id; 206 - __u16 instance_id; 207 - __u32 max_mcps; 208 - __u32 mem_pages; 209 - __u32 obs; 210 - __u32 ibs; 211 - __u32 vbus_id; 212 - 213 - __u32 max_in_queue:8; 214 - __u32 max_out_queue:8; 215 - __u32 time_slot:8; 216 - __u32 core_id:4; 217 - __u32 rsvd1:4; 218 - 219 - __u32 module_type:8; 220 - __u32 conn_type:4; 221 - __u32 dev_type:4; 222 - __u32 hw_conn_type:4; 223 - __u32 rsvd2:12; 224 - 225 - __u32 params_fixup:8; 226 - __u32 converter:8; 227 - __u32 input_pin_type:1; 228 - __u32 output_pin_type:1; 229 - __u32 is_dynamic_in_pin:1; 230 - __u32 is_dynamic_out_pin:1; 231 - __u32 is_loadable:1; 232 - __u32 rsvd3:11; 233 - 234 - struct skl_dfw_v4_pipe pipe; 235 - struct skl_dfw_v4_module_fmt in_fmt[MAX_IN_QUEUE]; 236 - struct skl_dfw_v4_module_fmt out_fmt[MAX_OUT_QUEUE]; 237 - struct skl_dfw_v4_module_pin in_pin[MAX_IN_QUEUE]; 238 - struct skl_dfw_v4_module_pin out_pin[MAX_OUT_QUEUE]; 239 - struct skl_dfw_v4_module_caps caps; 240 - } __packed; 241 - 242 168 #endif
-169
sound/soc/intel/skylake/skl-topology.c
··· 2682 2682 return -EINVAL; 2683 2683 } 2684 2684 2685 - /* Functions to parse private data from configuration file format v4 */ 2686 - 2687 - /* 2688 - * Add pipeline from topology binary into driver pipeline list 2689 - * 2690 - * If already added we return that instance 2691 - * Otherwise we create a new instance and add into driver list 2692 - */ 2693 - static int skl_tplg_add_pipe_v4(struct device *dev, 2694 - struct skl_module_cfg *mconfig, struct skl_dev *skl, 2695 - struct skl_dfw_v4_pipe *dfw_pipe) 2696 - { 2697 - struct skl_pipeline *ppl; 2698 - struct skl_pipe *pipe; 2699 - struct skl_pipe_params *params; 2700 - 2701 - list_for_each_entry(ppl, &skl->ppl_list, node) { 2702 - if (ppl->pipe->ppl_id == dfw_pipe->pipe_id) { 2703 - mconfig->pipe = ppl->pipe; 2704 - return 0; 2705 - } 2706 - } 2707 - 2708 - ppl = devm_kzalloc(dev, sizeof(*ppl), GFP_KERNEL); 2709 - if (!ppl) 2710 - return -ENOMEM; 2711 - 2712 - pipe = devm_kzalloc(dev, sizeof(*pipe), GFP_KERNEL); 2713 - if (!pipe) 2714 - return -ENOMEM; 2715 - 2716 - params = devm_kzalloc(dev, sizeof(*params), GFP_KERNEL); 2717 - if (!params) 2718 - return -ENOMEM; 2719 - 2720 - pipe->ppl_id = dfw_pipe->pipe_id; 2721 - pipe->memory_pages = dfw_pipe->memory_pages; 2722 - pipe->pipe_priority = dfw_pipe->pipe_priority; 2723 - pipe->conn_type = dfw_pipe->conn_type; 2724 - pipe->state = SKL_PIPE_INVALID; 2725 - pipe->p_params = params; 2726 - INIT_LIST_HEAD(&pipe->w_list); 2727 - 2728 - ppl->pipe = pipe; 2729 - list_add(&ppl->node, &skl->ppl_list); 2730 - 2731 - mconfig->pipe = pipe; 2732 - 2733 - return 0; 2734 - } 2735 - 2736 - static void skl_fill_module_pin_info_v4(struct skl_dfw_v4_module_pin *dfw_pin, 2737 - struct skl_module_pin *m_pin, 2738 - bool is_dynamic, int max_pin) 2739 - { 2740 - int i; 2741 - 2742 - for (i = 0; i < max_pin; i++) { 2743 - m_pin[i].id.module_id = dfw_pin[i].module_id; 2744 - m_pin[i].id.instance_id = dfw_pin[i].instance_id; 2745 - m_pin[i].in_use = false; 2746 - m_pin[i].is_dynamic = is_dynamic; 2747 - m_pin[i].pin_state = SKL_PIN_UNBIND; 2748 - } 2749 - } 2750 - 2751 - static void skl_tplg_fill_fmt_v4(struct skl_module_pin_fmt *dst_fmt, 2752 - struct skl_dfw_v4_module_fmt *src_fmt, 2753 - int pins) 2754 - { 2755 - int i; 2756 - 2757 - for (i = 0; i < pins; i++) { 2758 - dst_fmt[i].fmt.channels = src_fmt[i].channels; 2759 - dst_fmt[i].fmt.s_freq = src_fmt[i].freq; 2760 - dst_fmt[i].fmt.bit_depth = src_fmt[i].bit_depth; 2761 - dst_fmt[i].fmt.valid_bit_depth = src_fmt[i].valid_bit_depth; 2762 - dst_fmt[i].fmt.ch_cfg = src_fmt[i].ch_cfg; 2763 - dst_fmt[i].fmt.ch_map = src_fmt[i].ch_map; 2764 - dst_fmt[i].fmt.interleaving_style = 2765 - src_fmt[i].interleaving_style; 2766 - dst_fmt[i].fmt.sample_type = src_fmt[i].sample_type; 2767 - } 2768 - } 2769 - 2770 - static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, 2771 - struct skl_dev *skl, struct device *dev, 2772 - struct skl_module_cfg *mconfig) 2773 - { 2774 - struct skl_dfw_v4_module *dfw = 2775 - (struct skl_dfw_v4_module *)tplg_w->priv.data; 2776 - int ret; 2777 - int idx = mconfig->fmt_cfg_idx; 2778 - 2779 - dev_dbg(dev, "Parsing Skylake v4 widget topology data\n"); 2780 - 2781 - ret = guid_parse(dfw->uuid, (guid_t *)mconfig->guid); 2782 - if (ret) 2783 - return ret; 2784 - mconfig->id.module_id = -1; 2785 - mconfig->id.instance_id = dfw->instance_id; 2786 - mconfig->module->resources[0].cpc = dfw->max_mcps / 1000; 2787 - mconfig->module->resources[0].ibs = dfw->ibs; 2788 - mconfig->module->resources[0].obs = dfw->obs; 2789 - mconfig->core_id = dfw->core_id; 2790 - mconfig->module->max_input_pins = dfw->max_in_queue; 2791 - mconfig->module->max_output_pins = dfw->max_out_queue; 2792 - mconfig->module->loadable = dfw->is_loadable; 2793 - skl_tplg_fill_fmt_v4(mconfig->module->formats[0].inputs, dfw->in_fmt, 2794 - MAX_IN_QUEUE); 2795 - skl_tplg_fill_fmt_v4(mconfig->module->formats[0].outputs, dfw->out_fmt, 2796 - MAX_OUT_QUEUE); 2797 - 2798 - mconfig->params_fixup = dfw->params_fixup; 2799 - mconfig->converter = dfw->converter; 2800 - mconfig->m_type = dfw->module_type; 2801 - mconfig->vbus_id = dfw->vbus_id; 2802 - mconfig->module->resources[0].is_pages = dfw->mem_pages; 2803 - 2804 - ret = skl_tplg_add_pipe_v4(dev, mconfig, skl, &dfw->pipe); 2805 - if (ret) 2806 - return ret; 2807 - 2808 - mconfig->dev_type = dfw->dev_type; 2809 - mconfig->hw_conn_type = dfw->hw_conn_type; 2810 - mconfig->time_slot = dfw->time_slot; 2811 - mconfig->formats_config[idx].caps_size = dfw->caps.caps_size; 2812 - 2813 - mconfig->m_in_pin = devm_kcalloc(dev, 2814 - MAX_IN_QUEUE, sizeof(*mconfig->m_in_pin), 2815 - GFP_KERNEL); 2816 - if (!mconfig->m_in_pin) 2817 - return -ENOMEM; 2818 - 2819 - mconfig->m_out_pin = devm_kcalloc(dev, 2820 - MAX_OUT_QUEUE, sizeof(*mconfig->m_out_pin), 2821 - GFP_KERNEL); 2822 - if (!mconfig->m_out_pin) 2823 - return -ENOMEM; 2824 - 2825 - skl_fill_module_pin_info_v4(dfw->in_pin, mconfig->m_in_pin, 2826 - dfw->is_dynamic_in_pin, 2827 - mconfig->module->max_input_pins); 2828 - skl_fill_module_pin_info_v4(dfw->out_pin, mconfig->m_out_pin, 2829 - dfw->is_dynamic_out_pin, 2830 - mconfig->module->max_output_pins); 2831 - 2832 - if (mconfig->formats_config[idx].caps_size) { 2833 - mconfig->formats_config[idx].set_params = dfw->caps.set_params; 2834 - mconfig->formats_config[idx].param_id = dfw->caps.param_id; 2835 - mconfig->formats_config[idx].caps = 2836 - devm_kzalloc(dev, mconfig->formats_config[idx].caps_size, 2837 - GFP_KERNEL); 2838 - if (!mconfig->formats_config[idx].caps) 2839 - return -ENOMEM; 2840 - memcpy(mconfig->formats_config[idx].caps, dfw->caps.caps, 2841 - dfw->caps.caps_size); 2842 - } 2843 - 2844 - return 0; 2845 - } 2846 - 2847 2685 static int skl_tplg_get_caps_data(struct device *dev, char *data, 2848 2686 struct skl_module_cfg *mconfig) 2849 2687 { ··· 2714 2876 int num_blocks, block_size, block_type, off = 0; 2715 2877 char *data; 2716 2878 int ret; 2717 - 2718 - /* 2719 - * v4 configuration files have a valid UUID at the start of 2720 - * the widget's private data. 2721 - */ 2722 - if (uuid_is_valid((char *)tplg_w->priv.data)) 2723 - return skl_tplg_get_pvt_data_v4(tplg_w, skl, dev, mconfig); 2724 2879 2725 2880 /* Read the NUM_DATA_BLOCKS descriptor */ 2726 2881 array = (struct snd_soc_tplg_vendor_array *)tplg_w->priv.data;
+18 -223
sound/soc/soc-topology.c
··· 1768 1768 return soc_tplg_fe_link_create(tplg, pcm); 1769 1769 } 1770 1770 1771 - /* copy stream caps from the old version 4 of source */ 1772 - static void stream_caps_new_ver(struct snd_soc_tplg_stream_caps *dest, 1773 - struct snd_soc_tplg_stream_caps_v4 *src) 1774 - { 1775 - dest->size = cpu_to_le32(sizeof(*dest)); 1776 - memcpy(dest->name, src->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); 1777 - dest->formats = src->formats; 1778 - dest->rates = src->rates; 1779 - dest->rate_min = src->rate_min; 1780 - dest->rate_max = src->rate_max; 1781 - dest->channels_min = src->channels_min; 1782 - dest->channels_max = src->channels_max; 1783 - dest->periods_min = src->periods_min; 1784 - dest->periods_max = src->periods_max; 1785 - dest->period_size_min = src->period_size_min; 1786 - dest->period_size_max = src->period_size_max; 1787 - dest->buffer_size_min = src->buffer_size_min; 1788 - dest->buffer_size_max = src->buffer_size_max; 1789 - } 1790 - 1791 - /** 1792 - * pcm_new_ver - Create the new version of PCM from the old version. 1793 - * @tplg: topology context 1794 - * @src: older version of pcm as a source 1795 - * @pcm: latest version of pcm created from the source 1796 - * 1797 - * Support from version 4. User should free the returned pcm manually. 1798 - */ 1799 - static int pcm_new_ver(struct soc_tplg *tplg, 1800 - struct snd_soc_tplg_pcm *src, 1801 - struct snd_soc_tplg_pcm **pcm) 1802 - { 1803 - struct snd_soc_tplg_pcm *dest; 1804 - struct snd_soc_tplg_pcm_v4 *src_v4; 1805 - int i; 1806 - 1807 - *pcm = NULL; 1808 - 1809 - if (le32_to_cpu(src->size) != sizeof(*src_v4)) { 1810 - dev_err(tplg->dev, "ASoC: invalid PCM size\n"); 1811 - return -EINVAL; 1812 - } 1813 - 1814 - dev_warn(tplg->dev, "ASoC: old version of PCM\n"); 1815 - src_v4 = (struct snd_soc_tplg_pcm_v4 *)src; 1816 - dest = kzalloc(sizeof(*dest), GFP_KERNEL); 1817 - if (!dest) 1818 - return -ENOMEM; 1819 - 1820 - dest->size = cpu_to_le32(sizeof(*dest)); /* size of latest abi version */ 1821 - memcpy(dest->pcm_name, src_v4->pcm_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); 1822 - memcpy(dest->dai_name, src_v4->dai_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); 1823 - dest->pcm_id = src_v4->pcm_id; 1824 - dest->dai_id = src_v4->dai_id; 1825 - dest->playback = src_v4->playback; 1826 - dest->capture = src_v4->capture; 1827 - dest->compress = src_v4->compress; 1828 - dest->num_streams = src_v4->num_streams; 1829 - for (i = 0; i < le32_to_cpu(dest->num_streams); i++) 1830 - memcpy(&dest->stream[i], &src_v4->stream[i], 1831 - sizeof(struct snd_soc_tplg_stream)); 1832 - 1833 - for (i = 0; i < 2; i++) 1834 - stream_caps_new_ver(&dest->caps[i], &src_v4->caps[i]); 1835 - 1836 - *pcm = dest; 1837 - return 0; 1838 - } 1839 - 1840 1771 static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg, 1841 1772 struct snd_soc_tplg_hdr *hdr) 1842 1773 { 1843 - struct snd_soc_tplg_pcm *pcm, *_pcm; 1774 + struct snd_soc_tplg_pcm *pcm; 1844 1775 int count; 1845 1776 int size; 1846 1777 int i; 1847 - bool abi_match; 1848 1778 int ret; 1849 1779 1850 1780 count = le32_to_cpu(hdr->count); ··· 1782 1852 /* check the element size and count */ 1783 1853 pcm = (struct snd_soc_tplg_pcm *)tplg->pos; 1784 1854 size = le32_to_cpu(pcm->size); 1785 - if (size > sizeof(struct snd_soc_tplg_pcm) 1786 - || size < sizeof(struct snd_soc_tplg_pcm_v4)) { 1855 + if (size > sizeof(struct snd_soc_tplg_pcm)) { 1787 1856 dev_err(tplg->dev, "ASoC: invalid size %d for PCM elems\n", 1788 1857 size); 1789 1858 return -EINVAL; ··· 1801 1872 /* check ABI version by size, create a new version of pcm 1802 1873 * if abi not match. 1803 1874 */ 1804 - if (size == sizeof(*pcm)) { 1805 - abi_match = true; 1806 - _pcm = pcm; 1807 - } else { 1808 - abi_match = false; 1809 - ret = pcm_new_ver(tplg, pcm, &_pcm); 1810 - if (ret < 0) 1811 - return ret; 1812 - } 1875 + if (size != sizeof(*pcm)) 1876 + return -EINVAL; 1813 1877 1814 1878 /* create the FE DAIs and DAI links */ 1815 - ret = soc_tplg_pcm_create(tplg, _pcm); 1816 - if (ret < 0) { 1817 - if (!abi_match) 1818 - kfree(_pcm); 1879 + ret = soc_tplg_pcm_create(tplg, pcm); 1880 + if (ret < 0) 1819 1881 return ret; 1820 - } 1821 1882 1822 1883 /* offset by version-specific struct size and 1823 1884 * real priv data size 1824 1885 */ 1825 - tplg->pos += size + le32_to_cpu(_pcm->priv.size); 1826 - 1827 - if (!abi_match) 1828 - kfree(_pcm); /* free the duplicated one */ 1886 + tplg->pos += size + le32_to_cpu(pcm->priv.size); 1829 1887 } 1830 1888 1831 1889 dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count); ··· 1886 1970 else 1887 1971 link->dai_fmt |= SND_SOC_DAIFMT_CBC_CFC; 1888 1972 } 1889 - } 1890 - 1891 - /** 1892 - * link_new_ver - Create a new physical link config from the old 1893 - * version of source. 1894 - * @tplg: topology context 1895 - * @src: old version of phyical link config as a source 1896 - * @link: latest version of physical link config created from the source 1897 - * 1898 - * Support from version 4. User need free the returned link config manually. 1899 - */ 1900 - static int link_new_ver(struct soc_tplg *tplg, 1901 - struct snd_soc_tplg_link_config *src, 1902 - struct snd_soc_tplg_link_config **link) 1903 - { 1904 - struct snd_soc_tplg_link_config *dest; 1905 - struct snd_soc_tplg_link_config_v4 *src_v4; 1906 - int i; 1907 - 1908 - *link = NULL; 1909 - 1910 - if (le32_to_cpu(src->size) != 1911 - sizeof(struct snd_soc_tplg_link_config_v4)) { 1912 - dev_err(tplg->dev, "ASoC: invalid physical link config size\n"); 1913 - return -EINVAL; 1914 - } 1915 - 1916 - dev_warn(tplg->dev, "ASoC: old version of physical link config\n"); 1917 - 1918 - src_v4 = (struct snd_soc_tplg_link_config_v4 *)src; 1919 - dest = kzalloc(sizeof(*dest), GFP_KERNEL); 1920 - if (!dest) 1921 - return -ENOMEM; 1922 - 1923 - dest->size = cpu_to_le32(sizeof(*dest)); 1924 - dest->id = src_v4->id; 1925 - dest->num_streams = src_v4->num_streams; 1926 - for (i = 0; i < le32_to_cpu(dest->num_streams); i++) 1927 - memcpy(&dest->stream[i], &src_v4->stream[i], 1928 - sizeof(struct snd_soc_tplg_stream)); 1929 - 1930 - *link = dest; 1931 - return 0; 1932 1973 } 1933 1974 1934 1975 /** ··· 1993 2120 static int soc_tplg_link_elems_load(struct soc_tplg *tplg, 1994 2121 struct snd_soc_tplg_hdr *hdr) 1995 2122 { 1996 - struct snd_soc_tplg_link_config *link, *_link; 2123 + struct snd_soc_tplg_link_config *link; 1997 2124 int count; 1998 2125 int size; 1999 2126 int i, ret; 2000 - bool abi_match; 2001 2127 2002 2128 count = le32_to_cpu(hdr->count); 2003 2129 2004 2130 /* check the element size and count */ 2005 2131 link = (struct snd_soc_tplg_link_config *)tplg->pos; 2006 2132 size = le32_to_cpu(link->size); 2007 - if (size > sizeof(struct snd_soc_tplg_link_config) 2008 - || size < sizeof(struct snd_soc_tplg_link_config_v4)) { 2133 + if (size > sizeof(struct snd_soc_tplg_link_config)) { 2009 2134 dev_err(tplg->dev, "ASoC: invalid size %d for physical link elems\n", 2010 2135 size); 2011 2136 return -EINVAL; ··· 2018 2147 for (i = 0; i < count; i++) { 2019 2148 link = (struct snd_soc_tplg_link_config *)tplg->pos; 2020 2149 size = le32_to_cpu(link->size); 2021 - if (size == sizeof(*link)) { 2022 - abi_match = true; 2023 - _link = link; 2024 - } else { 2025 - abi_match = false; 2026 - ret = link_new_ver(tplg, link, &_link); 2027 - if (ret < 0) 2028 - return ret; 2029 - } 2150 + if (size != sizeof(*link)) 2151 + return -EINVAL; 2030 2152 2031 - ret = soc_tplg_link_config(tplg, _link); 2032 - if (ret < 0) { 2033 - if (!abi_match) 2034 - kfree(_link); 2153 + ret = soc_tplg_link_config(tplg, link); 2154 + if (ret < 0) 2035 2155 return ret; 2036 - } 2037 2156 2038 2157 /* offset by version-specific struct size and 2039 2158 * real priv data size 2040 2159 */ 2041 - tplg->pos += size + le32_to_cpu(_link->priv.size); 2042 - 2043 - if (!abi_match) 2044 - kfree(_link); /* free the duplicated one */ 2160 + tplg->pos += size + le32_to_cpu(link->priv.size); 2045 2161 } 2046 2162 2047 2163 return 0; ··· 2138 2280 return 0; 2139 2281 } 2140 2282 2141 - /** 2142 - * manifest_new_ver - Create a new version of manifest from the old version 2143 - * of source. 2144 - * @tplg: topology context 2145 - * @src: old version of manifest as a source 2146 - * @manifest: latest version of manifest created from the source 2147 - * 2148 - * Support from version 4. Users need free the returned manifest manually. 2149 - */ 2150 - static int manifest_new_ver(struct soc_tplg *tplg, 2151 - struct snd_soc_tplg_manifest *src, 2152 - struct snd_soc_tplg_manifest **manifest) 2153 - { 2154 - struct snd_soc_tplg_manifest *dest; 2155 - struct snd_soc_tplg_manifest_v4 *src_v4; 2156 - int size; 2157 - 2158 - *manifest = NULL; 2159 - 2160 - size = le32_to_cpu(src->size); 2161 - if (size != sizeof(*src_v4)) { 2162 - dev_warn(tplg->dev, "ASoC: invalid manifest size %d\n", 2163 - size); 2164 - if (size) 2165 - return -EINVAL; 2166 - src->size = cpu_to_le32(sizeof(*src_v4)); 2167 - } 2168 - 2169 - dev_warn(tplg->dev, "ASoC: old version of manifest\n"); 2170 - 2171 - src_v4 = (struct snd_soc_tplg_manifest_v4 *)src; 2172 - dest = kzalloc(sizeof(*dest) + le32_to_cpu(src_v4->priv.size), 2173 - GFP_KERNEL); 2174 - if (!dest) 2175 - return -ENOMEM; 2176 - 2177 - dest->size = cpu_to_le32(sizeof(*dest)); /* size of latest abi version */ 2178 - dest->control_elems = src_v4->control_elems; 2179 - dest->widget_elems = src_v4->widget_elems; 2180 - dest->graph_elems = src_v4->graph_elems; 2181 - dest->pcm_elems = src_v4->pcm_elems; 2182 - dest->dai_link_elems = src_v4->dai_link_elems; 2183 - dest->priv.size = src_v4->priv.size; 2184 - if (dest->priv.size) 2185 - memcpy(dest->priv.data, src_v4->priv.data, 2186 - le32_to_cpu(src_v4->priv.size)); 2187 - 2188 - *manifest = dest; 2189 - return 0; 2190 - } 2191 - 2192 2283 static int soc_tplg_manifest_load(struct soc_tplg *tplg, 2193 2284 struct snd_soc_tplg_hdr *hdr) 2194 2285 { 2195 - struct snd_soc_tplg_manifest *manifest, *_manifest; 2196 - bool abi_match; 2286 + struct snd_soc_tplg_manifest *manifest; 2197 2287 int ret = 0; 2198 2288 2199 2289 manifest = (struct snd_soc_tplg_manifest *)tplg->pos; 2200 2290 2201 2291 /* check ABI version by size, create a new manifest if abi not match */ 2202 - if (le32_to_cpu(manifest->size) == sizeof(*manifest)) { 2203 - abi_match = true; 2204 - _manifest = manifest; 2205 - } else { 2206 - abi_match = false; 2207 - 2208 - ret = manifest_new_ver(tplg, manifest, &_manifest); 2209 - if (ret < 0) 2210 - return ret; 2211 - } 2292 + if (le32_to_cpu(manifest->size) != sizeof(*manifest)) 2293 + return -EINVAL; 2212 2294 2213 2295 /* pass control to component driver for optional further init */ 2214 2296 if (tplg->ops && tplg->ops->manifest) 2215 - ret = tplg->ops->manifest(tplg->comp, tplg->index, _manifest); 2216 - 2217 - if (!abi_match) /* free the duplicated one */ 2218 - kfree(_manifest); 2297 + ret = tplg->ops->manifest(tplg->comp, tplg->index, manifest); 2219 2298 2220 2299 return ret; 2221 2300 }