Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1824329iog; Thu, 16 Jun 2022 14:52:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sMhkhPtfcfAOVLoILXi2v4xYAXGJfajcmT1Wq9cuvg2eMbiNTAFTwjZAtH9PNtHx7x/LCb X-Received: by 2002:a17:902:b714:b0:168:f72d:b8d5 with SMTP id d20-20020a170902b71400b00168f72db8d5mr6484337pls.66.1655416365707; Thu, 16 Jun 2022 14:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655416365; cv=none; d=google.com; s=arc-20160816; b=onQpUJoa1Jjrn8O+YzinWhnnBD4umTJFsy7eHKjD10daCFXCp2jIUbWgD7YYpSEOWU 48kLC2mIfa6mABbQLgFEHc/1ZBpdiGOkCC0RBooYbIX98PsIjeCpd77v7qcFMXkHtdR7 XjcQIZV142Htd3wFRRftyQjRIl4cM6NXCjwCiVOkIRPiGNqB1WvJzS7y2FTrMvsi0rUx OeSFwFFH5hUkShDlU/JEaK4XQ0MDf8m3bUyUsKE/xO7RtBWS2JxuyOSXXOr5yDLYlfbE v9lR9jpn9m4hFvVnloPE7XpO0n3dVJ0oFltYsdO2K3DVha3DDnVYUXf1N6b0H7e4vWKN z6Ig== 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=uN2MkJ4nUIty1Sor4XqPwun1hGLUtXm8GHd5WHbkewo=; b=0D81O5pVXF76tG3WPSl7bl+fH2JXBidhG7fejltEkFhikR1cAJEKkfTRopXTuJS3QU vlmwJD+tbWKaggWXfqZ7IlbyOygcqqBnpWkyZJ0rxb3HIWJo6WejFqbf84QJTnprG4OP yzVa+LoM+5f8TOdYUZ0buFRwidJYnv+fSxmYgeMlz4G9VWYxocKnkVF0H0Pde/70pqIY unlwybsfu3f3XvdhP8HpZVmLZYF98ROZYdHUVdPJ+wF9hFA7IGGTVgtN97DZXg2eudVH KseahTCpCWItQca+1b7SBIKO6iuZ3Gtf/su67lyzA6JD8W/l/sFAtyW4fGLbaY0DY1Na 4pew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zmokaMcV; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rt9-20020a17090b508900b001e86a88ccbesi3294887pjb.81.2022.06.16.14.52.33; Thu, 16 Jun 2022 14:52:45 -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=@linaro.org header.s=google header.b=zmokaMcV; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378747AbiFPU5u (ORCPT + 99 others); Thu, 16 Jun 2022 16:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiFPU5s (ORCPT ); Thu, 16 Jun 2022 16:57:48 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BF018394 for ; Thu, 16 Jun 2022 13:57:47 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id a17so235592pls.6 for ; Thu, 16 Jun 2022 13:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=uN2MkJ4nUIty1Sor4XqPwun1hGLUtXm8GHd5WHbkewo=; b=zmokaMcV6kyTpb28Gi8AD+sXGgk4clAe1LHnxikamybHWfRzKloNw5d4MWaKqb4XbY jlGKGQGnK1+nTTbvlabT9aHoYZuc505lAG259+1EmeINJXzmI4JBxUAmP44mQN90TIq4 gizXW/SlGVlxdozS8yAGTFUxL1LuxTds/q4S45sRsTv0u5XF8po7XTE4AmauyBnlJhi+ SJRPwyFqQ1fXzVhySp7YU3Ga7bWRWiFHzr8g5ViteJbC1zKTEvDx0i61atSLq1PcAj05 K1r6xkTydF05AiQ0iOCv0Wtb7L2iTl6KkXKH9k7vNro8CApVaLUZq0UFouNGx5ght+p5 oJqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=uN2MkJ4nUIty1Sor4XqPwun1hGLUtXm8GHd5WHbkewo=; b=qufE6hnsGfYJqqhnC2LVgIeXMzo9YcepSUyz2sPMu/5EdK0sxgAlpSWhhF2qRDt3wD qVSKOnhdTL8nUVhjMXDJpeEHmn/C60oc9AH92LPc/96JRsWLkrVovsDPiRt1MTtNGL4F PamhANiGqBC9iApTiI/H4FUIioGSNnW096B6WKr/vy70OPzaaE0gyE44QaRliIw9LDXy g+8ENXz7llt6Dgqh6TKP4KdFMrf5mhA8ja/zYBJrazyD2/3n4GSnohaZcgyLUoq+n8qu IphYPmPUwfQ2EBYfWaIJ7+G8sNFQq1Syq3ffmBaO4qyEGsBt8HA1vZU31n2VEY+LtCmt Ji5A== X-Gm-Message-State: AJIora95hrmh4pKPyVGGa8EvSFEYzOMgJQzfTsIlg8iBuA5Zqdq4pXR1 AkWNpbWAlCLwLviMsD+KKQ8Snw== X-Received: by 2002:a17:90a:aa96:b0:1ea:3780:c3dc with SMTP id l22-20020a17090aaa9600b001ea3780c3dcmr17901042pjq.241.1655413066683; Thu, 16 Jun 2022 13:57:46 -0700 (PDT) Received: from google.com ([192.77.111.2]) by smtp.gmail.com with ESMTPSA id h10-20020a170902f7ca00b001621ce92196sm2046829plw.86.2022.06.16.13.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 13:57:45 -0700 (PDT) Date: Thu, 16 Jun 2022 21:57:41 +0100 From: Lee Jones To: Satya Priya Cc: Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, quic_collinsd@quicinc.com, quic_subbaram@quicinc.com, quic_jprakash@quicinc.com Subject: Re: [PATCH V15 6/9] mfd: pm8008: Use i2c_new_dummy_device() API Message-ID: References: <1655200111-18357-1-git-send-email-quic_c_skakit@quicinc.com> <1655200111-18357-7-git-send-email-quic_c_skakit@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1655200111-18357-7-git-send-email-quic_c_skakit@quicinc.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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, 14 Jun 2022, Satya Priya wrote: > Use i2c_new_dummy_device() to register pm8008-regulator > client present at a different address space, instead of > defining a separate DT node. This avoids calling the probe > twice for the same chip, once for each client pm8008-infra > and pm8008-regulator. > > As a part of this define pm8008_regmap_init() to do regmap > init for both the clients and define pm8008_get_regmap() to > pass the regmap to the regulator driver. > > Signed-off-by: Satya Priya > Reviewed-by: Stephen Boyd > --- > Changes in V15: > - None. > > Changes in V14: > - None. > > Changes in V13: > - None. > > drivers/mfd/qcom-pm8008.c | 34 ++++++++++++++++++++++++++++++++-- > include/linux/mfd/qcom_pm8008.h | 9 +++++++++ > 2 files changed, 41 insertions(+), 2 deletions(-) > create mode 100644 include/linux/mfd/qcom_pm8008.h > > diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c > index 569ffd50..55e2a8e 100644 > --- a/drivers/mfd/qcom-pm8008.c > +++ b/drivers/mfd/qcom-pm8008.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -57,6 +58,7 @@ enum { > > struct pm8008_data { > struct device *dev; > + struct regmap *regulators_regmap; > int irq; > struct regmap_irq_chip_data *irq_data; > }; > @@ -150,6 +152,12 @@ static struct regmap_config qcom_mfd_regmap_cfg = { > .max_register = 0xFFFF, > }; > > +struct regmap *pm8008_get_regmap(const struct pm8008_data *chip) > +{ > + return chip->regulators_regmap; > +} > +EXPORT_SYMBOL_GPL(pm8008_get_regmap); Seems like abstraction for the sake of abstraction. Why not do the dereference inside the regulator driver? > static int pm8008_init(struct regmap *regmap) > { > int rc; > @@ -217,11 +225,25 @@ static int pm8008_probe_irq_peripherals(struct pm8008_data *chip, > return 0; > } > > +static struct regmap *pm8008_regmap_init(struct i2c_client *client, > + struct pm8008_data *chip) > +{ > + struct regmap *regmap; > + > + regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg); > + if (!regmap) > + return NULL; > + > + i2c_set_clientdata(client, chip); > + return regmap; > +} This function seems superfluous. It's only called once and it contains a single call. Just pop the call directly into probe. > static int pm8008_probe(struct i2c_client *client) > { > int rc; > struct pm8008_data *chip; > struct gpio_desc *reset_gpio; > + struct i2c_client *regulators_client; > struct regmap *regmap; > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > @@ -229,11 +251,19 @@ static int pm8008_probe(struct i2c_client *client) > return -ENOMEM; > > chip->dev = &client->dev; > - regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg); > + regmap = pm8008_regmap_init(client, chip); > if (!regmap) > return -ENODEV; > > - i2c_set_clientdata(client, chip); > + regulators_client = i2c_new_dummy_device(client->adapter, client->addr + 1); > + if (IS_ERR(regulators_client)) { > + dev_err(&client->dev, "can't attach client\n"); > + return PTR_ERR(regulators_client); > + } > + > + chip->regulators_regmap = pm8008_regmap_init(regulators_client, chip); > + if (!chip->regulators_regmap) > + return -ENODEV; > > reset_gpio = devm_gpiod_get(chip->dev, "reset", GPIOD_OUT_LOW); > if (IS_ERR(reset_gpio)) > diff --git a/include/linux/mfd/qcom_pm8008.h b/include/linux/mfd/qcom_pm8008.h > new file mode 100644 > index 0000000..3814bff > --- /dev/null > +++ b/include/linux/mfd/qcom_pm8008.h > @@ -0,0 +1,9 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +// Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. > +#ifndef __QCOM_PM8008_H__ > +#define __QCOM_PM8008_H__ > + > +struct pm8008_data; > +struct regmap *pm8008_get_regmap(const struct pm8008_data *chip); > + > +#endif -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog