From patchwork Wed May 27 09:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gromm X-Patchwork-Id: 214998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 026EBC433E3 for ; Wed, 27 May 2020 09:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D656F20787 for ; Wed, 27 May 2020 09:06:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="D9SRndsN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388503AbgE0JGf (ORCPT ); Wed, 27 May 2020 05:06:35 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:1485 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388330AbgE0JGe (ORCPT ); Wed, 27 May 2020 05:06:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1590570394; x=1622106394; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UQhCFs5M0TuJKwieIYLpaCSxjEN4IzcEDkm4f4sP1qI=; b=D9SRndsNx9mJcW1XV4p6qGzA6iBUD8T3EVysUJuYM5JizX8guS6IxLFP lM9dwty4rdqv8g7Pr9lZMmCBYzzCP3HnJrwHkXkOAMZsUEzA40gTCb1Po HWgXKxooCQ9i45ccYOVfPe2apmTAbyBkHTd3RodfItxDuXDJfbXnxlvJO Ogy3pgHrw1TmSH7xoQ+UGaigGhNSmfq31o9xpV569e+zZAmoJ4fEP2/Tw isIzlmEOXBV5gkuhIFuFymKOIBkFcgDaNKv25rSlaaXXKrWMQArOVyky1 pu+teI4F2I86tDYEcA3eGC0Uae0QGaqmAdIarR7Oi0ZSzXql+ld91VzkM w==; IronPort-SDR: rykcD1jpoRaddSsGpC1Py2gQs/RJUJQtnj6j9oo2dORH56zZc6MZOSzKdC7WzAD2H7dFy8KXpV chr+jkUFoB1Bw88Dl6dB4j8OatUPiCsGuagR2/yP9kd4T59at9GRnvAb8VYs/4SQAO/5AHDEDv FPuiJQybHtSqJ947TztcuBy3MQkb+Wyp7BmsIdULY8jGRVfuE/Vp4zuGbcm2Z79/ZT5Gi2yFbL ECx/Xdmnv/JEUIsPCSjjHhk3Wmyb70L1sAKsKnsL4XIYxjfBsRQ6NMVDMo9+oXKfly/hFnLkCY Jwc= X-IronPort-AV: E=Sophos;i="5.73,440,1583218800"; d="scan'208";a="77204586" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 May 2020 02:06:33 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 May 2020 02:06:32 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 27 May 2020 02:06:31 -0700 From: Christian Gromm To: CC: , , Christian Gromm Subject: [PATCH 01/10] staging: most: usb: change order of function parameters Date: Wed, 27 May 2020 11:06:18 +0200 Message-ID: <1590570387-27069-2-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> References: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch swaps the arguments of function get_stream_frame_size to have the struct device as first parameter. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/usb/usb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index 56b75e4..0e1264d 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -183,10 +183,11 @@ static inline int start_sync_ep(struct usb_device *usb_dev, u16 ep) /** * get_stream_frame_size - calculate frame size of current configuration + * @dev: device structure * @cfg: channel configuration */ -static unsigned int get_stream_frame_size(struct most_channel_config *cfg, - struct device *dev) +static unsigned int get_stream_frame_size(struct device *dev, + struct most_channel_config *cfg) { unsigned int frame_size = 0; unsigned int sub_size = cfg->subbuffer_size; @@ -270,7 +271,7 @@ static int hdm_poison_channel(struct most_interface *iface, int channel) static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo) { struct most_channel_config *conf = &mdev->conf[channel]; - unsigned int frame_size = get_stream_frame_size(conf, &mdev->dev); + unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); unsigned int j, num_frames; if (!frame_size) @@ -304,7 +305,7 @@ static int hdm_remove_padding(struct most_dev *mdev, int channel, struct mbo *mbo) { struct most_channel_config *const conf = &mdev->conf[channel]; - unsigned int frame_size = get_stream_frame_size(conf, &mdev->dev); + unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); unsigned int j, num_frames; if (!frame_size) @@ -600,7 +601,7 @@ static int hdm_configure_channel(struct most_interface *iface, int channel, mdev->padding_active[channel] = true; - frame_size = get_stream_frame_size(conf, &mdev->dev); + frame_size = get_stream_frame_size(&mdev->dev, conf); if (frame_size == 0 || frame_size > USB_MTU) { dev_warn(dev, "Misconfig: frame size wrong\n"); return -EINVAL; From patchwork Wed May 27 09:06:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gromm X-Patchwork-Id: 214997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BC45C433E4 for ; Wed, 27 May 2020 09:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C8A420787 for ; Wed, 27 May 2020 09:06:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="OL7IDv48" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388501AbgE0JGg (ORCPT ); Wed, 27 May 2020 05:06:36 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:2344 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388374AbgE0JGf (ORCPT ); Wed, 27 May 2020 05:06:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1590570395; x=1622106395; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=9tGRvt0IuvI8/C5nNy+dhJmMZwVdWn7eK6/c8LNTvps=; b=OL7IDv48FYQtpaZjVwheX4/1auFrkcJwIJJHoLHYygP15OhyY8Z1ubqL T3e/Ar9ivMMUwQTg8G8379Nm85S46H3ZVr62g4mCQsbm5KKygTEqBGl5H e2Tqs2Lqmy/ZqLstAdYbKCF6CuVdA+TC8P2MAuE7AgGrH+PFvfgNYUEwI 2y5BhK2LZcCS9scIg9rvE2SA+bHGQGyRd0XAvUefRbXHeZCI12pnBML8H C1izFPdUzUWx41E8hHpYIy8tXQivUPpyqpI4Mex9zyIBWC6rIgz4Z3gED BAutYkcbGYbV4WlejQXm49njC31hXJDvN0z8o0T9T11ZSCrcNp5Sla40/ g==; IronPort-SDR: IwA80yyJj6oK3zqahw43qnQiPKDiVRgKN76n9pkyvGpjPKCagXFlzvXq2DuOmLk7jp7da1h5UI 9DU//eRFmrWl5LWGl/9DRzLOKKFy3OxEHVvxscX1nh07/JGTvlL3ZlwFfO2ifIm3PrrN7m6ZXG NJjRZfFv48r3K0lIfHC0B4zueFwgivdAtCsixz+5J2+idna6lT7Vh46ATlrO4BkHjLiPx6Nimf ELMwAHivaX9C3rpWe6CoDr1hqjbeCpUF61C+OuH4JR0/8JLsKyXIqVu/GuzXgQ186YXLhhoyMb iVI= X-IronPort-AV: E=Sophos;i="5.73,440,1583218800"; d="scan'208";a="74590209" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 May 2020 02:06:35 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 May 2020 02:06:28 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 27 May 2020 02:06:33 -0700 From: Christian Gromm To: CC: , , Christian Gromm Subject: [PATCH 03/10] staging: most: usb: change return value of function drci_rd_reg Date: Wed, 27 May 2020 11:06:20 +0200 Message-ID: <1590570387-27069-4-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> References: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch makes function drci_rd_reg return 0 in case of success and a negative number else. As no caller is evaluating the number of bytes transferred by function usb_control_msg this information is being omitted. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/usb/usb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index fd0d885..64005b6 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -153,7 +153,9 @@ static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf) *buf = le16_to_cpu(*dma_buf); kfree(dma_buf); - return retval; + if (retval < 0) + return retval; + return 0; } /** @@ -686,22 +688,22 @@ static void wq_netinfo(struct work_struct *wq_obj) u16 hi, mi, lo, link; u8 hw_addr[6]; - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) { + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi)) { dev_err(dev, "Vendor request 'hw_addr_hi' failed\n"); return; } - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) { + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi)) { dev_err(dev, "Vendor request 'hw_addr_mid' failed\n"); return; } - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) { + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo)) { dev_err(dev, "Vendor request 'hw_addr_low' failed\n"); return; } - if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) { + if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link)) { dev_err(dev, "Vendor request 'link status' failed\n"); return; } From patchwork Wed May 27 09:06:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gromm X-Patchwork-Id: 214996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6AA4C433E0 for ; Wed, 27 May 2020 09:06:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98F0B20787 for ; Wed, 27 May 2020 09:06:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="MzsCPVTA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388507AbgE0JGi (ORCPT ); Wed, 27 May 2020 05:06:38 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:2344 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388359AbgE0JGi (ORCPT ); Wed, 27 May 2020 05:06:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1590570397; x=1622106397; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qHSHd1bgmgLlhngnky1syAKjrwWciKU5ySfx008erzA=; b=MzsCPVTAWpUNKbYiHQJSdAUskJdE0hVffvGQsVosOMFF5aVnfmO19vN5 Oo75NahKF+Fh2NMF+r1i40f73DfSFqzq7VrxClLoHsYp41yCN29FHU0fG cSj3u9pSgwtuFm9Q2N3QSh4rFL/ekaAX1BLCpAYbFkVcvrqEuPM4Ek10h yU8YZMSIEZ26K7RUrThizmcKXP18Y/ZmNXE7rmLhxHjyyc1Yni299kgEh SAl3PYsMcgbg8fzt4bhqLS6dUwEg0uehB57yDZF6Yx6HLXOLyiDNrXg8q hjONH9jO5eLMll4VQ7mLl0utTjE8o6Ddkt5URUejyIPasgnaaxWIzwgEA g==; IronPort-SDR: yVXOOwX0QQWb8rRcKDqq81HXC+fOA7If8M2vGB4me/1fCAk2fcKBM7xqdYG9bf/f6l0LCjmLDU IpYYUE73swjsfxUQy6bblSRJNlUm26tMc3Zm7xoSPgnccRmPWk4aCwpGyjWDmEq7gXXWddqiNO HBaerpZLhagYDZNM+q2fsvs4T2DDYUfJcy+26JuqI2KlaNERxvpZClD9tqBBWfACSLbTPKpfcr RURCZDDXoSDUUMNk5teHcBmBEom7nAXb2jm2paXo0YM78qGDhpuxL/AexaDA0ZthNVuLA5NfqF yqk= X-IronPort-AV: E=Sophos;i="5.73,440,1583218800"; d="scan'208";a="74590217" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 May 2020 02:06:37 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 May 2020 02:06:30 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 27 May 2020 02:06:36 -0700 From: Christian Gromm To: CC: , , Christian Gromm Subject: [PATCH 05/10] staging: most: usb: move allocation of URB out of critical section Date: Wed, 27 May 2020 11:06:22 +0200 Message-ID: <1590570387-27069-6-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> References: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch puts the call to usb_alloc_urb() before the critical section starts that is protected with the io_mutex lock. This is to make the section as short as possible and to use the regular GFP_KERNEL flag. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/usb/usb.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index a605e0f..534825f 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -467,18 +467,16 @@ static int hdm_enqueue(struct most_interface *iface, int channel, if (iface->num_channels <= channel || channel < 0) return -ECHRNG; + urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_KERNEL); + if (!urb) + return -ENOMEM; + conf = &mdev->conf[channel]; mutex_lock(&mdev->io_mutex); if (!mdev->usb_device) { retval = -ENODEV; - goto unlock_io_mutex; - } - - urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC); - if (!urb) { - retval = -ENOMEM; - goto unlock_io_mutex; + goto err_free_urb; } if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] && From patchwork Wed May 27 09:06:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gromm X-Patchwork-Id: 214995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C558C433E2 for ; Wed, 27 May 2020 09:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D40C20787 for ; Wed, 27 May 2020 09:06:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="yopHUqx4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388421AbgE0JGl (ORCPT ); Wed, 27 May 2020 05:06:41 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:2344 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388508AbgE0JGk (ORCPT ); Wed, 27 May 2020 05:06:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1590570400; x=1622106400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Ubu5DjfeMwuoDfB7rELb/kow3WmwDtRNqlTYJOZEPRo=; b=yopHUqx45jlkPzQp4aCC/9CM5JITyXoa5/xukd7uTGIUX1X2NHUSltXk XjgkBUczyv3Yx758clSnD27AbN779+A8jxk5R9+KHK8NlpdIcmaiOOPff 5z6Th0tyRnZnB0Ir/P3CPtUqaMcZeVP1E21z1OqPnGx6BNw/FPHzl5vxK Ls+CmMwkrpmPcUtgPbmFQTlY0EsguS3o6SQlsoErEn5A95/ppMQWbxxzs CofKpXwajbn8uNrthtVawpyL8UvDkpiOU8lShdWD1hsbnErs2JXqMgXFq vHg97Ene4/J8ONl9nO5lRpi4l4Kr0TGCh2PzhyuqD1lfAPo2XQWF951w5 g==; IronPort-SDR: 4sKuQhn51/IgvXLOji8+H0LK7IdpJXbTWXQtLD5a4dR6FVsPXy+jcVbgnC2zz4Z0+QPyorwzT/ bs4tSMtDrXYrbvnigLY8fagOIrrjD2QOdXteTWr/zhb7kLXDw8MErCNW1zp39vDUmEq/+0xmVj PMN0EGVZmAIf2z87PuHhYhkw831AAkyD85Q2Ivin32AdcMxfMYFDP1P5FDrTmg8VNc3dFX++Jj 8fnCLYW44zwAteYwTbvORlVeZr7soX0XiTx8YSUNF7HKV6qQ3fcLQ96RyqrruJ9gHMszZACabp fYA= X-IronPort-AV: E=Sophos;i="5.73,440,1583218800"; d="scan'208";a="74590227" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 May 2020 02:06:40 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 May 2020 02:06:33 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 27 May 2020 02:06:38 -0700 From: Christian Gromm To: CC: , , Christian Gromm Subject: [PATCH 07/10] staging: most: usb: replace code to calculate array index Date: Wed, 27 May 2020 11:06:24 +0200 Message-ID: <1590570387-27069-8-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> References: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch removes the expression that makes use of a priori knowledge about channel numbers to calculate an array index. The expression 'peer = 1 - channel' utilizes the fact that an USB interface that operates on the asynchronous data of the Network only has two endpoints. Hence, channel being 0 or 1. The replacement is more simple and less confusing when reading the code. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/usb/usb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index 03318de..468aabf 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -729,6 +729,8 @@ static void wq_clear_halt(struct work_struct *wq_obj) struct most_dev *mdev = clear_work->mdev; unsigned int channel = clear_work->channel; int pipe = clear_work->pipe; + int snd_pipe; + int peer; mutex_lock(&mdev->io_mutex); most_stop_enqueue(&mdev->iface, channel); @@ -746,9 +748,12 @@ static void wq_clear_halt(struct work_struct *wq_obj) */ if (mdev->conf[channel].data_type == MOST_CH_ASYNC && mdev->conf[channel].direction == MOST_CH_RX) { - int peer = 1 - channel; - int snd_pipe = usb_sndbulkpipe(mdev->usb_device, - mdev->ep_address[peer]); + if (channel == 0) + peer = 1; + else + peer = 0; + snd_pipe = usb_sndbulkpipe(mdev->usb_device, + mdev->ep_address[peer]); usb_clear_halt(mdev->usb_device, snd_pipe); } mdev->is_channel_healthy[channel] = true; From patchwork Wed May 27 09:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gromm X-Patchwork-Id: 214994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06664C433DF for ; Wed, 27 May 2020 09:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9C8420787 for ; Wed, 27 May 2020 09:06:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="o7dc6UZH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388514AbgE0JGo (ORCPT ); Wed, 27 May 2020 05:06:44 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:2344 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388513AbgE0JGn (ORCPT ); Wed, 27 May 2020 05:06:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1590570403; x=1622106403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Veetgosw/XgbnoNh0z9adVvVyUO6uS1tR9xrwVrKhTE=; b=o7dc6UZH9UonIbpXJkvp1cREEXWlkP2AalfFb7zp4yYruCX/mueTO9+4 MltqHkcqQ7dI3SaD2ezqKWyF9MK5xw3ZYX2Ms5/jB2CjY3VPSXSgJhv+9 ljxX6RMtpL6pshooxzJ8qS7LYxFA9EB6UUPFxg5LVJtr9hO0kqZaIVJx7 ygERTNeXUSQ+12wgfDH0CCvRE/Rj2NgysSdxGCFzcJAH4Vx+3ps+Osb4f FjDHos1jqVGAa8uBDAK8mypnZv2TolXjd4pgTeDuicCWxDfpOupK1JBSO xdU7QNqkkmWhnach2Vkj22X1JK2vcTxt8KKKhE6c890oBtIUzR4KIMH7+ Q==; IronPort-SDR: xwkJRzbbz4quINAHcRsOYANRojvjjVysM9bzqiJXm7k8Mi6ifRXlnLeRUuZ1bFzoapAF8PO7Mm Njsu5yy5LqztwK4K5Mj9wPCb+DK0DJ43YRHLOHKSYwgxBNymY2i3+nl4drAijguyTktRySDSXJ bE2gjhVbe2RV3vC2GbpxgYpuO62UXdbWKM3IGC9ztiXkHQ5gQhEYUIkCjew1NAIugr426Jc5lR Nn7intZulFqzI9x/jP18T9bbl+PaBj/dP1TvNE9s3Xa5V02XAg3h7GqJu72IaQUpprpt7IK1cU e7w= X-IronPort-AV: E=Sophos;i="5.73,440,1583218800"; d="scan'208";a="74590239" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 27 May 2020 02:06:42 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 27 May 2020 02:06:35 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 27 May 2020 02:06:41 -0700 From: Christian Gromm To: CC: , , Christian Gromm Subject: [PATCH 09/10] staging: most: usb: add missing put_device calls Date: Wed, 27 May 2020 11:06:26 +0200 Message-ID: <1590570387-27069-10-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> References: <1590570387-27069-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch adds the missing put_device() function calls to properly free allocated resources and maintain reference counts. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/usb/usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c index 3575a40..1c4bdb8 100644 --- a/drivers/staging/most/usb/usb.c +++ b/drivers/staging/most/usb/usb.c @@ -919,6 +919,7 @@ static void release_dci(struct device *dev) { struct most_dci_obj *dci = to_dci_obj(dev); + put_device(dev->parent); kfree(dci); } @@ -1123,6 +1124,7 @@ static void hdm_disconnect(struct usb_interface *interface) kfree(mdev->cap); kfree(mdev->conf); kfree(mdev->ep_address); + put_device(&mdev->dci->dev); put_device(&mdev->dev); }