Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1382113rwd; Tue, 13 Jun 2023 08:25:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bjVCg+GUvIpdWQoYjRu6jsQnO0W+a7aMG2kDKw1KTj7KB5rgov6k2LUXsQVpGGVUZqiyV X-Received: by 2002:a17:907:96ab:b0:96f:f98c:ac71 with SMTP id hd43-20020a17090796ab00b0096ff98cac71mr11638144ejc.67.1686669902730; Tue, 13 Jun 2023 08:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686669902; cv=none; d=google.com; s=arc-20160816; b=VGjVsvHD9I4DnrG5+zXon4c5Bh6NEBaHs2uTAgbTQt32sDAhAz7IEEzZS4fOJrCtmj ojzMhcuowSx5MVA6NGuIV8XZK9IKRZAEERgA7VLif2Fsl0C9YwQjEEv8wqBl7wfT4DPV zFkZsw62qe/Jp7If4X0B5gsHSv98a3NiI5AU9BKk0xQwa7xla6u7nmNepGi479n80+HB /hwBEWCMgzl+lTVzhjoif1qYvT3p338ed+QsqS6LMnpvhLEGUQq2butVqd0BbkuJX6P7 1lM21ThnFrQFYcEv6YpcmtJtqF0y0Qp/fINXhE54dq7NtQyF0XcrFMjIYyusUrZEQdUU 7+mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ex0dznvpi1eleeA8XHHQu01oULAGo5ibgkKdkgGEv+Y=; b=ZEU1m+ITcTj4G6E03KeAjvEg9d988Y7ZD2fE5DbzD/L+EWp0FB7QqQDWxzsuPo6Vqt LmQUnfskZMjw4nr00ylXTHBxYM/FH51BLRuCdw9rqdV/Qt/DmBIg84UK4zgVWCzKuRjD 0hN036Vafx5q3LlQ8pKlmpIolYrbEAo/fpdrTQIAh9PEgDbLrCgevyXncfZSbtpp7BfL Mn35gNmZGmmYsTJOCbNaO2MH8tS6x727R1EISf/auivLif9bptrXwJGeQGlebBO2Q/O0 G+/2PX8Wx3TPe1yK8sqyiDQVu0CaXnRS27vtrT6JdakbZPEd1jAr9lrtph3UiurOPrmG PZ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O0dpH6xI; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a170906715700b00960c27e4608si6645985ejj.399.2023.06.13.08.24.37; Tue, 13 Jun 2023 08:25:02 -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=@intel.com header.s=Intel header.b=O0dpH6xI; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241271AbjFMPVD (ORCPT + 99 others); Tue, 13 Jun 2023 11:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234367AbjFMPVC (ORCPT ); Tue, 13 Jun 2023 11:21:02 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A794199A; Tue, 13 Jun 2023 08:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686669662; x=1718205662; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=plNmqEkqncOE/3uGn703aXGX7ZUQBL5FWEgWSiyApfI=; b=O0dpH6xIz/XCyfM3PxwfCzMhuFzKOIPErkS8ijCMMZeCHP1O5ZoQAnYN Lyy+bjVUo/mrhFKqtIcZGLeXYZxvBzbcSDbPx2MC11HdFcjiYrZZjNIg4 RNvQzcmPqdqvAUSIHCmjZjy6UAQaBro5ngPqFHeE/CpwUmwgIN937Clb+ IdVwnC6JjE+x/LrBLU2ZVMTJVCV+CL0Su0z4ZgNqbqdXQ30JdNJvS8Xe+ CGGVpn9jZoHAnGVMdU+vDP0951MOHLxenzXmOqEwkN8byyU3fsx0Hw3ZY 9f6niiNWiq8fajeJwVYj5kIxrB5z5qkZa57rnJXfwepAbF8uXoRbOk+/F w==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="348021136" X-IronPort-AV: E=Sophos;i="6.00,240,1681196400"; d="scan'208";a="348021136" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 08:21:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711699337" X-IronPort-AV: E=Sophos;i="6.00,240,1681196400"; d="scan'208";a="711699337" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2023 08:20:58 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1q95pI-003UAE-1G; Tue, 13 Jun 2023 18:20:56 +0300 Date: Tue, 13 Jun 2023 18:20:56 +0300 From: Andy Shevchenko To: Rasmus Villemoes Cc: Alessandro Zummo , Alexandre Belloni , 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: 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: <20230613130011.305589-6-linux@rasmusvillemoes.dk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 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. > + 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