Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B45BAC001B0 for ; Mon, 7 Aug 2023 08:26:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A44C86933; Mon, 7 Aug 2023 10:26:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oosacB1X"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 68FE686939; Mon, 7 Aug 2023 10:26:29 +0200 (CEST) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 695D686922 for ; Mon, 7 Aug 2023 10:26:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-523108efb36so4663140a12.1 for ; Mon, 07 Aug 2023 01:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691396786; x=1692001586; 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=KnuJzyttXdYOO/Y5QuViyNLB5skqt6xD/FB7G0SDNwU=; b=oosacB1XQvQJA7HBraJkGx42Wv57t9yAMg51aEA6LFdFbs+dM47dAWgzgvfhrez391 Koe/OMWsBnDS+88nIV+OcZM57u7jLA/470M0OsWkjtUKxNckQm8+G9ldjdidlUUY9m4P C6Hor5h1RV77z9OKw6miHW3rJe0ZgUw5qV0yocds4ZQNLKIwljmKSSmiLRwGzx6neoBK JYwq8Xh3z9lonDW+BbcL15tfL4tWfyzsF6bwxsWJ7ZOu0FQGxQYXnL00YYMp+N3HL9t+ D9RRuKJmKkUvwOg8dLheDTSq7BVsDNGjYC1bcfppJMO8mciuXtnAX1iwkrOT2Mfufwf/ CsUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691396786; x=1692001586; 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=KnuJzyttXdYOO/Y5QuViyNLB5skqt6xD/FB7G0SDNwU=; b=fz2vepD/0NHCu1Mq5RV5FOWlvsy59UW1sDuR5bxrMaibYY/TpGqMWYBmWVLfYN8uO7 JW9T4u/EhAfZLOQERQAN8hwNlplBzSKdIhu+YBKUIk+j8S196CwqA8t9+VhLUgJCMr6g tntORn76qpZ6WA8zfYpGo5nl6ENu1q6gkmvuSVIbKr9SHIZXutB0abvx+hOTc2jvAz5T A6Zhc+hwlESUwx/IO+0dR7KsTi9M+1jkklTIisxt17xyeRy1nU4AHOATt203gjbcfjMz fuyxD7DD8BnQlo4M/JVvs4KIf+z+6kCc11gPnytw2/TpqGC1yq7zRsg94CdJOXszSUz/ STyg== X-Gm-Message-State: AOJu0YwmB59FcVxRW3tR8IpvmvIVBqh9IEtt7LpjmCUTJTDC3mgh8nDv feioMMcydteGHul3xzyaxRE= X-Google-Smtp-Source: AGHT+IHAAraK2kzFo9S07fyHhz4B6YmvCqRGizV32KGv8jdBUpjOKjQ4g5o/vL9rfDLpvnG9f1ExAg== X-Received: by 2002:aa7:d316:0:b0:522:38f9:e64e with SMTP id p22-20020aa7d316000000b0052238f9e64emr7032681edq.1.1691396785761; Mon, 07 Aug 2023 01:26:25 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id v7-20020aa7dbc7000000b0052333e5237esm1952801edt.88.2023.08.07.01.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 01:26:25 -0700 (PDT) From: Svyatoslav Ryhel To: Jaehoon Chung , Simon Glass , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v5 2/8] power: regulator: palmas: fix ldoln and ldousb detection Date: Mon, 7 Aug 2023 11:25:59 +0300 Message-Id: <20230807082605.56135-3-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807082605.56135-1-clamor95@gmail.com> References: <20230807082605.56135-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean dev->driver_data will carry the tail of ldo if there is a number and if there is no number it will be an error code, anyway it will not be zero. This results in a wrong ldo regulator detection. To avoid this check for non-numerical ldo first and then manipulate dev->driver_data. Signed-off-by: Svyatoslav Ryhel --- drivers/power/regulator/palmas_regulator.c | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c index 3c4eb83be7..d615e94734 100644 --- a/drivers/power/regulator/palmas_regulator.c +++ b/drivers/power/regulator/palmas_regulator.c @@ -301,19 +301,23 @@ static int palmas_ldo_probe(struct udevice *dev) uc_pdata->type = REGULATOR_TYPE_LDO; - if (dev->driver_data) { + /* check for ldoln and ldousb cases */ + if (!strcmp("ldoln", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; + uc_pdata->volt_reg = palmas_ldo_volt[type][9]; + return 0; + } + + if (!strcmp("ldousb", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; + uc_pdata->volt_reg = palmas_ldo_volt[type][10]; + return 0; + } + + if (dev->driver_data > 0) { u8 idx = dev->driver_data - 1; uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][idx]; uc_pdata->volt_reg = palmas_ldo_volt[type][idx]; - } else { - /* check for ldoln and ldousb cases */ - if (!strcmp("ldoln", dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; - uc_pdata->volt_reg = palmas_ldo_volt[type][9]; - } else if (!strcmp("ldousb", dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; - uc_pdata->volt_reg = palmas_ldo_volt[type][10]; - } } return 0; -- 2.39.2