Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp426308ybg; Tue, 9 Jun 2020 04:21:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPDjXGwkYyrBPrHGiEGOpK6g5FM+ikQsFcHDGWFzkYYJCDTY0ZLL9LKiWOzePE+6ek4Z+/ X-Received: by 2002:a50:954b:: with SMTP id v11mr26493613eda.273.1591701707297; Tue, 09 Jun 2020 04:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591701707; cv=none; d=google.com; s=arc-20160816; b=rWcailgQ8eBPJ4qso6b1zxrwAohIxI8IExH5X8OT3SfPybFtEaTgqvTw2WhTCorLOV mQVSTezoxJ95v2VYNadlFRqzDg8TZc3h8aZIsuo1gS08y0K+PhycVpQhej4T0R8ox4Y6 YAcoPjVuz4qCu47y+AWj6tmRhivx7rzmm5xzXR8Y1+afCWpE+Oj3z27WzrEH/c0uS7bM WYsgRPI7iHv64yaBVcFvMYH0dNS9uA1C3LC7KkOlMKzyxRxFxIvI/efgKMuRp7zBno6W U3RqqlnwNguLfa8ug7rC96UB9BvpvAQg5NvWLFxUK7oFpmXESOQBl1qUGTcqg+qIke4X rnHg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=BxtbScUF2ptuRRT/8KdB9SXJcd80RUfQSFVb+Ar85Yk=; b=W/Bt2PjYtQyoczx/yvYyUgkVxwrtpS01MvDbMTQriTs8z5XXbAR1Q6ebRI388o88jJ 3ymrxpGkdslXJLMO+FAQ+ndYwalTkLvoS+jUnt6zaTfMqv3sZPdeLdU3Afk/aMfGzbqn 95cu3AM2SJK/81L33kPhFJqxDGjGxyl9+n88ozFWwV4IsiJ1GzjbY4zLpr1D0LtlDV+y 2EEXf87GXLRbqq10GclBRwyMu1Ks/4D4Q3Po8muAZbfPcr9+JK++VOu2EJUM1BR0GPZI nd7VhPmX1w+B1YtAKSCVKolJlMBMsAN5CztFeafKSF1rXIAu3bv7dxGkt/eZIdPib7Tf 0grQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=grNWNDH3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si10064600ejh.449.2020.06.09.04.21.23; Tue, 09 Jun 2020 04:21:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=grNWNDH3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728889AbgFILTY (ORCPT + 99 others); Tue, 9 Jun 2020 07:19:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:42454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727002AbgFILTW (ORCPT ); Tue, 9 Jun 2020 07:19:22 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 474D6207ED; Tue, 9 Jun 2020 11:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591701561; bh=6oLQbi+VXC1BdFqllwYDYoh8Oblpv+hbligMTtN4J9A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=grNWNDH3GlB+YNv3nWCA/FnuaYvGvyFVA8jL/Y5gTcEYV8LTScYQ+LE56GWpT820v CMxIrbcjLrnArBNgWsMIiLgu4ebGojdkmezi3xiDISKdOBUBpiZPg0val06pCT+YFz jxwXA9YCaZ4ud06SzK/33S3Q6PVxjqWsEAJ+wI4A= Date: Tue, 9 Jun 2020 12:19:19 +0100 From: Mark Brown To: Pi-Hsun Shih Cc: Nicolas Boichat , Liam Girdwood , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Gwendal Grignou , Lee Jones , Fabien Lahoudere , Tzung-Bi Shih , open list Subject: Re: [PATCH 2/2] regulator: Add driver for cros-ec-regulator Message-ID: <20200609111919.GB4583@sirena.org.uk> References: <20200609080001.121499-1-pihsun@chromium.org> <20200609080001.121499-3-pihsun@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zx4FCpZtqtKETZ7O" Content-Disposition: inline In-Reply-To: <20200609080001.121499-3-pihsun@chromium.org> X-Cookie: Be careful! Is it classified? User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --zx4FCpZtqtKETZ7O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jun 09, 2020 at 03:59:55PM +0800, Pi-Hsun Shih wrote: > +static int cros_ec_regulator_set_state(struct regulator_dev *dev, bool enable) > +{ > + struct cros_ec_regulator_data *data = rdev_get_drvdata(dev); > + struct ec_params_regulator_enable cmd = { > + .index = data->index, > + .enable = enable ? 1 : 0, The ternery operator is totally redundant here. > +static int cros_ec_regulator_enable(struct regulator_dev *dev) > +{ > + return cros_ec_regulator_set_state(dev, true); > +} > +static int cros_ec_regulator_disable(struct regulator_dev *dev) > +{ > + return cros_ec_regulator_set_state(dev, false); > +} I'm not sure that the shared function is really worthwhile though, there's not really enough in it and certainly not anything complicated. > +static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV, > + int max_uV, unsigned int *selector) > +{ > + struct cros_ec_regulator_data *data = rdev_get_drvdata(dev); > + int min_mV = DIV_ROUND_UP(min_uV, 1000); > + int max_mV = max_uV / 1000; > + struct ec_params_regulator_set_voltage cmd = { > + .index = data->index, > + .min_mv = min_mV, > + .max_mv = max_mV, > + }; > + > + if (min_mV > max_mV) > + return -EINVAL; The core will do this for you. > + ret = of_property_read_u32(np, "google,remote-regulator", > + &drvdata->index); > + if (ret < 0) > + return ret; This remote-regulator property is a bit weird, it feels like it should be a reg property on a bus. > +#if defined(CONFIG_OF) > +static const struct of_device_id regulator_cros_ec_of_match[] = { > + { .compatible = "regulator-cros-ec", }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, regulator_cros_ec_of_match); > +#endif Your compatible is google,regulator-cros-ec. --zx4FCpZtqtKETZ7O Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl7fcDYACgkQJNaLcl1U h9A5Fgf/Yyo8CmM9ox3GNrQJJGSsFommmFLc+Zk9J9kySNzjzSAete1eVCX7D8XU LuLvLP7Adm0+ouCAaty/on0CMaXpnislczWMQDu3wWmIuv8RUGUGb5btlJi4M32p tcmDal42jgwj49szrLR9BlH96l2pfyfkW6+4lktXHQt51t8xonHBzH4pDptBUqSa UxQnCS1+lHQI8EG1GYOhWdlYFrV7kiYDVLyA9xJeFjuCE4QYkggyQq7Gy1fGFgw+ WsKRmHQuHajXLFIKR+8SbVpBBVp2OYBCrSmVVWUBC8//VMR49yUOC1KMscDJ7Ujm eYA9OmT/RzJXN5LmZVsoqlXx93itFw== =j9T6 -----END PGP SIGNATURE----- --zx4FCpZtqtKETZ7O--