From patchwork Thu Nov 29 22:29:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10705453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61DFE13AD for ; Thu, 29 Nov 2018 22:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481B92FA63 for ; Thu, 29 Nov 2018 22:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 393852FAFF; Thu, 29 Nov 2018 22:29:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 168012FA63 for ; Thu, 29 Nov 2018 22:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbeK3Jgh (ORCPT ); Fri, 30 Nov 2018 04:36:37 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37228 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbeK3Jgh (ORCPT ); Fri, 30 Nov 2018 04:36:37 -0500 Received: by mail-wm1-f67.google.com with SMTP id g67so3828712wmd.2 for ; Thu, 29 Nov 2018 14:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=2jaO7J7OVdfqoPqWDRK0vWXXJl9TJ6EhStRTTW6R35Y=; b=P3zDXHylUnfPlBK5KQQMSUlR3HiofxlNNrnw/fEL1IGok5e5y7/A9TpQvlRxNcGzSc x4WGs4URYQBd1JU12o3Fgo0jYjDY3qUg2URQuo6xPiIa9sVLr+IPV9nnEf09cNMi5Lxa Z6pPimIZvo45hIvb4xfPDTlGqwhchejNraPD1clypkwtyif+iQV2l++mLebSHpUrfwAp 4aXFdfksQY11ipvZeZyIiyccTHb6Av6zCO26wKQKHBje4Jk7TEv4xKj5+3baYReUYepq TIZmJz39m7njdPTJBvj/TZMJsbu9woc3fGcjVi67mQmOQ244yIftTCVDbXsiX3KeSVQc BYqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=2jaO7J7OVdfqoPqWDRK0vWXXJl9TJ6EhStRTTW6R35Y=; b=T53gVCYUxOvY/Dgn+IfcTBBReByLRRNkEU7IfRTsW1fUUajudITFseWNrpVotZGRFr Xy4CV3HOKEjDRbq1L/dhYoCtFWbQiwobf1buw/l258bu2kezwDbrKypZKGbeE4eGLK6D 8TYyDMQBtGTx33sLZ68fMNT6jS+fLLbBmRyIpCfCe3POB9uNb2ExsAb7WIrYvJVTbn1E YKknVFBeKNAauizgS7ZCEQ0NI+T4XDs1TtoboyoBYIzrQPlzr+bswwXa7DE4uhcdqVRi zuU9mywhufiFJ9ZsNkkCOesCdupCiwQ+H3c5SjbaG8pQS54yncJ5J7rE7l88rMJu3XIs t/Pg== X-Gm-Message-State: AA+aEWb5or0SN2Vz86Gh8D6fZqzehs/Ki8UlkpkINP/MGIjm9NZnk8J4 GbgubRqBcDYL65MQRoIIcyuxi1ep X-Google-Smtp-Source: AFSGD/Vw+JROxJl08mkXFeP8QId7tE3Wc6tdiZGxy9a9aLBd36o1hp+4JWV5DjN1cuxdNO0bqmIK7A== X-Received: by 2002:a1c:1b86:: with SMTP id b128mr3187493wmb.30.1543530573809; Thu, 29 Nov 2018 14:29:33 -0800 (PST) Received: from [192.168.43.227] (92.40.249.58.threembb.co.uk. [92.40.249.58]) by smtp.gmail.com with ESMTPSA id j199sm7529434wmf.13.2018.11.29.14.29.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:29:33 -0800 (PST) From: Malcolm Priestley Subject: [PATCH 1/4] media: lmedm04: Add missing usb_free_urb to free, interrupt urb To: Linux Media Mailing List Message-ID: Date: Thu, 29 Nov 2018 22:29:31 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The interrupt urb is killed but never freed add the function Cc: stable@vger.kernel.org Signed-off-by: Malcolm Priestley --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index f109c04f05ae..8b405e131439 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -1264,6 +1264,7 @@ static void *lme2510_exit_int(struct dvb_usb_device *d) if (st->lme_urb != NULL) { usb_kill_urb(st->lme_urb); + usb_free_urb(st->lme_urb); usb_free_coherent(d->udev, 128, st->buffer, st->lme_urb->transfer_dma); info("Interrupt Service Stopped"); From patchwork Thu Nov 29 22:29:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10705455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F8D014BD for ; Thu, 29 Nov 2018 22:29:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C1A22FA63 for ; Thu, 29 Nov 2018 22:29:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DAEB2FAE7; Thu, 29 Nov 2018 22:29:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 262322FA63 for ; Thu, 29 Nov 2018 22:29:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbeK3Jg5 (ORCPT ); Fri, 30 Nov 2018 04:36:57 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41655 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbeK3Jg4 (ORCPT ); Fri, 30 Nov 2018 04:36:56 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so3450416wrs.8 for ; Thu, 29 Nov 2018 14:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=XNUfp54daPTl8yJwzS5s9jDSS8tzLboUCMKg0fwbiKQ=; b=jpXlDfdfkn6XQcY8doHOQEFs9KkJnUp8HHqOXpF2Vl7OlbiUCY/z7ErkFLj+5FdS6E uaumUJvXuv+lyQz7dU6EH0bBNuO7l9QfdtBBqWBk1SF3paapfGiGveAxiYH+g43D/zcJ gkQDherHNdvXxd/yYb1gq4lSXPFaAxJvLhXjJln6cYfWoCiSHLLbykh0gKAxqq0GFv6p 54bwOZRzbF+RsT2ouUNl8WoQI6Mu5MBlPuTd8QRh1dsRsyC6aMbyPmGU2ebRl4IH25FB xujhAK1Tn3/+LcZTXmlr4lYy+btccHM2VwA9hdhEjYl9MfL99cAyBd5I1VL2VH1OgaP8 TTXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=XNUfp54daPTl8yJwzS5s9jDSS8tzLboUCMKg0fwbiKQ=; b=sQ+hRLM98uvcDzpe9VgrWYwxzNJcanoHJoxG+nxSUZaJsZuiksx+7yfV5n4EaNpLK3 FJS0LdZ4Rt1Lqg6speL3Y5I47SuDIzf2D4o/0wv18jSrZlUwnFGkODskjg6rLjysAvlD sz1cEeZRnfcJqYHqd2QwLF83P1pgvYQmY+UMD+Xec/NCZw3PHCbpwKQxyc9rumTmVD/x J2uYETnt0a5QwBo9sDW9CQUT4bZ12L/EVolEcvgaxq8zXU4XdERW6v4MtOZJXhxaJeAP SsHmABXFMp/hQad/ySZqW4tyEz9VKLqzq4waan3g+9ntMWo+C3HC8gjY6o3WKnFqKCDR ViBQ== X-Gm-Message-State: AA+aEWYpBTcEP6FdVl5SKkBDQKsiXILdTsDP0vPFJBiEHDLvDrP52AS4 U1ouzKbA4oNK7+limV1BRgr741WA X-Google-Smtp-Source: AFSGD/Xfwg26zHCd0mUn3rJri5tU8lOvzaCdPwM0WgMxHDkzbzAnULfQxS24kVEEW4/QJwODJgYFgg== X-Received: by 2002:adf:f101:: with SMTP id r1mr2949226wro.32.1543530593074; Thu, 29 Nov 2018 14:29:53 -0800 (PST) Received: from [192.168.43.227] (92.40.249.58.threembb.co.uk. [92.40.249.58]) by smtp.gmail.com with ESMTPSA id s202sm4277694wme.40.2018.11.29.14.29.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:29:52 -0800 (PST) From: Malcolm Priestley Subject: [PATCH 2/4] media: lmedm04: Move usb buffer to lme2510_state. To: Linux Media Mailing List Message-ID: <1f6430e7-4b41-1516-a3f7-01be30fdcd3f@gmail.com> Date: Thu, 29 Nov 2018 22:29:51 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP lme2510_state exists for the entire duration of driver. Move usb_buffer to lme2510_state removing the need for lme2510_exit_int for removing the buffer. Signed-off-by: Malcolm Priestley --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 35 +++----------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 8b405e131439..8fb53b83c914 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -136,7 +136,7 @@ struct lme2510_state { u8 pid_off; void *buffer; struct urb *lme_urb; - void *usb_buffer; + u8 usb_buffer[64]; /* Frontend original calls */ int (*fe_read_status)(struct dvb_frontend *, enum fe_status *); int (*fe_read_signal_strength)(struct dvb_frontend *, u16 *); @@ -169,18 +169,9 @@ static int lme2510_usb_talk(struct dvb_usb_device *d, u8 *wbuf, int wlen, u8 *rbuf, int rlen) { struct lme2510_state *st = d->priv; - u8 *buff; + u8 *buff = st->usb_buffer; int ret = 0; - if (st->usb_buffer == NULL) { - st->usb_buffer = kmalloc(64, GFP_KERNEL); - if (st->usb_buffer == NULL) { - info("MEM Error no memory"); - return -ENOMEM; - } - } - buff = st->usb_buffer; - ret = mutex_lock_interruptible(&d->usb_mutex); if (ret < 0) @@ -1245,23 +1236,15 @@ static int lme2510_get_rc_config(struct dvb_usb_device *d, return 0; } -static void *lme2510_exit_int(struct dvb_usb_device *d) +static void lme2510_exit(struct dvb_usb_device *d) { struct lme2510_state *st = d->priv; struct dvb_usb_adapter *adap = &d->adapter[0]; - void *buffer = NULL; if (adap != NULL) { lme2510_kill_urb(&adap->stream); } - if (st->usb_buffer != NULL) { - st->i2c_talk_onoff = 1; - st->signal_level = 0; - st->signal_sn = 0; - buffer = st->usb_buffer; - } - if (st->lme_urb != NULL) { usb_kill_urb(st->lme_urb); usb_free_urb(st->lme_urb); @@ -1269,18 +1252,6 @@ static void *lme2510_exit_int(struct dvb_usb_device *d) st->lme_urb->transfer_dma); info("Interrupt Service Stopped"); } - - return buffer; -} - -static void lme2510_exit(struct dvb_usb_device *d) -{ - void *usb_buffer; - - if (d != NULL) { - usb_buffer = lme2510_exit_int(d); - kfree(usb_buffer); - } } static struct dvb_usb_device_properties lme2510_props = { From patchwork Thu Nov 29 22:30:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10705457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A6F51057 for ; Thu, 29 Nov 2018 22:30:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BDD72FB48 for ; Thu, 29 Nov 2018 22:30:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 608732FB57; Thu, 29 Nov 2018 22:30:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E51632FB53 for ; Thu, 29 Nov 2018 22:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbeK3JhV (ORCPT ); Fri, 30 Nov 2018 04:37:21 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37410 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbeK3JhU (ORCPT ); Fri, 30 Nov 2018 04:37:20 -0500 Received: by mail-wr1-f67.google.com with SMTP id j10so3465479wru.4 for ; Thu, 29 Nov 2018 14:30:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=jhxu5l9PQoc/IxsPNHRolK020u4/JxBHLQXcs88Bgv0=; b=oyREmhn82V6qqugBtGIXH5CZP5K/cMUSYS49pJMchPh5gPtyP+PGaeG5eafOVRdIaT T1EfmCpaj1AWQOANCAA6/aKSEB/rQJQXt/XkWAx4kxxA0sOAIjqXHvh0FYEK36dullLa M6k4vU3A6zFLd4+6gLOXvvhVqLcXAZJmgA+Q9m5mhlILOuHFh815FNH/L9J4K8hHomsA w+Rvr1bYDH53L5oXSFLHemqV+W4OWMsL+KMVWcjf3mLfj+IPzQuHJnwsrGC4hf/HcFne Ti4kTCgbR5v6pVYwv5Am2dH8+p300wUhsloaCZe6fkSkSr2eXddIUuVu11fsxzM3iXhh vWdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=jhxu5l9PQoc/IxsPNHRolK020u4/JxBHLQXcs88Bgv0=; b=CCZGMnMdkdZM3BufZpkRp8OmdDxnh0hEKU29+uv09z8E+0eZ7QWLz+1H8EZonGe6ey Sj/ZFsNBtXRCDk9qxwDRdbqeMrDTmwvc/2wTNtatFF6b10EA6Hd8xcjvjWHw62oWWfd7 F3pF1SJmOZrWyIidNgJqbU9WNBZgKTpwe4kKgWXcsuISLSwVD88TPGWydbjdM7Ah7l4F k8ia8g+unPxMlV+iQHKPB525OEe1fE3p5DRvzkyaNQcwWkLqz0RUxxgWxJB2qzrxEqbo N83kUi8t48iEqMuS0fYroT63biHzSYIzBo4rjHRWnywh7UpTwzeI8hiU7DbUtd78iAWK pCXQ== X-Gm-Message-State: AA+aEWaakCdBf4ojOC7H0mUZigC3OBXiWxvIS0hNbeakEThBJYjYHoWL 14M13fqXRUD5cXeJ60OE68RFdaVr X-Google-Smtp-Source: AFSGD/UWAU+0Ic02fIvcbwbXA0tr1ZwVbsx/L+1ekTyP8kNk4NdI40N56/74hCM0JQr8Hl5OiW2zmw== X-Received: by 2002:adf:ffca:: with SMTP id x10mr3046147wrs.289.1543530616946; Thu, 29 Nov 2018 14:30:16 -0800 (PST) Received: from [192.168.43.227] (92.40.249.58.threembb.co.uk. [92.40.249.58]) by smtp.gmail.com with ESMTPSA id h131sm5525852wmd.17.2018.11.29.14.30.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:30:16 -0800 (PST) From: Malcolm Priestley Subject: [PATCH 3/4] media: lmedm04: Move interrupt buffer to priv buffer. To: Linux Media Mailing List Message-ID: Date: Thu, 29 Nov 2018 22:30:15 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Interrupt is always present throught life time of there is no dma element move this buffer to private area of driver. Signed-off-by: Malcolm Priestley --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 8fb53b83c914..7b1aaed259db 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -134,7 +134,7 @@ struct lme2510_state { u8 stream_on; u8 pid_size; u8 pid_off; - void *buffer; + u8 int_buffer[128]; struct urb *lme_urb; u8 usb_buffer[64]; /* Frontend original calls */ @@ -408,20 +408,14 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap) if (lme_int->lme_urb == NULL) return -ENOMEM; - lme_int->buffer = usb_alloc_coherent(d->udev, 128, GFP_ATOMIC, - &lme_int->lme_urb->transfer_dma); - - if (lme_int->buffer == NULL) - return -ENOMEM; - usb_fill_int_urb(lme_int->lme_urb, - d->udev, - usb_rcvintpipe(d->udev, 0xa), - lme_int->buffer, - 128, - lme2510_int_response, - adap, - 8); + d->udev, + usb_rcvintpipe(d->udev, 0xa), + lme_int->int_buffer, + sizeof(lme_int->int_buffer), + lme2510_int_response, + adap, + 8); /* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */ ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe); @@ -1245,11 +1239,9 @@ static void lme2510_exit(struct dvb_usb_device *d) lme2510_kill_urb(&adap->stream); } - if (st->lme_urb != NULL) { + if (st->lme_urb) { usb_kill_urb(st->lme_urb); usb_free_urb(st->lme_urb); - usb_free_coherent(d->udev, 128, st->buffer, - st->lme_urb->transfer_dma); info("Interrupt Service Stopped"); } } From patchwork Thu Nov 29 22:30:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10705459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1373013AD for ; Thu, 29 Nov 2018 22:30:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0520D2FB59 for ; Thu, 29 Nov 2018 22:30:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDD252FB63; Thu, 29 Nov 2018 22:30:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C9B2FB59 for ; Thu, 29 Nov 2018 22:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbeK3Jhb (ORCPT ); Fri, 30 Nov 2018 04:37:31 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39132 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbeK3Jhb (ORCPT ); Fri, 30 Nov 2018 04:37:31 -0500 Received: by mail-wr1-f68.google.com with SMTP id t27so3470629wra.6 for ; Thu, 29 Nov 2018 14:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=gPwRh4y1MJkNUP9sZfXowbnQMs9tE446sGEOOhydZa4=; b=gcREx3ImRVVmk+X7qZxg0MNSL0xR5wgONuskxLWkbBEmrL+FXrKhNhb14Zyz9gDbPV UKUNgXW3OiAXHLPnc9nJhWxBPQ5BJVVh7ZK3n5H53dEw7aXBuDJBjP1zy/r9lBSsCu9D 4sHf9OAF65AMAG3JbhTYPoPmDI7LD+Oo4+6h1xcsgG8AIRzTaWxIXAGAMUIVovjAsVq/ JzJ4HY/LA1TAMopPGtBVuUC8/qsvL66HAa8VDkFaJFkTV1WW46MMmd8xMHv+sZy0Vw9B Tt8JTC+dK0XsLq6irTC8PKvf28CrlQAp4G7KBtmugjGiJP2aNYTYQ6jHxoZ7rQ2E0DgN PaEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=gPwRh4y1MJkNUP9sZfXowbnQMs9tE446sGEOOhydZa4=; b=VrQAIL+8VPHWX/rNj/0nEDcgmW23kkHa4WwK72oImitCoQn/X/oBicoQR6szkWarfR wta0S6KWwXzs6eF9Eqskgr27BLLYnUQfxR5pgjZZgloRGKVVaWCo5gy/8tEyeKPTNeep 1wgaD+yyl3MHbEP+B9COclgGa+FZFXSehFVD5wHcELDHsdQ/7z2LLQ5xKL6KLriUW4zK bwrotbmY4XW25H42zW/94NWLihxYY0SQByWir+zTJGN4BVhKd3QaZ/MPhS6hI1AiB/Ln fN0qdGGbLC9th7rOLWFyOOXCA4LccKtrq0k+vp5LB2ZvWU3FqO6/1Wx6cGaYBQZHr2PR mh7w== X-Gm-Message-State: AA+aEWZi4cQawNxhT0p2t2P1NGfNTYdJ24hBoxtbDwAF6Nm4f3dE6jla qvZxSJnpbXy/UODgmIByUnoUsmC9 X-Google-Smtp-Source: AFSGD/VKtmoGXqLGxEnvv0+RPlwsbNldn+2BlpJCMQjhVddKDhxYIWj36lJn0cmwJ7ydawHTlF9NYQ== X-Received: by 2002:a5d:5351:: with SMTP id t17mr2851881wrv.288.1543530627277; Thu, 29 Nov 2018 14:30:27 -0800 (PST) Received: from [192.168.43.227] (92.40.249.58.threembb.co.uk. [92.40.249.58]) by smtp.gmail.com with ESMTPSA id c7sm5121907wre.64.2018.11.29.14.30.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:30:26 -0800 (PST) From: Malcolm Priestley Subject: [PATCH 4/4] media: lmedm04: use dvb_usbv2_generic_rw_locked To: Linux Media Mailing List Message-ID: Date: Thu, 29 Nov 2018 22:30:25 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use dvb-usb-v2 generic usb function for bulk transfers and simplify logic. Signed-off-by: Malcolm Priestley --- drivers/media/usb/dvb-usb-v2/lmedm04.c | 42 ++++++++------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 7b1aaed259db..8ca0cc67541f 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -147,50 +147,30 @@ struct lme2510_state { u8 dvb_usb_lme2510_firmware; }; -static int lme2510_bulk_write(struct usb_device *dev, - u8 *snd, int len, u8 pipe) -{ - int actual_l; - - return usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe), - snd, len, &actual_l, 100); -} - -static int lme2510_bulk_read(struct usb_device *dev, - u8 *rev, int len, u8 pipe) -{ - int actual_l; - - return usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe), - rev, len, &actual_l, 200); -} - static int lme2510_usb_talk(struct dvb_usb_device *d, - u8 *wbuf, int wlen, u8 *rbuf, int rlen) + u8 *wbuf, int wlen, u8 *rbuf, int rlen) { struct lme2510_state *st = d->priv; - u8 *buff = st->usb_buffer; int ret = 0; - ret = mutex_lock_interruptible(&d->usb_mutex); + if (max(wlen, rlen) > sizeof(st->usb_buffer)) + return -EINVAL; + ret = mutex_lock_interruptible(&d->usb_mutex); if (ret < 0) return -EAGAIN; - /* the read/write capped at 64 */ - memcpy(buff, wbuf, (wlen < 64) ? wlen : 64); + memcpy(st->usb_buffer, wbuf, wlen); - ret |= lme2510_bulk_write(d->udev, buff, wlen , 0x01); + ret = dvb_usbv2_generic_rw_locked(d, st->usb_buffer, wlen, + st->usb_buffer, rlen); - ret |= lme2510_bulk_read(d->udev, buff, (rlen < 64) ? - rlen : 64 , 0x01); - - if (rlen > 0) - memcpy(rbuf, buff, rlen); + if (rlen) + memcpy(rbuf, st->usb_buffer, rlen); mutex_unlock(&d->usb_mutex); - return (ret < 0) ? -ENODEV : 0; + return ret; } static int lme2510_stream_restart(struct dvb_usb_device *d) @@ -1252,6 +1232,8 @@ static struct dvb_usb_device_properties lme2510_props = { .bInterfaceNumber = 0, .adapter_nr = adapter_nr, .size_of_priv = sizeof(struct lme2510_state), + .generic_bulk_ctrl_endpoint = 0x01, + .generic_bulk_ctrl_endpoint_response = 0x01, .download_firmware = lme2510_download_firmware,