From: kbuild test robot <lkp@intel.com>
To: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Cc: kbuild-all@01.org, Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] usb: gadget: add USB Audio Device Class 3.0 gadget support
Date: Tue, 7 Nov 2017 21:20:31 +0800 [thread overview]
Message-ID: <201711072109.bPwho9kY%fengguang.wu@intel.com> (raw)
In-Reply-To: <1510019522-15155-2-git-send-email-ruslan.bilovol@gmail.com>
Hi Ruslan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on balbi-usb/next]
[also build test WARNING on v4.14-rc8 next-20171107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ruslan-Bilovol/usb-gadget-add-USB-Audio-Device-Class-3-0-gadget-support/20171107-175202
base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
coccinelle warnings: (new ones prefixed by >>)
>> drivers/usb/gadget/function/f_uac3.c:766:2-9: alloc with no test, possible model on line 780
vim +766 drivers/usb/gadget/function/f_uac3.c
722
723 static int f_audio_bind(struct usb_configuration *cfg, struct usb_function *fn)
724 {
725 struct f_uac3 *uac3 = func_to_uac3(fn);
726 struct g_audio *audio = func_to_g_audio(fn);
727 struct usb_composite_dev *cdev = cfg->cdev;
728 struct usb_gadget *gadget = cdev->gadget;
729 struct device *dev = &gadget->dev;
730 struct f_uac3_opts *uac3_opts;
731 struct uac3_hc_descriptor_header *cluster_desc;
732 struct uac3_hc_desc *hc_desc;
733 struct usb_string *us;
734 u16 hc_desc_id = 1; /* HC id always starts from 1 */
735 int ret;
736
737 uac3_opts = container_of(fn->fi, struct f_uac3_opts, func_inst);
738
739 us = usb_gstrings_attach(cdev, fn_strings, ARRAY_SIZE(strings_fn));
740 if (IS_ERR(us))
741 return PTR_ERR(us);
742
743 iad_desc.iFunction = us[STR_ASSOC].id;
744 std_ac_if_desc.iInterface = us[STR_IF_CTRL].id;
745 std_as_out_if0_desc.iInterface = us[STR_AS_OUT_ALT0].id;
746 std_as_out_if1_desc.iInterface = us[STR_AS_OUT_ALT1].id;
747 std_as_in_if0_desc.iInterface = us[STR_AS_IN_ALT0].id;
748 std_as_in_if1_desc.iInterface = us[STR_AS_IN_ALT1].id;
749
750 INIT_LIST_HEAD(&uac3->hc_desc_list);
751
752 /* Initialize the configurable parameters */
753 cluster_desc = build_cluster_descriptor(uac3_opts, 0); /* capture */
754 if (cluster_desc) {
755 hc_desc = kzalloc(sizeof *hc_desc, GFP_KERNEL);
756 hc_desc->hc_header = cluster_desc;
757 list_add(&hc_desc->list, &uac3->hc_desc_list);
758 cluster_desc->wDescriptorID = cpu_to_le16(hc_desc_id);
759 usb_out_it_desc.wClusterDescrID = cluster_desc->wDescriptorID;
760 as_out_hdr_desc.wClusterDescrID = cluster_desc->wDescriptorID;
761 hc_desc_id++;
762 }
763
764 cluster_desc = build_cluster_descriptor(uac3_opts, 1); /* playback */
765 if (cluster_desc) {
> 766 hc_desc = kzalloc(sizeof *hc_desc, GFP_KERNEL);
767 hc_desc->hc_header = cluster_desc;
768 list_add(&hc_desc->list, &uac3->hc_desc_list);
769 cluster_desc->wDescriptorID = cpu_to_le16(hc_desc_id);
770 io_in_it_desc.wClusterDescrID = cluster_desc->wDescriptorID;
771 as_in_hdr_desc.wClusterDescrID = cluster_desc->wDescriptorID;
772 }
773
774 as_out_hdr_desc.bSubslotSize = uac3_opts->c_ssize;
775 as_out_hdr_desc.bBitResolution = uac3_opts->c_ssize * 8;
776 as_in_hdr_desc.bSubslotSize = uac3_opts->p_ssize;
777 as_in_hdr_desc.bBitResolution = uac3_opts->p_ssize * 8;
778
779 /* alloc and configure Feature Unit descriptors */
> 780 usb_out_fu_desc = alloc_fu_desc(num_channels(uac3_opts->c_chmask),
781 USB_OUT_FU_ID,
782 USB_OUT_IT_ID);
783 if (!usb_out_fu_desc) {
784 dev_err(dev, "%s: can't allocate OUT FU descriptor on %s\n",
785 fn->name, gadget->name);
786 ret = -ENOMEM;
787 goto err_free_hc_desc;
788 }
789
790 usb_in_fu_desc = alloc_fu_desc(num_channels(uac3_opts->p_chmask),
791 USB_IN_FU_ID,
792 IO_IN_IT_ID);
793 if (!usb_in_fu_desc) {
794 dev_err(dev, "%s: can't allocate IN FU descriptor on %s\n",
795 fn->name, gadget->name);
796 ret = -ENOMEM;
797 goto err_free_out_fu_desc;
798 }
799
800 /* update AC desc size with allocated FUs */
801 ac_hdr_desc.wTotalLength = cpu_to_le16(
802 sizeof in_clk_src_desc + sizeof out_clk_src_desc
803 + sizeof usb_out_it_desc + sizeof io_in_it_desc
804 + sizeof usb_in_ot_desc + sizeof io_out_ot_desc
805 + sizeof usb_in_pd_desc + sizeof usb_out_pd_desc
806 + usb_out_fu_desc->bLength + usb_in_fu_desc->bLength);
807
808 ret = usb_interface_id(cfg, fn);
809 if (ret < 0) {
810 dev_err(dev, "%s: can't allocate AC interface id on %s\n",
811 fn->name, gadget->name);
812 goto err_free_in_fu_desc;
813 }
814 std_ac_if_desc.bInterfaceNumber = ret;
815 uac3->ac_intf = ret;
816 uac3->ac_alt = 0;
817
818 ret = usb_interface_id(cfg, fn);
819 if (ret < 0) {
820 dev_err(dev, "%s: can't allocate AS OUT interface id on %s\n",
821 fn->name, gadget->name);
822 goto err_free_in_fu_desc;
823 }
824 std_as_out_if0_desc.bInterfaceNumber = ret;
825 std_as_out_if1_desc.bInterfaceNumber = ret;
826 uac3->as_out_intf = ret;
827 uac3->as_out_alt = 0;
828
829 ret = usb_interface_id(cfg, fn);
830 if (ret < 0) {
831 dev_err(dev, "%s: can't allocate AS IN interface id on %s\n",
832 fn->name, gadget->name);
833 goto err_free_in_fu_desc;
834 }
835 std_as_in_if0_desc.bInterfaceNumber = ret;
836 std_as_in_if1_desc.bInterfaceNumber = ret;
837 uac3->as_in_intf = ret;
838 uac3->as_in_alt = 0;
839
840 /* Calculate wMaxPacketSize according to audio bandwidth */
841 set_ep_max_packet_size(uac3_opts, &fs_epin_desc, 1000, true);
842 set_ep_max_packet_size(uac3_opts, &fs_epout_desc, 1000, false);
843 set_ep_max_packet_size(uac3_opts, &hs_epin_desc, 8000, true);
844 set_ep_max_packet_size(uac3_opts, &hs_epout_desc, 8000, false);
845
846 audio->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
847 if (!audio->out_ep) {
848 dev_err(dev, "%s: can't autoconfigure on %s\n",
849 fn->name, gadget->name);
850 ret = -ENODEV;
851 goto err_free_in_fu_desc;
852 }
853
854 audio->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
855 if (!audio->in_ep) {
856 dev_err(dev, "%s: can't autoconfigure on %s\n",
857 fn->name, gadget->name);
858 ret = -ENODEV;
859 goto err_free_in_fu_desc;
860 }
861
862 audio->in_ep_maxpsize = max_t(u16,
863 le16_to_cpu(fs_epin_desc.wMaxPacketSize),
864 le16_to_cpu(hs_epin_desc.wMaxPacketSize));
865 audio->out_ep_maxpsize = max_t(u16,
866 le16_to_cpu(fs_epout_desc.wMaxPacketSize),
867 le16_to_cpu(hs_epout_desc.wMaxPacketSize));
868
869 hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
870 hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
871
872 /* Copy descriptors */
873 fn->fs_descriptors = uac3_copy_descriptors(USB_SPEED_FULL);
874 if (!fn->fs_descriptors)
875 goto err_free_in_fu_desc;
876 if (gadget_is_dualspeed(gadget)) {
877 fn->hs_descriptors = uac3_copy_descriptors(USB_SPEED_HIGH);
878 if (!fn->hs_descriptors)
879 goto err_free_in_fu_desc;
880 }
881
882 audio->gadget = gadget;
883
884 audio->params.p_chmask = uac3_opts->p_chmask;
885 audio->params.p_srate = uac3_opts->p_srate;
886 audio->params.p_ssize = uac3_opts->p_ssize;
887 audio->params.c_chmask = uac3_opts->c_chmask;
888 audio->params.c_srate = uac3_opts->c_srate;
889 audio->params.c_ssize = uac3_opts->c_ssize;
890 audio->params.req_number = uac3_opts->req_number;
891 ret = g_audio_setup(audio, "UAC3 PCM", "UAC3_Gadget");
892 if (ret)
893 goto err_free_descs;
894 return 0;
895
896 err_free_descs:
897 usb_free_all_descriptors(fn);
898 audio->gadget = NULL;
899 err_free_in_fu_desc:
900 kfree(usb_in_fu_desc);
901 usb_in_fu_desc = NULL;
902 err_free_out_fu_desc:
903 kfree(usb_out_fu_desc);
904 usb_out_fu_desc = NULL;
905 err_free_hc_desc:
906 list_for_each_entry(hc_desc, &uac3->hc_desc_list, list)
907 kfree(hc_desc);
908
909 return ret;
910 }
911
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
next prev parent reply other threads:[~2017-11-07 13:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 1:52 [PATCH 0/1] USB Audio Device Class 3.0 Gadget support Ruslan Bilovol
2017-11-07 1:52 ` [PATCH 1/1] usb: gadget: add USB Audio Device Class 3.0 gadget support Ruslan Bilovol
2017-11-07 11:34 ` kbuild test robot
2017-11-07 13:20 ` kbuild test robot [this message]
2017-11-07 2:04 ` [PATCH 0/1] USB Audio Device Class 3.0 Gadget support Ruslan Bilovol
2017-12-04 11:36 ` Felipe Balbi
2017-12-07 11:18 ` Ruslan Bilovol
2018-06-13 0:28 ` Ruslan Bilovol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201711072109.bPwho9kY%fengguang.wu@intel.com \
--to=lkp@intel.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kbuild-all@01.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ruslan.bilovol@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).