Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5279005imu; Tue, 29 Jan 2019 16:25:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN4zTz24EhrdBc7ZwT36Kf9fl2iWqPa5qY0fclkfvQXgO4DIrAa0XvvG+b6DOniSwvH4Lv/q X-Received: by 2002:a62:9913:: with SMTP id d19mr28363684pfe.107.1548807935312; Tue, 29 Jan 2019 16:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548807935; cv=none; d=google.com; s=arc-20160816; b=vpWy5csDRz8EuiKKjT9PVNzp2or5Ru32iKCO83lCjhVhy9xh115PVa2QcKjZmODsG9 Qjp05cMxhD8DoqhIBy1Ye0CiG/4IX1Nwm8dsvqhDALBsg+emc2BUFUVQwPpvDX4OpVLj E3XMSptQNpx7XsgeBMkW87JdzVy7wZy9P7eyWZuUeQkx4Ddapt4oIGEYJdBtwt7z546k svAkAwAGWsmdt4Dv3MRjRIenXtbp50vWdHWeSSnft9j8aEpHQGmLolni8e4HI3ta6S8X mlpDEiBUewwfzu7YPN8IIxtLuinbWuhyrldh8tbjImmXP294pgyU6nzlKvBGd4T2r2yX RPbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=8QD3BLfryhhpPEJCSA9FAXLeo/cERyXpa66bM//QkOI=; b=xJ1kdWSYgMCOwIujrz+vtytnO8doIoGnKXEFpOMrQ1galcUyydBM6hXXFdyEuk83zb CeL841aKvdYZuX3cbGdxrCVlH5TjWabcMywz+5Lo7VjS7G5M7Y7Iv4V4UqIRirrS9uSH eLIRmjRbep7NjdeU1TqBjl58TyvzK0DIm/Wx3Qp++IutMxuZihLuE9V/De6ErQCWrKi4 6J3vcBcTvRF/A2xvSk92J6Ydfm8dJ3gfELXChxmJlr4YQ7wmrKRM1/WdKB+EHMtERHAh +ayNOrKCQpo7fQYrUJ2SaxkYD0Yuk/tL729ytECODXJ1glgrHSH3B2zkAerog/KsSmEa mQ5Q== 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 w5si9945258pll.64.2019.01.29.16.25.18; Tue, 29 Jan 2019 16:25:35 -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; 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 S1729050AbfA3AZP (ORCPT + 99 others); Tue, 29 Jan 2019 19:25:15 -0500 Received: from mx0a-002e3701.pphosted.com ([148.163.147.86]:56894 "EHLO mx0a-002e3701.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbfA3AZO (ORCPT ); Tue, 29 Jan 2019 19:25:14 -0500 Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0U0OH9i025702; Wed, 30 Jan 2019 00:24:22 GMT Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 2qb17mr195-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Jan 2019 00:24:22 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 957DEEE; Wed, 30 Jan 2019 00:24:07 +0000 (UTC) Received: from anatevka (anatevka.americas.hpqcorp.net [10.34.81.61]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id AD1F637; Wed, 30 Jan 2019 00:24:04 +0000 (UTC) Date: Tue, 29 Jan 2019 17:24:04 -0700 From: Jerry Hoemann To: Matti Vaittinen Cc: Guenter Roeck , mazziesaccount@gmail.com, heikki.haikola@fi.rohmeurope.com, mikko.mutanen@fi.rohmeurope.com, lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, broonie@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, linus.walleij@linaro.org, bgolaszewski@baylibre.com, sre@kernel.org, lgirdwood@gmail.com, a.zummo@towertech.it, alexandre.belloni@bootlin.com, wim@linux-watchdog.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [RFC PATCH v2 08/10] rtc: bd70528: Initial support for ROHM bd70528 RTC Message-ID: <20190130002404.GA19729@anatevka> Reply-To: Jerry.Hoemann@hpe.com References: <20190125110536.GA29321@localhost.localdomain> <35bbc5b9-5f8c-ec80-3eaa-bb2c0e2812c9@roeck-us.net> <20190128202656.GA17466@anatevka> <20190129070103.GA2551@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190129070103.GA2551@localhost.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-29_19:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=986 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901300000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 29, 2019 at 09:01:03AM +0200, Matti Vaittinen wrote: > On Mon, Jan 28, 2019 at 01:26:56PM -0700, Jerry Hoemann wrote: > > On Sat, Jan 26, 2019 at 08:30:24AM -0800, Guenter Roeck wrote: > > > On 1/25/19 3:05 AM, Matti Vaittinen wrote: > > > > +static int bd70528_set_wake(struct bd70528 *bd70528, > > > > + int enable, int *old_state) > > > > +{ > > > > + int ret; > > > > + unsigned int ctrl_reg; > > > > + > > > > + ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WAKE_EN, &ctrl_reg); > > > > + if (ret) > > > > + return ret; > > > > + > > > > + if (old_state) { > > > > + if (ctrl_reg & BD70528_MASK_WAKE_EN) > > > > + *old_state |= BD70528_WAKE_STATE_BIT; > > > > + else > > > > + *old_state &= ~BD70528_WAKE_STATE_BIT; > > > > + > > > > + if ((!enable) == (!(*old_state & BD70528_WAKE_STATE_BIT))) > > > > + return 0; > > > > > > I think > > > if (enable == !!(*old_state & BD70528_WAKE_STATE_BIT)) > > > would be much better readable. Even if not, there are way too many () > > > in the above conditional. > > > > > > > The substitution is not equivalent to original. I think you mean: > > > > if (!!enable == !!(*old_state & BD70528_WAKE_STATE_BIT)) > > Thanks Jerry! Good catch! I originally wanted that all non-zero values > of 'enable' would be 'true'. So maybe I just use the original approach > but get rid of extra parenthesis which were pointed out by Guenter. > > if (!enable == !(*old_state & BD70528_WAKE_STATE_BIT)) > should do it just fine, right? > The use of "!!" to turn an int into one of two Boolean values (0 | 1) is used extensively in Linux and as such might make the intent of the code a bit clearer which I take as checking to see the states match. But, I will defer to you and Guenter on the question. -- ----------------------------------------------------------------------------- Jerry Hoemann Software Engineer Hewlett Packard Enterprise -----------------------------------------------------------------------------