Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2165000ybx; Sat, 2 Nov 2019 13:19:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiOBwoJW9vgDIQ40sqXp+gN2D1mAOYJs0Bp04Ja8cnYng8/kVR1TK2agVjMEwHdPbJsAFP X-Received: by 2002:a17:906:3385:: with SMTP id v5mr16297520eja.154.1572725973334; Sat, 02 Nov 2019 13:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572725973; cv=none; d=google.com; s=arc-20160816; b=WBj+3OtDDI3+jRapnRMEUIZhnZFy9WlWKgRKZBvASUq9fivkb7b6M/xDD56oIxdZHq Ovfg90f4cLAX9CsSTBwi+xFQ4oZXwy76Sr5ERb5GR0jcNnDUNfGzhNyywFmmck/OkzCe Jmul+eTVK1bb7SlfJ1CeAp53Kls6MqkST9pUHTJ3mw4+cKG3oGMzQI4Ou6ihZr3wPp1k Yjr7OJkp8X7d6nC/VaZwl7tAAxfWnFf4uGeAtonry9NifXyXnWdacX0dVe0lryqKhHxx JwhLTzq0wdtuieoUfiJ1CD6StMJ8XB5In+cEjcn/NJ0ZN6CCKBsD3S7lnV+s018FpHDU sY8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GCKtXZPJZlR/Mcd74h91IO3TX8RtSvtBcuGVBQORT7Q=; b=vQ31KeyP+fFWjWXwmHnClqjhhKH9gB5sAILBsgAhh+NZr0y26aDqP4W23I2cGVHnOD p8cTpX7P5AQTFpPR6EgBo9LnmLJCpwo5+pbc/Lh8tdOC3RIYiw/jsiGiZwbbrx0KmF9A nrMBly18do2Ly3WqGQ0FNhk4BQMcX83mubv7WYy2yzhCDrHcZpY6qxYEe9yR6erc7uwb qmKK+Mh6pMVQ1uzsFIuLhfWJpKKxZnQKv7hrgrnMUybH5sEFX4rHctJbJKwfczIo8/lN vsW0RtngwpcUASIXc3QZv8Zt0KDAPtwJspghVDshHDoQ0oTxmM8Os1JxHx/lM1fRr+nA 8K4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si8712382ejz.6.2019.11.02.13.19.10; Sat, 02 Nov 2019 13:19:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbfKBUPr (ORCPT + 99 others); Sat, 2 Nov 2019 16:15:47 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:35242 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbfKBUPr (ORCPT ); Sat, 2 Nov 2019 16:15:47 -0400 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992926AbfKBUPibe3l0 (ORCPT + 1 other); Sat, 2 Nov 2019 21:15:38 +0100 Date: Sat, 2 Nov 2019 21:15:35 +0100 From: Ladislav Michl To: Jonathan Cameron Cc: YueHaibing , knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, denis.ciocca@st.com, rfontana@redhat.com, tglx@linutronix.de, heiko.stuebner@bq.com, rjones@gateworks.com, drake@endlessm.com, colin.king@canonical.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] iio: st_accel: Fix unused variable warning Message-ID: <20191102201535.GA30346@lenoch> References: <20191101134741.25108-1-yuehaibing@huawei.com> <20191102104125.GA22015@lenoch> <20191102140810.3d756294@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191102140810.3d756294@archlinux> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 02, 2019 at 02:08:10PM +0000, Jonathan Cameron wrote: > On Sat, 2 Nov 2019 11:41:25 +0100 > Ladislav Michl wrote: > > > On Fri, Nov 01, 2019 at 09:47:41PM +0800, YueHaibing wrote: > > > drivers/iio/accel/st_accel_core.c:1005:44: warning: > > > mount_matrix_ext_info defined but not used [-Wunused-const-variable=] > > > > > > Move it to ifdef to mute this warning. > > > > > > Signed-off-by: YueHaibing > > > --- > > > drivers/iio/accel/st_accel_core.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c > > > index 2e37f8a..bba0717 100644 > > > --- a/drivers/iio/accel/st_accel_core.c > > > +++ b/drivers/iio/accel/st_accel_core.c > > > @@ -1002,10 +1002,12 @@ get_mount_matrix(const struct iio_dev *indio_dev, > > > return adata->mount_matrix; > > > } > > > > > > +#ifdef CONFIG_ACPI > > > static const struct iio_chan_spec_ext_info mount_matrix_ext_info[] = { > > > IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, get_mount_matrix), > > > > So now you do not get any warning for unused get_mount_matrix? > > (Then it would make more sense to put all that stuff under one ifdef > > and provide empty apply_acpi_orientation for non ACPI case) > > Does the __maybe_unused marking make this go away? > > I'd assume that the compiler will manage to drop this either way > but I guess we should check that. > > ifdef magic is always harder to read and potentially fragile in the > long run. Here we simply want to indicate that in some build > configurations we might not use this. This suggestion implies we'll get rid of CONFIG_ACPI completely, which seems inapproriate looking at size of apply_acpi_orientation function. And having both CONFIG_ACPI and __maybe_unused does not make much sense. I had something like that in mind (+COMPILE_TEST perhaps): diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 2e37f8a6d8cf..0e7eac62d618 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -993,6 +993,7 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { #define ST_ACCEL_TRIGGER_OPS NULL #endif +#ifdef CONFIG_ACPI static const struct iio_mount_matrix * get_mount_matrix(const struct iio_dev *indio_dev, const struct iio_chan_spec *chan) @@ -1013,7 +1014,6 @@ static const struct iio_chan_spec_ext_info mount_matrix_ext_info[] = { static int apply_acpi_orientation(struct iio_dev *indio_dev, struct iio_chan_spec *channels) { -#ifdef CONFIG_ACPI struct st_sensor_data *adata = iio_priv(indio_dev); struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_device *adev; @@ -1141,10 +1141,14 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev, out: kfree(buffer.pointer); return ret; -#else /* !CONFIG_ACPI */ +} +#else +static int apply_acpi_orientation(struct iio_dev *indio_dev, + struct iio_chan_spec *channels) +{ return 0; -#endif } +#endif /* * st_accel_get_settings() - get sensor settings from device name > Thanks, > > Jonathan > > > > > > > { }, > > > }; > > > +#endif > > > > > > /* Read ST-specific _ONT orientation data from ACPI and generate an > > > * appropriate mount matrix. > > > -- > > > 2.7.4 > > >