Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1803433rwd; Tue, 13 Jun 2023 14:37:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XWj9sTcEWRO9UTxY0kXDYhTAfLqfZu62psP7vZvCV6W8xJ1PtqcbvqRV3jIdIsxOSc9oI X-Received: by 2002:a17:906:99c4:b0:974:6216:8dd2 with SMTP id s4-20020a17090699c400b0097462168dd2mr16365621ejn.27.1686692266492; Tue, 13 Jun 2023 14:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686692266; cv=none; d=google.com; s=arc-20160816; b=0QlvxzaDyFVYi71Bs80kVdjwwbFASwUQF2DiHjkYiwWKfKGKuDfniZ9CupwgHzr1Ak WFz8qOs2Zdd/jRVpfJq2jn68m4Rw/dKjMr4aj3TUPJnUrs3RVSm1/jrzmArMGKVcz4L9 XIsnk91BFqej5CVa6V6pKY39JMqOCsIJv5rCG9D1fp7Rc+9lERIjfpV3bOHVKp0K7xgJ 0HE72Q9QUhney/zRiYt9KXlATI6Ft1NPf9rk9B3ZeZyy1CgYBqanZhx1wNt5N5deeSe3 RoBoY/uKydvNJvHWCTrsdjPXDV57aUNGoRAOdaAz8erxGqUCkaAdyd4AtGaOhTmmO7Ez 88Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jjZCe4TrlpXSYUUbagVQDBLP7aBDJF+vIKC3en79nPo=; b=qrjkUHV7Yvwv4RrKyCsdBl3uXD3eXzgHcVU1qMgVV5VqdSOfJnPaNiOmBmcaeJAE+G AJJXmrz4uLvj/FjU+CrFT7X4nKsk/V5n89f+rHeSyHYXo5Nf1V99vAMcBO6hq/JWo9Ou v/XfNlcve0jf4D9dE0Pzm+/iym7/bVJ5jqpjOO5jroagQ9eq7BlS6IjEA39DZBFdyuNk vjTIMIKNaboNxls8mRPxh/YWnUGfNubfU1gUx4NrVZG2jKvE2TC7qOORN5CUcW5vzAJz SGwzcxzzN0FicC/9pK7B0nWvWrLgdjwoWglyNrdJux1GOSDf2p/EPThed5jWqemuM0vz emkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pKDOX8Hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ov15-20020a170906fc0f00b00969f259cac2si7466637ejb.640.2023.06.13.14.37.21; Tue, 13 Jun 2023 14:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pKDOX8Hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbjFMV06 (ORCPT + 99 others); Tue, 13 Jun 2023 17:26:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230220AbjFMV05 (ORCPT ); Tue, 13 Jun 2023 17:26:57 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C614173C; Tue, 13 Jun 2023 14:26:53 -0700 (PDT) X-GND-Sasl: alexandre.belloni@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686691612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jjZCe4TrlpXSYUUbagVQDBLP7aBDJF+vIKC3en79nPo=; b=pKDOX8HkYiifDAB1XriX5mIBW5Jz9sucTkoPOBmTln+QszEhusmswpdySTBA97iXRfsGBf sbZCJH+832cgP7WciP76y3ADpuYljAlsCGBghvKvcr48hW9nis7qUFDVCaImlVBb1JzyzO uVzuEGgtnX2+vU+h0Gm9ZEK9kpR4EGvLINJSGl8OzggbkfHLwJLBmaMkAT4jcAOXGjXQsy muI1LIIJXUhIytwDFNoycJZTaaKP6kobo/tsX+eqMw/gAzZ73cRGDqSBWl6r8TDEANIOEr JnDhxiOWSdFgeimQO5vJVBjsSbXz5ujqmew0nD1tgEIuKtqgy4YiwT2Xz2u1FA== X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com X-GND-Sasl: alexandre.belloni@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 029941C0002; Tue, 13 Jun 2023 21:26:51 +0000 (UTC) Date: Tue, 13 Jun 2023 23:26:51 +0200 From: Alexandre Belloni To: Andy Shevchenko Cc: Rasmus Villemoes , Alessandro Zummo , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/8] rtc: isl12022: implement RTC_VL_READ ioctl Message-ID: <20230613212651c8770218@mail.local> References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230613130011.305589-1-linux@rasmusvillemoes.dk> <20230613130011.305589-6-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GND-Spam-Score: 400 X-GND-Status: SPAM X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/2023 18:20:56+0300, Andy Shevchenko wrote: > On Tue, Jun 13, 2023 at 03:00:07PM +0200, Rasmus Villemoes wrote: > > Hook up support for reading the values of the SR_LBAT85 and SR_LBAT75 > > bits. Translate the former to "battery low", and the latter to > > "battery empty or not-present". > > A couple of nit-picks below. > > ... > > > +static int isl12022_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) > > +{ > > + struct regmap *regmap = dev_get_drvdata(dev); > > + u32 user = 0, val; > > This assignment can be done in the actual case below. > > > + int ret; > > + > > + switch (cmd) { > > + case RTC_VL_READ: > > + ret = regmap_read(regmap, ISL12022_REG_SR, &val); > > + if (ret < 0) > > I always feel uneasy with ' < 0' — Does positive error makes sense? > Is it even possible? OTOH if the entire driver uses this idiom... > oh well, let's make it consistent. > /** * regmap_read() - Read a value from a single register * * @map: Register map to read from * @reg: Register to be read from * @val: Pointer to store read value * * A value of zero will be returned on success, a negative errno will * be returned in error cases. */ > > + return ret; > > user = 0; > > The rationale to avoid potential mistakes in the future in case this function > will be expanded and user will be re-used. > > > + if (val & ISL12022_SR_LBAT85) > > + user |= RTC_VL_BACKUP_LOW; > > + > > + if (val & ISL12022_SR_LBAT75) > > + user |= RTC_VL_BACKUP_EMPTY; > > + > > + return put_user(user, (u32 __user *)arg); > > + > > + default: > > + return -ENOIOCTLCMD; > > + } > > +} > > -- > With Best Regards, > Andy Shevchenko > > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com