Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2747636ybx; Sun, 3 Nov 2019 03:06:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy1hrF8KRJGOk3gq97DBvqHrCJv6/OSQiAsiozRBED3ob3hSdB6iXLdhxiuuN8d0GifPDba X-Received: by 2002:a17:906:3285:: with SMTP id 5mr18167795ejw.143.1572779160121; Sun, 03 Nov 2019 03:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572779160; cv=none; d=google.com; s=arc-20160816; b=w1Q2GnzrGkrStPP2yoBRmHqY/eLWkOGWxF4/s75csNUL73b7WBTonygLk3eBtDKEj7 cxD37oaUviZAEyp/09ajbhECMdtGN0Zx2aIzmtK0yP/ea1FK4miXvwGvw9n0hvYiy2fO wfPhdtGBQ0tWeoF0nz9mwDnH0ebFHzGTScoumd4FGGTLy6q2Cy7T1OiO1LEGKpsndQy6 6LvSrLWybcoUPCC6xmNVph5DEuJCxVERLaz8G6bYZUEdd30K7+jYK/TIxryvDxlf2ERi MLN2VZ6n0Hdct237FlrjPXJvHohT0u9wAD9qKD7q5aZp/pjFIDeAQ+ak8lxdKClWPfqt kKDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=aS8R+cRQTDEkXItnMM/IU0ULa/wqAIG4rYwjYrSR/n8=; b=d7KrH7et83sBe/53U/gtju8THDg/Z5qiS6MCfVjbAUzv0QodI9m74kkN0gAJqW7XFX tXfJvIQjHmlZMEjkbWHrsTdr7AFDsV/WgnIfQs/WQjLZsjCPoVTJrqrgeuFv5KY3Kx8a hEOFW0tiOEVOm7flhpmTcJ9CefFlSVyk8DhiRDO4OpXJrRoq60UPuzDGm5FLZn+wtxC5 HOCjmVbqcopb+OYHqYOPcBAhFQ84c2Zc51ytPWwLtUZ2JMV44iXezUL2HIw0x9WrEqvS 7cTa+s+Qrf1XC3Im3YeoKRTBY5PZOF3H2WhQHvrnM/d1njOGeqTjiKMKplTvtd8wBA2Z gU6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SufD7E4g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si4505872edb.234.2019.11.03.03.05.24; Sun, 03 Nov 2019 03:06:00 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=SufD7E4g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727490AbfKCLBi (ORCPT + 99 others); Sun, 3 Nov 2019 06:01:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:59114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726998AbfKCLBi (ORCPT ); Sun, 3 Nov 2019 06:01:38 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3573A20842; Sun, 3 Nov 2019 11:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572778896; bh=oipkd6rQfHiDI65o0ii8gnAMeM1wSzlA2B/Q0CGwYwY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SufD7E4gi3oJVFVo1Vu7ZQ3hvtI0yZ9J8eqzJgpNORyCKxfEZ4/LG//6XEtV05ffx 5RC7W3HBEJviBiarBvWNR2P9IPYKrwPURx+JqaKDgu0Hd4kpF0vozsL7hdsfbg96SF afmnXvOCVxDG6vxUqiWZ0lH5nJy2vTUOjwDEn9+g= Date: Sun, 3 Nov 2019 11:01:31 +0000 From: Jonathan Cameron To: Ladislav Michl 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: <20191103110131.1e6c1f04@archlinux> In-Reply-To: <20191102201535.GA30346@lenoch> References: <20191101134741.25108-1-yuehaibing@huawei.com> <20191102104125.GA22015@lenoch> <20191102140810.3d756294@archlinux> <20191102201535.GA30346@lenoch> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2 Nov 2019 21:15:35 +0100 Ladislav Michl wrote: > 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): One additional oddity here is why we have explicit support for the mount matrix only in the ACPI paths. There are standard DT bindings for it as well which we should be using. So let us take your approach below for now, but it would be good to support this properly on non acpi platforms as well. Where it isn't specified it will fall back to an identity matrix which is as good as we have now with no information supplied. Please send a v2 with the below. Thanks, Jonathan > > 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 > > > >