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,