Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp211158ybg; Tue, 9 Jun 2020 21:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpTDju4U2Z7S3No+7cYWKfju8gGjqiXqTxgEztj1deCD9Ro1PHO0TjIAmXszvS2v3432Bf X-Received: by 2002:a17:906:73db:: with SMTP id n27mr1576498ejl.16.1591763717085; Tue, 09 Jun 2020 21:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591763717; cv=none; d=google.com; s=arc-20160816; b=qJR9hoD4XKQYJqDbG6SheQSNr0kVaoXyrmEVTLJlGI3KpGh2XHTYo52pJH4WSiNXIF SVftOdrW4QvYyvJY6/wxEySRGL+2fpqyqceAy/bfX1QzCeZaxsW3YOMB87mVzd5Hnn6s rRa6MDCf9YTZ+D2tkIP99hqyDsiyFtK3adilqFTDhDn05jjt/2/rNJAaRbtccTc77E4c Yn7vOvcuRV/LN66JcKrQxlFTWG1L7gWlvhQlULg3VAr5XGPr4XewmIBfkl6SsaoqXJEZ j/IU0VP/dSuWRaWmYwxUaYqDjwe187hI7nV+JVITtsxyDuDI1OrWomuzXHcp3ssWyLBW DqUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rNZY3kvPUajnugJBZAgYscKFfGeLDHC37yBStZ/Zzc0=; b=ltGLokIYEH57AEuUset4jqHW02OPciWbmODVXjkcelu+HmTL/8bX8Buc1iAKyh5r2g 3CW58NvFujfla/Q+P+LUmjhefnca1FFkqEMCZhq8UCF7OsoH9UjYRVXZqxxuwt3kYM6o 8HpH0peLRoYc3++AAviLTjqQqdoyAU78iHFq5psjJvzhsw6gNMEYSc/jbiEK35V1Yg0m PevqOKH1/V1wb46Ic3rfzzAfXUiCGewrzYU5Npb5kqMV30TwogsoXOeG2m49mNhXzOmK vE8l2xlht5hpUCnr1boIsxl4JVeuhH548pdIFF0vX5bFsBRwQKajOXuuCltxz1DXl74t QTOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F1GgAEfk; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ha26si12217158ejb.533.2020.06.09.21.34.54; Tue, 09 Jun 2020 21:35:17 -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=@chromium.org header.s=google header.b=F1GgAEfk; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726051AbgFJEcd (ORCPT + 99 others); Wed, 10 Jun 2020 00:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgFJEcb (ORCPT ); Wed, 10 Jun 2020 00:32:31 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9FCC05BD1E for ; Tue, 9 Jun 2020 21:32:30 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id m32so394326ede.8 for ; Tue, 09 Jun 2020 21:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rNZY3kvPUajnugJBZAgYscKFfGeLDHC37yBStZ/Zzc0=; b=F1GgAEfksMlFWf+LbjWv2+RWQ2Me1uHwZ/PexVY3WpC9e4coq6wekkYYP/tKnOKxyl GceH0uSy6sm+w/1UrCLci37W1+yyg5n9/tunLQPkIMtQw5mNpmw6Kc+NsDmS9KNG31vZ PV5kT5rPvRWY3y+PaOLzFQaeOdBuVs8HZLSyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rNZY3kvPUajnugJBZAgYscKFfGeLDHC37yBStZ/Zzc0=; b=SRoqsmBnM4YdzscffwKoExaXFZyGrDTmx/8Y+8h59xXMaX7qUKCWQDW6KWcxHQ5ajh yf/oc8EbjayiXY/TWOkROYsNlfNJ65kTzBCQhOCzYGXMa/lnIMGcBE10yk4gcPo0aOyO tYxtflwVy0VwMDTYSexess4qPzg2KVQhdMbhABtBC2LO3Eau42mn4AmQbniQq/cICSeo KU3Yy/IXIlW9KIK7G+8U7RWn6f8cTRVgltHuHBQRmCqGyZ9/Wyz4teNdVDF+3MEydrPF 16xfLm2n/YsLYdKy+J5DLrCVdmRheBbtxgqk/ZQFb+CPS9Kt0VDupoMWg1Ac2mGM4tS6 UUxw== X-Gm-Message-State: AOAM533g0Qk5fhFsdWr7qv0CmgUyCH2wptIYaTeeYPzUSHAcA+XKG/Hl xcXd4LgqJx0lJJWteVZbdzemW1LckFWOwg8+q5OTwg== X-Received: by 2002:a05:6402:17ce:: with SMTP id s14mr880290edy.53.1591763548970; Tue, 09 Jun 2020 21:32:28 -0700 (PDT) MIME-Version: 1.0 References: <20200609080001.121499-1-pihsun@chromium.org> <20200609080001.121499-3-pihsun@chromium.org> <20200609111919.GB4583@sirena.org.uk> In-Reply-To: <20200609111919.GB4583@sirena.org.uk> From: Pi-Hsun Shih Date: Wed, 10 Jun 2020 12:31:53 +0800 Message-ID: Subject: Re: [PATCH 2/2] regulator: Add driver for cros-ec-regulator To: Mark Brown Cc: Nicolas Boichat , Liam Girdwood , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Gwendal Grignou , Lee Jones , Fabien Lahoudere , Tzung-Bi Shih , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the review, some inline reply: On Tue, Jun 9, 2020 at 7:19 PM Mark Brown wrote: > > 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. Ack, would fix in v2. > > > +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. Ack, would fix in v2. > > > +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. Since I'm doing DIV_ROUND_UP for the min_mV, so this may happen if the min_uV~max_uV range given by the core doesn't contain any value that can be represented exactly in mV. > > > + 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. Ok I'll change this to reg property in v2. > > > +#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. Ack, would fix in v2.