Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1291290rwr; Thu, 20 Apr 2023 12:44:06 -0700 (PDT) X-Google-Smtp-Source: AKy350aUSF4m3vVSDnxM/GlCfU9GMrDii0nWTLtPPym26VJ+QF1orQcomgOrSInefYBHR/Z+BWSF X-Received: by 2002:a05:6a00:807:b0:63a:fae3:9890 with SMTP id m7-20020a056a00080700b0063afae39890mr3173828pfk.24.1682019845880; Thu, 20 Apr 2023 12:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682019845; cv=none; d=google.com; s=arc-20160816; b=lI4cbL4jJhP67+wHU/QlKE2GeRLosJ8KxqABj9BHOXMXMBBVz7uCJk1vN7mKjWPa43 Y8FSUSn8mTJC8VYDsxSZgXAq+3fT37Y0H/Q+h2n8DK/pMC9xhXiiG11U5kXONCaHb9kR EEiLxk0LMqxtNNfvVbAchh+Rxp6cGpOAFGrn8X5JMwkPjjXvluLqcKkl5cY2TV7HuwbP KSqc4O5ehbZoofXRWvS7Ob8AkpKRDFIt3JRZKM7YRxGgBZafG1bnoU1hUi1eJABTG7oE TuLk+rqiEhWSOIBdGM1NE8Ye+lrbVVBGn1pdkj19hd4PcrQj5Qm0nok0AJdd9v+ENvgt UD0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N7qSJwDSiitY3uCpzZx4l6+eeywWmLBW7PeXm8DLhHc=; b=Zdu0sHedePhce24QRmZQEoPoCrwGcWTltT9DfyvBJDJy+3zgLO/JYSpWWjQbj8OSTn WmlBWAxtrKTm0IbV79SIjj9rq7/BLNzXy33UlCjR3/ACpdC1VhZdObNNo89aBQmDOmml F0+hzIAcNpLOZmp2aeTyN9V1xuEqOltmteio3MatCS6EwsmSWTvRlH/Pw/T+pWP910tm bRk7OxJ9q+uRw2qyJroIQATHQ68HaxBbm3NP7gljS8BAJ57yXEbSSvcH77B268axoId6 +5obbFm2ZqKLiAPEuGLeEiSprrxYZWpTCEW80DK2HOH0whXMio5Qv8/lTENsyrKsd1Cv 7oOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=D7k+1CR9; 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=9elements.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x187-20020a6263c4000000b0063d2f6979fcsi2508805pfb.56.2023.04.20.12.43.54; Thu, 20 Apr 2023 12:44:05 -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=@9elements.com header.s=google header.b=D7k+1CR9; 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=9elements.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbjDTTYl (ORCPT + 99 others); Thu, 20 Apr 2023 15:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbjDTTYi (ORCPT ); Thu, 20 Apr 2023 15:24:38 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED0B835BF for ; Thu, 20 Apr 2023 12:24:32 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f1738d0d4cso6255145e9.1 for ; Thu, 20 Apr 2023 12:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1682018671; x=1684610671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N7qSJwDSiitY3uCpzZx4l6+eeywWmLBW7PeXm8DLhHc=; b=D7k+1CR96+DNx76UiY9T/db8eriT4tmt+8o1MN2Xxy3ozmNQV1fhw+Fpybe+io4ru+ iGRpNT+weQAG45PiMGDb6+z2gtduBFba0ijcBHdZ6QEurIUoI096+MWXEpVlTSa4gMIV 5yEQIcjSkazIGb4fVRZFAsXLisZNSIE5ijgsd3J61/hKwzRkt5ulPeIv+Z1G6ElJI20E sT1xtLo3prZdoro2Ng7p5zsj6GVo5D4h+YQpXgR+fBm3Lk8cDwVAZsO3ulaonX1mB7WE hLG7liDf6vxbS6RluuNJGgGoe2I8e16vEBKGj73YotdV0dZDSVHbR5BzxogxiPclXiqT 41FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682018671; x=1684610671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N7qSJwDSiitY3uCpzZx4l6+eeywWmLBW7PeXm8DLhHc=; b=c6iPxI6LnlBsjPhLrq5mK8vNbveIGM7dMbZ6dgsOCQ1D9dsZzdDDLY+ZDMZ/xgNfoV FlUSDWn2PdXvmxI+eVUn2caEFAOmJKuPhgro3mjRIoqlOXh3cI3CYilznm86K2w9jWFY vogCBwybozbPuTK5FnFFNKxRcDZO0jyQ2/F48Wfq4FYZWbPnHcX8hrDTMfXnRE1Mzfed y8vopdA8cseP6cFOSsGQXxKg3Ydh8DtpL7OUfn5fr/lKauvSH/nJFtyvNAaro5Jmhams 4uOcCwGv4rol71opLgv5eMYWpPtKqh//4mLa2Z+6XSim1dlSXgmpuEDOuSIL7s82LY33 kydg== X-Gm-Message-State: AAQBX9cYkHwuy0GGYd4tHkEkXVYjvdNjQKsh3GJ/NdgaxwUUTjx6+m9G zSXN10ZaNCU+A+tFXpGNWpVq8A== X-Received: by 2002:a7b:c8cb:0:b0:3f1:8167:dc30 with SMTP id f11-20020a7bc8cb000000b003f18167dc30mr79981wml.2.1682018671473; Thu, 20 Apr 2023 12:24:31 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id u3-20020a7bcb03000000b003f16f3cc9fcsm2825651wmj.9.2023.04.20.12.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 12:24:31 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: zev@bewilderbeest.net, Liam Girdwood , Mark Brown Cc: Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] regulator: userspace-consumer: Support multiple supplies in DT Date: Thu, 20 Apr 2023 21:24:02 +0200 Message-Id: <20230420192402.3695265-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230420192402.3695265-1-Naresh.Solanki@9elements.com> References: <20230420192402.3695265-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Add support for optional DT property 'regulator-supplies' to handle connectors with multiple supplies. If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback. This change improves support for some connector output like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies. Signed-off-by: Naresh Solanki ... Change in V2: - Update commit message - Code improved to add fallback if the property isn't used. --- drivers/regulator/userspace-consumer.c | 33 +++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c index 97f075ed68c9..aaa0189d6dab 100644 --- a/drivers/regulator/userspace-consumer.c +++ b/drivers/regulator/userspace-consumer.c @@ -120,7 +120,10 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) struct regulator_userspace_consumer_data tmpdata; struct regulator_userspace_consumer_data *pdata; struct userspace_consumer_data *drvdata; - int ret; + struct device_node *np = pdev->dev.of_node; + struct property *prop; + const char *supply; + int ret, count = 0; pdata = dev_get_platdata(&pdev->dev); if (!pdata) { @@ -131,11 +134,29 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) memset(pdata, 0, sizeof(*pdata)); pdata->no_autoswitch = true; - pdata->num_supplies = 1; - pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies), GFP_KERNEL); - if (!pdata->supplies) - return -ENOMEM; - pdata->supplies[0].supply = "vout"; + + if (of_find_property(np, "regulator-supplies", NULL)) { + pdata->num_supplies = of_property_count_strings(np, "regulator-supplies"); + if (pdata->num_supplies < 1) { + dev_err(&pdev->dev, + "could not parse property regulator-supplies\n"); + return -EINVAL; + } + pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies) * + pdata->num_supplies, GFP_KERNEL); + if (!pdata->supplies) + return -ENOMEM; + of_property_for_each_string(np, "regulator-supplies", prop, supply) { + pdata->supplies[count++].supply = supply; + } + } else { + pdata->num_supplies = 1; + pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies), + GFP_KERNEL); + if (!pdata->supplies) + return -ENOMEM; + pdata->supplies[0].supply = "vout"; + } } if (pdata->num_supplies < 1) { -- 2.39.1