From patchwork Mon Jul 4 13:23:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9212653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 565C160572 for ; Mon, 4 Jul 2016 13:21:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44101286F9 for ; Mon, 4 Jul 2016 13:21:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37283286FC; Mon, 4 Jul 2016 13:21:09 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 8D142286F9 for ; Mon, 4 Jul 2016 13:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932421AbcGDNUw (ORCPT ); Mon, 4 Jul 2016 09:20:52 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:60451 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932379AbcGDNUv (ORCPT ); Mon, 4 Jul 2016 09:20:51 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0LqnUA-1boSbl2uyw-00eOXl; Mon, 04 Jul 2016 15:20:39 +0200 From: Arnd Bergmann To: Hans de Goede Cc: Arnd Bergmann , Mauro Carvalho Chehab , Leandro Costantino , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH alternative] [media] gspca: avoid unused variable warnings Date: Mon, 4 Jul 2016 15:23:12 +0200 Message-Id: <20160704132341.1188066-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:4hfIW4wit/jyLHvBMp0o8IEFx6YQjjc4B4ShogSzXIPa9LKhXgu T/mPiDQu0qgOHpUEVJr7sD8gLmZ7v2kaVQxdfTIbEN1Zq3YrK8nvLFOzeW7LoUxhZ9PA5li 9ZmPPSPS2revjX5HhFIxJTJatUNsd8ZiEqCxovERrZCArSyOw6KiEos5E4nJ3SPm1xrAozi CQNYA4vNpU+w1OU0l7Abg== X-UI-Out-Filterresults: notjunk:1; V01:K0:77Da5Yhmk8w=:NFgVNwx6tYmdtgT+QSLodq ZmBe9T/8QE7uQNxSifnlXbgnOoaNiUec3DrAzLGY9aImsU9Wzf7jz/XF2Ov6K28xkgrdShc4n +vnNm8hlbVWnFBkbWk2gjBjETp76+STmj+10ROF4dr4oISENO7PgxdDcivCpLrEnnk/dQ/5yc WxgM78pUzWK8f/RCtLSri9APLDHSNs51BJ3Nr2+2ozzTgmGo/BpxFMreUkzyQqDmDuYyUK1Y4 ZwaZURx3fwDSGhEkJrirPzvsiceTcLlFTcPbAhy+bhzU4ivsMfZ4sW4jA7iXwyQ0m1kEYYiRC i4+BqMPsG3omOwXqIGB6VI/CEq+pL1pzk1iCGg69+PwomuzLVk/QI28UddjNpDOe3nfNPUaHW HXdhwBTQJvs7/BWtIGksD86EuLsbLYUoYoAG7MVQNqmA54INp3nUhs07nA1dAaXmFj02ddKX0 3s2X00ZHota+UeCNh92OgvYyZAWRr/u8sDgsHhwsOmUJLv8Hyr1rwl12YUNPdV1TfyI/8HWIu /WecH8krZFEfZqJx9ezgbchHEIkZwy2GJLmTecUxHtG2mXdN1iC6BKKH2PYEeVS/TDR0ScFiU Smeu57IpDpITZRxJ1pXVs1vjuG+qLqsX+gySrbJ+i1ur+iZfCg/wK+BjfrKpkYPfMoRbnVvFD BtLCJEqZ+x2hd3cSQF6JEUt0JdtmVLGVyAQKu5xPlOPcQJiMWfJQgw3MO34zlWJD7YLQ= 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 When CONFIG_INPUT is disabled, multiple gspca backend drivers print compile-time warnings about unused variables: media/usb/gspca/cpia1.c: In function 'sd_stopN': media/usb/gspca/cpia1.c:1627:13: error: unused variable 'sd' [-Werror=unused-variable] media/usb/gspca/konica.c: In function 'sd_stopN': media/usb/gspca/konica.c:246:13: error: unused variable 'sd' [-Werror=unused-variable] This converts the #if check into an if(), to let the compiler see where the variables are used, at the expense of slightly enlarging the gspca_dev structure. Signed-off-by: Arnd Bergmann Fixes: ee186fd96a5f ("[media] gscpa_t613: Add support for the camera button") Fixes: c2f644aeeba3 ("[media] gspca_cpia1: Add support for button") Fixes: b517af722860 ("V4L/DVB: gspca_konica: New gspca subdriver for konica chipset using cams") --- This is one of two approaches to avoid the warning, please pick either this or the other one. --- drivers/media/usb/gspca/cpia1.c | 13 ++++++------- drivers/media/usb/gspca/gspca.h | 2 +- drivers/media/usb/gspca/konica.c | 8 ++------ drivers/media/usb/gspca/t613.c | 8 ++------ 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c index f23df4a9d8c5..29ce3faecada 100644 --- a/drivers/media/usb/gspca/cpia1.c +++ b/drivers/media/usb/gspca/cpia1.c @@ -540,10 +540,11 @@ static int do_command(struct gspca_dev *gspca_dev, u16 command, /* test button press */ a = ((gspca_dev->usb_buf[1] & 0x02) == 0); if (a != sd->params.qx3.button) { -#if IS_ENABLED(CONFIG_INPUT) - input_report_key(gspca_dev->input_dev, KEY_CAMERA, a); - input_sync(gspca_dev->input_dev); -#endif + if (IS_ENABLED(CONFIG_INPUT)) { + input_report_key(gspca_dev->input_dev, + KEY_CAMERA, a); + input_sync(gspca_dev->input_dev); + } sd->params.qx3.button = a; } if (sd->params.qx3.button) { @@ -1637,16 +1638,14 @@ static void sd_stopN(struct gspca_dev *gspca_dev) /* Update the camera status */ do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); -#if IS_ENABLED(CONFIG_INPUT) /* If the last button state is pressed, release it now! */ - if (sd->params.qx3.button) { + if (IS_ENABLED(CONFIG_INPUT) && sd->params.qx3.button) { /* The camera latch will hold the pressed state until we reset the latch, so we do not reset sd->params.qx3.button now, to avoid a false keypress being reported the next sd_start */ input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); input_sync(gspca_dev->input_dev); } -#endif } /* this function is called at probe and resume time */ diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h index d39adf90303b..0d0f8ba1d673 100644 --- a/drivers/media/usb/gspca/gspca.h +++ b/drivers/media/usb/gspca/gspca.h @@ -149,8 +149,8 @@ struct gspca_dev { struct usb_device *dev; struct file *capt_file; /* file doing video capture */ /* protected by queue_lock */ -#if IS_ENABLED(CONFIG_INPUT) struct input_dev *input_dev; +#if IS_ENABLED(CONFIG_INPUT) char phys[64]; /* physical device path */ #endif diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c index 39c96bb4c985..2abbde7ee532 100644 --- a/drivers/media/usb/gspca/konica.c +++ b/drivers/media/usb/gspca/konica.c @@ -246,15 +246,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) struct sd *sd = (struct sd *) gspca_dev; konica_stream_off(gspca_dev); -#if IS_ENABLED(CONFIG_INPUT) /* Don't keep the button in the pressed state "forever" if it was pressed when streaming is stopped */ - if (sd->snapshot_pressed) { + if (IS_ENABLED(CONFIG_INPUT) && sd->snapshot_pressed) { input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); input_sync(gspca_dev->input_dev); sd->snapshot_pressed = 0; } -#endif } /* reception of an URB */ @@ -341,8 +339,7 @@ static void sd_isoc_irq(struct urb *urb) if (st & 0x80) { gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0); - } else { -#if IS_ENABLED(CONFIG_INPUT) + } else if (IS_ENABLED(CONFIG_INPUT)) { u8 button_state = st & 0x40 ? 1 : 0; if (sd->snapshot_pressed != button_state) { input_report_key(gspca_dev->input_dev, @@ -351,7 +348,6 @@ static void sd_isoc_irq(struct urb *urb) input_sync(gspca_dev->input_dev); sd->snapshot_pressed = button_state; } -#endif if (st & 0x01) continue; } diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c index e2cc4e5a0ccb..fd2500725f25 100644 --- a/drivers/media/usb/gspca/t613.c +++ b/drivers/media/usb/gspca/t613.c @@ -823,14 +823,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev) msleep(20); reg_w(gspca_dev, 0x0309); } -#if IS_ENABLED(CONFIG_INPUT) /* If the last button state is pressed, release it now! */ - if (sd->button_pressed) { + if (IS_ENABLED(CONFIG_INPUT) && sd->button_pressed) { input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); input_sync(gspca_dev->input_dev); sd->button_pressed = 0; } -#endif } static void sd_pkt_scan(struct gspca_dev *gspca_dev, @@ -841,8 +839,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, int pkt_type; if (data[0] == 0x5a) { -#if IS_ENABLED(CONFIG_INPUT) - if (len > 20) { + if (IS_ENABLED(CONFIG_INPUT) && len > 20) { u8 state = (data[20] & 0x80) ? 1 : 0; if (sd->button_pressed != state) { input_report_key(gspca_dev->input_dev, @@ -851,7 +848,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, sd->button_pressed = state; } } -#endif /* Control Packet, after this came the header again, * but extra bytes came in the packet before this, * sometimes an EOF arrives, sometimes not... */