Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp275859imm; Tue, 15 May 2018 01:17:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqxqdmLmQArTvbWbcaL77d0x+xr9L4t+3Ddla8J0mchFTGSZI/NNWmw3Zq1dhzG/iednonv X-Received: by 2002:a62:bd2:: with SMTP id 79-v6mr14038599pfl.4.1526372269309; Tue, 15 May 2018 01:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526372269; cv=none; d=google.com; s=arc-20160816; b=iDIFhYoOLhano1x9lfKYusNRksIAx2u05lRSsMp4yLnbum9WVwvcvNOD2hM8jKLTL8 vA0bSD6R0Spx9zWnR6yKLLNju0z6nD6rabiDEvpfmX19mh7RqhOfaf3J1SWDNO3mvyTO oPijtmuTPNmV2FYCRpIdkQnx59ztO3eJy5/T5RzwEzgjckHOJLHcDVdLs13qDenT/pAL tF/kifCOQvjCPoPZN5z0+8LfQkyZESa2cyd+xePvYpEFcnWvquy765SQ96SYRU1/yKVf zspD7+NIfX/P3/Qx2ZiIIeG682z2O8TrvEKbmPYLn4+zpex2HQD+9dVCygYoHwQwx6S/ Agxw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=J9bHZ9fPSC91tFGGPm2zyGfjbWZcc7JXf6wVQHFypWg=; b=XzhaK6rtYgW8lurKFxuNuwPFsZ7UnftSV3T2Wsx7DfHUs0Sp417fZgqc6y/Q4ik/MY 6KzK1+zV9XJxh0YrCta81BIJSltCo0oepedn/+Oe4QWOPiq5fDkVfp1MEHvJ621FUMSy 5pP6behMegMwA39W9RbsdfX5ZfLXES4S3617XBB3UaOlZNYIHqg8y/4dnSPaRiVn8umF 2Pl/Jn95cs6EgCX11CWlLKhBmZ+Wbh8SkP/uADnaaak5f9gJ1kiTPEVC31ylRV5DNuSh AZUEpD1pb0RSkSQBzoI0ovsn5dZrJiS+yrZ6lV9aX77+LFrKH6RcQGGVsvp22q2pVty9 F2Lw== 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 n25-v6si9441006pgc.42.2018.05.15.01.17.35; Tue, 15 May 2018 01:17:49 -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 S1752551AbeEOIQJ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 15 May 2018 04:16:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:47142 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752482AbeEOIQH (ORCPT ); Tue, 15 May 2018 04:16:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 42033AC95; Tue, 15 May 2018 08:16:06 +0000 (UTC) Date: Tue, 15 May 2018 10:16:02 +0200 From: Jean Delvare To: Andy Shevchenko Cc: Anders Roxell , linux-i2c , Linux Kernel Mailing List Subject: Re: [PATCH v2] i2c: i801: fix unused-function warning Message-ID: <20180515101602.79ff49cf@endymion> In-Reply-To: References: <20180510152719.6e37b10e@endymion> <20180514093326.30314-1-anders.roxell@linaro.org> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On Mon, 14 May 2018 20:18:37 +0300, Andy Shevchenko wrote: > On Mon, May 14, 2018 at 12:33 PM, Anders Roxell > wrote: > > With CONFIG_PM, we get a harmless build warning: > > drivers/i2c/busses/i2c-i801.c:1723:12: warning: ‘i801_resume’ defined but not used [-Wunused-function] > > static int i801_resume(struct device *dev) > > ^~~~~~~~~~~ > > drivers/i2c/busses/i2c-i801.c:1714:12: warning: ‘i801_suspend’ defined but not used [-Wunused-function] > > static int i801_suspend(struct device *dev) > > ^~~~~~~~~~~~ > > > -#ifdef CONFIG_PM > > +#ifdef CONFIG_PM_SLEEP > > static int i801_suspend(struct device *dev) > > The better pattern is to get rid of ugly ifdef and supply > __maybe_unused annotation to each function in question. That was Anders' first proposal, but it was declined by the driver maintainer (me.) See: https://marc.info/?l=linux-kernel&m=152588526520326&w=2 __maybe_unused is just a way to prevent the compiler from doing its job. If it's really what you want, you might as well build with -Wno-unused, instead of crippling the code with yet another annotation. I can't see how building unused code only to discard it later can be better than a proper #ifdef which will only build the code when we actually need it. Maybe there are cases where __maybe_unused is actually needed, but in my opinion that should be the last resort option. That's not the case here. -- Jean Delvare SUSE L3 Support