Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1195822ybj; Tue, 5 May 2020 15:11:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLua2O4i0QzvQEdYUdLUT8Pjz78hKcIg4XalZxtI/P2cURQmpcy92loJhCb7uefpCj9xiQU X-Received: by 2002:a50:c60c:: with SMTP id k12mr4575979edg.111.1588716667236; Tue, 05 May 2020 15:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588716667; cv=none; d=google.com; s=arc-20160816; b=Az7Q2S8k9jvhBpfXMuf7rFQ3g4ekWkJq+j4IDVyP7BtBEX89J3ATETLzA906z5jdFP I6dAF+1RzxhJUibySAXLlwLG0cXn+ZO1VjzziREuH0ljDz3nGCYiN+H7GeCiy5WwtHCB 7kmwelp2CgRzp1vtbG6lvyuA0S+K0mPKhB9Nzq/B09N1Vy5BJUfSqV6IP/8zqVfJ9QV7 t2LunjensmgBMyoaMd74zIWmhj1KTa7OlwxipN7GQMuRANX4HL8ABJSzi2P6wbevcHIG abefOK2z23YKIzJS9vMUd+iQIBHNdB8oAPaUQn8ZtMC454c5FrPE++8Fc5CWpjfQybTu Wrcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=sjtEoS8e9VIGbjrwNMhhlfNT8/nkVRr9nt7aGpNizIo=; b=IfohAsmb0h2YsyaTy+Il7gCzWsgLhtK+sEichcOTzuNX18Kk/2hmuifFHJarnJJc+y 3x8/kpJ0EvZIChPli+3Ju1VX1DnGItKbuj2zJ7aN8SdMLRCCoMy9QCZ05eW+nomYR3SL jQgTjRuZE7K5st1iY/azsvmGO55qyJKn6GWWCvFb+CTai2TYa97kNKRtQdrVqEN7zjVc fWAOmn0pSmhYbEYfzfG8I4D730J9y6Qxr36zdkMS8UpWrz+LcROwoQwTbOcGgJFJ41PP wa186CIOMEvTjMW9B2g0oTomY6MAn7z3U2eTdoG5GBOkmoKBgadoYtvzDmsSUsD00JY1 W49Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f24si14305eja.417.2020.05.05.15.10.42; Tue, 05 May 2020 15:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729159AbgEEWJP (ORCPT + 99 others); Tue, 5 May 2020 18:09:15 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:56265 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgEEWJO (ORCPT ); Tue, 5 May 2020 18:09:14 -0400 X-Originating-IP: 86.202.105.35 Received: from localhost (lfbn-lyo-1-9-35.w86-202.abo.wanadoo.fr [86.202.105.35]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2C875C0003; Tue, 5 May 2020 22:09:12 +0000 (UTC) Date: Wed, 6 May 2020 00:09:11 +0200 From: Alexandre Belloni To: Rasmus Villemoes Cc: linux-rtc@vger.kernel.org, Per =?iso-8859-1?Q?N=F8rgaard?= Christensen , linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] rtc: pcf2127: report battery switch over Message-ID: <20200505220911.GW34497@piout.net> References: <20200505201310.255145-1-alexandre.belloni@bootlin.com> <20200505201310.255145-5-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/05/2020 23:30:18+0200, Rasmus Villemoes wrote: > On 05/05/2020 22.13, Alexandre Belloni wrote: > > Add support for the RTC_VL_BACKUP_SWITCH flag to report battery switch over > > events. > > > > Signed-off-by: Alexandre Belloni > > --- > > drivers/rtc/rtc-pcf2127.c | 16 ++++++++++++---- > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c > > index 039078029bd4..967de68e1b03 100644 > > --- a/drivers/rtc/rtc-pcf2127.c > > +++ b/drivers/rtc/rtc-pcf2127.c > > @@ -188,18 +188,27 @@ static int pcf2127_rtc_ioctl(struct device *dev, > > unsigned int cmd, unsigned long arg) > > { > > struct pcf2127 *pcf2127 = dev_get_drvdata(dev); > > - int touser; > > + int val, touser = 0; > > int ret; > > > > switch (cmd) { > > case RTC_VL_READ: > > - ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL3, &touser); > > + ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL3, &val); > > if (ret) > > return ret; > > > > - touser = touser & PCF2127_BIT_CTRL3_BLF ? RTC_VL_BACKUP_LOW : 0; > > + if (val & PCF2127_BIT_CTRL3_BLF) > > + touser = RTC_VL_BACKUP_LOW; > > + > > + if (val & PCF2127_BIT_CTRL3_BF) > > + touser |= RTC_VL_BACKUP_SWITCH; > > I think it's a bit easier to read if you use |= in both cases. > > Re patch 3, one saves a little .text by eliding the ioctl function when, > as you say, it cannot be called anyway. No strong opinion either way, I > don't think anybody actually builds without CONFIG_RTC_INTF_DEV, but > those that do are probably the ones that care about having a tiny vmlinux. > Honestly, I don't think it is worth doing that. On armv7, this only removes 248 bytes. Also, compiling without CONFIG_RTC_INTF_DEV simply makes the RTC unusable. There are no tools actually using the sysfs interface instead of the char device interface. I prefer keeping CONFIG_RTC_INTF_DEV private to the core. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com