From patchwork Mon Dec 6 14:37:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12658641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94857C433FE for ; Mon, 6 Dec 2021 14:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344440AbhLFOkj (ORCPT ); Mon, 6 Dec 2021 09:40:39 -0500 Received: from gofer.mess.org ([88.97.38.141]:47105 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244773AbhLFOki (ORCPT ); Mon, 6 Dec 2021 09:40:38 -0500 Received: by gofer.mess.org (Postfix, from userid 1000) id 804C6C63C2; Mon, 6 Dec 2021 14:37:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1638801428; bh=TykkLm2xhObcuB/rvpCHJh5+X02KEjytZ8xm8kqjk4M=; h=From:To:Subject:Date:From; b=n2LYW03VSOymtIzYrwYTokFZO4i3zC4rhrDajNH6kJneY+KWAiJIGcD8LZjd1E8uX yyuZPp0ew97sSDyFxCgbiUB3DjfikAIR6iZlw+IaKhzByNgEJVJdWh3q+gpUasuV1g dyGn9IMi7Wz/7FM/mzQydgsVZ0l67hRALIVc78kNNyS1tjqAYmj3nSVww4mhQlu0BX 27LXsGRU2cD++/D1gopCmL1rBioy75htF5m1au72BK8mO24N3Ym6qMteHNlBl9VBCH i9k7HH9z998rycujuVjRri6NvLot6renIUdNd+fWBCwnOW6gp5DO5faS/hdnwk8x4k SSuASY6Lawumw== From: Sean Young To: linux-media@vger.kernel.org Subject: [PATCH 1/2] media: streamzap: remove unused struct members Date: Mon, 6 Dec 2021 14:37:07 +0000 Message-Id: <3756e0cf7c64858510531867a9c10dbd80c1ee40.1638801410.git.sean@mess.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org These struct members do not serve any purpose. Signed-off-by: Sean Young --- drivers/media/rc/streamzap.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c index 4d3670d2a913..39856af16305 100644 --- a/drivers/media/rc/streamzap.c +++ b/drivers/media/rc/streamzap.c @@ -66,9 +66,6 @@ struct streamzap_ir { struct device *dev; /* usb */ - struct usb_device *usbdev; - struct usb_interface *interface; - struct usb_endpoint_descriptor *endpoint; struct urb *urb_in; /* buffer & dma */ @@ -85,7 +82,6 @@ struct streamzap_ir { /* start time of signal; necessary for gap tracking */ ktime_t signal_last; ktime_t signal_start; - bool timeout_enabled; char phys[64]; }; @@ -240,8 +236,7 @@ static void streamzap_callback(struct urb *urb) .duration = sz->rdev->timeout }; sz->idle = true; - if (sz->timeout_enabled) - sz_push(sz, rawir); + sz_push(sz, rawir); } else { sz_push_full_space(sz, sz->buf_in[i]); } @@ -263,7 +258,8 @@ static void streamzap_callback(struct urb *urb) usb_submit_urb(urb, GFP_ATOMIC); } -static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) +static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz, + struct usb_device *usbdev) { struct rc_dev *rdev; struct device *dev = sz->dev; @@ -273,12 +269,12 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) if (!rdev) goto out; - usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); + usb_make_path(usbdev, sz->phys, sizeof(sz->phys)); strlcat(sz->phys, "/input0", sizeof(sz->phys)); rdev->device_name = "Streamzap PC Remote Infrared Receiver"; rdev->input_phys = sz->phys; - usb_to_input_id(sz->usbdev, &rdev->input_id); + usb_to_input_id(usbdev, &rdev->input_id); rdev->dev.parent = dev; rdev->priv = sz; rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; @@ -310,6 +306,7 @@ static int streamzap_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *usbdev = interface_to_usbdev(intf); + struct usb_endpoint_descriptor *endpoint; struct usb_host_interface *iface_host; struct streamzap_ir *sz = NULL; int retval = -ENOMEM; @@ -320,9 +317,6 @@ static int streamzap_probe(struct usb_interface *intf, if (!sz) return -ENOMEM; - sz->usbdev = usbdev; - sz->interface = intf; - /* Check to ensure endpoint information matches requirements */ iface_host = intf->cur_altsetting; @@ -333,22 +327,22 @@ static int streamzap_probe(struct usb_interface *intf, goto free_sz; } - sz->endpoint = &(iface_host->endpoint[0].desc); - if (!usb_endpoint_dir_in(sz->endpoint)) { + endpoint = &iface_host->endpoint[0].desc; + if (!usb_endpoint_dir_in(endpoint)) { dev_err(&intf->dev, "%s: endpoint doesn't match input device 02%02x\n", - __func__, sz->endpoint->bEndpointAddress); + __func__, endpoint->bEndpointAddress); retval = -ENODEV; goto free_sz; } - if (!usb_endpoint_xfer_int(sz->endpoint)) { + if (!usb_endpoint_xfer_int(endpoint)) { dev_err(&intf->dev, "%s: endpoint attributes don't match xfer 02%02x\n", - __func__, sz->endpoint->bmAttributes); + __func__, endpoint->bmAttributes); retval = -ENODEV; goto free_sz; } - pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); + pipe = usb_rcvintpipe(usbdev, endpoint->bEndpointAddress); maxp = usb_maxpacket(usbdev, pipe, usb_pipeout(pipe)); if (maxp == 0) { @@ -370,14 +364,13 @@ static int streamzap_probe(struct usb_interface *intf, sz->dev = &intf->dev; sz->buf_in_len = maxp; - sz->rdev = streamzap_init_rc_dev(sz); + sz->rdev = streamzap_init_rc_dev(sz, usbdev); if (!sz->rdev) goto rc_dev_fail; sz->idle = true; sz->decoder_state = PulseSpace; /* FIXME: don't yet have a way to set this */ - sz->timeout_enabled = true; sz->rdev->timeout = SZ_TIMEOUT * SZ_RESOLUTION; #if 0 /* not yet supported, depends on patches from maxim */ @@ -391,7 +384,7 @@ static int streamzap_probe(struct usb_interface *intf, /* Complete final initialisations */ usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, maxp, (usb_complete_t)streamzap_callback, - sz, sz->endpoint->bInterval); + sz, endpoint->bInterval); sz->urb_in->transfer_dma = sz->dma_in; sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; @@ -432,7 +425,6 @@ static void streamzap_disconnect(struct usb_interface *interface) if (!sz) return; - sz->usbdev = NULL; rc_unregister_device(sz->rdev); usb_kill_urb(sz->urb_in); usb_free_urb(sz->urb_in); From patchwork Mon Dec 6 14:37:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12658639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41D0BC433F5 for ; Mon, 6 Dec 2021 14:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344364AbhLFOki (ORCPT ); Mon, 6 Dec 2021 09:40:38 -0500 Received: from gofer.mess.org ([88.97.38.141]:54155 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344015AbhLFOki (ORCPT ); Mon, 6 Dec 2021 09:40:38 -0500 Received: by gofer.mess.org (Postfix, from userid 1000) id 9B765C603C; Mon, 6 Dec 2021 14:37:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1638801428; bh=U0tk56XprXZCOh//Hxbx2CiZTaBUINfgSaJredGFmWE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YB1KyzjEkwcyhETVd6mbgXKh0d17Wvq6V3+ffkW6/VQBrk+00Cyf0iGx4ar+KUDfg oaT1Cb/H+CqP2Sp7BkYEYHWEyJVM95SE/SpT7w5Y5j/D34pFcQ8FXXmaFHFpJaaYPS 9i9Y3vnFJMoytqeVUiG+ebacmChKPEwQ9+fQL1uazFuvl29dR6XJ5m9/GM0OChmAUX CE+POWcXq+nWvqyIro7D4CJrwrs7Et2GSs8L9fGCZA1tvspBp0Jl3Nr54204dm5/CC Q/Is9sEcOmFLBh9o9CxKoTWMVDIx/a32MECK9Aj/WB8eISE/bSVC9l2EPzlVk/bAO8 L7EmcABtapS6w== From: Sean Young To: linux-media@vger.kernel.org Subject: [PATCH 2/2] media: streamzap: remove redundant gap calculations Date: Mon, 6 Dec 2021 14:37:08 +0000 Message-Id: <9bc3bacf8d97b219d055929fddb5e46ec5eacf34.1638801410.git.sean@mess.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <3756e0cf7c64858510531867a9c10dbd80c1ee40.1638801410.git.sean@mess.org> References: <3756e0cf7c64858510531867a9c10dbd80c1ee40.1638801410.git.sean@mess.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The lirc driver already introduces gaps, so there is no need for this in the driver. Signed-off-by: Sean Young --- drivers/media/rc/streamzap.c | 55 ++++++------------------------------ 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c index 39856af16305..71ad750730fc 100644 --- a/drivers/media/rc/streamzap.c +++ b/drivers/media/rc/streamzap.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -75,13 +74,6 @@ struct streamzap_ir { /* track what state we're in */ enum StreamzapDecoderState decoder_state; - /* tracks whether we are currently receiving some signal */ - bool idle; - /* sum of signal lengths received since signal start */ - unsigned long sum; - /* start time of signal; necessary for gap tracking */ - ktime_t signal_last; - ktime_t signal_start; char phys[64]; }; @@ -115,37 +107,11 @@ static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir) static void sz_push_full_pulse(struct streamzap_ir *sz, unsigned char value) { - struct ir_raw_event rawir = {}; - - if (sz->idle) { - int delta; - - sz->signal_last = sz->signal_start; - sz->signal_start = ktime_get_real(); - - delta = ktime_us_delta(sz->signal_start, sz->signal_last); - rawir.pulse = false; - if (delta > (15 * USEC_PER_SEC)) { - /* really long time */ - rawir.duration = IR_MAX_DURATION; - } else { - rawir.duration = delta; - rawir.duration -= sz->sum; - rawir.duration = (rawir.duration > IR_MAX_DURATION) ? - IR_MAX_DURATION : rawir.duration; - } - sz_push(sz, rawir); - - sz->idle = false; - sz->sum = 0; - } + struct ir_raw_event rawir = { + .pulse = true, + .duration = value * SZ_RESOLUTION + SZ_RESOLUTION / 2, + }; - rawir.pulse = true; - rawir.duration = ((int) value) * SZ_RESOLUTION; - rawir.duration += SZ_RESOLUTION / 2; - sz->sum += rawir.duration; - rawir.duration = (rawir.duration > IR_MAX_DURATION) ? - IR_MAX_DURATION : rawir.duration; sz_push(sz, rawir); } @@ -158,12 +124,11 @@ static void sz_push_half_pulse(struct streamzap_ir *sz, static void sz_push_full_space(struct streamzap_ir *sz, unsigned char value) { - struct ir_raw_event rawir = {}; + struct ir_raw_event rawir = { + .pulse = false, + .duration = value * SZ_RESOLUTION + SZ_RESOLUTION / 2, + }; - rawir.pulse = false; - rawir.duration = ((int) value) * SZ_RESOLUTION; - rawir.duration += SZ_RESOLUTION / 2; - sz->sum += rawir.duration; sz_push(sz, rawir); } @@ -235,7 +200,6 @@ static void streamzap_callback(struct urb *urb) .pulse = false, .duration = sz->rdev->timeout }; - sz->idle = true; sz_push(sz, rawir); } else { sz_push_full_space(sz, sz->buf_in[i]); @@ -368,7 +332,6 @@ static int streamzap_probe(struct usb_interface *intf, if (!sz->rdev) goto rc_dev_fail; - sz->idle = true; sz->decoder_state = PulseSpace; /* FIXME: don't yet have a way to set this */ sz->rdev->timeout = SZ_TIMEOUT * SZ_RESOLUTION; @@ -379,8 +342,6 @@ static int streamzap_probe(struct usb_interface *intf, sz->max_timeout = SZ_TIMEOUT * SZ_RESOLUTION; #endif - sz->signal_start = ktime_get_real(); - /* Complete final initialisations */ usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, maxp, (usb_complete_t)streamzap_callback,