From nobody Fri Sep 20 09:58:42 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5DB0CD54A8 for ; Tue, 19 Sep 2023 08:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbjISIhA (ORCPT ); Tue, 19 Sep 2023 04:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjISIg6 (ORCPT ); Tue, 19 Sep 2023 04:36:58 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E89102 for ; Tue, 19 Sep 2023 01:36:53 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c4194f769fso38405875ad.3 for ; Tue, 19 Sep 2023 01:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695112613; x=1695717413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AFgJ89zcFrRudWbk8kdaUIQLDil/i3wCbCwtmAyU7YI=; b=im6qbHu+ssbrtA4uYEaEV2pz40GiuDaR8fB1qyEYRDpZEfqsq564ss/RYHeRVzsuxU tcuWzJpwCJKUS2uHCk2Y2nRiwMTMUSfvHU6tEbzfC8COu0KWP6PhETg51Zr9ZB8S3G5a 8yFOzrJRpR/jEP09PDe6XMXNGnp/AGwweaX58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695112613; x=1695717413; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AFgJ89zcFrRudWbk8kdaUIQLDil/i3wCbCwtmAyU7YI=; b=ryq8qUcgr18NqqaI87GbjGjzMWQPlEDKDE40QS4m4BwosRIOka9vNaa22IB8bKPtFM zhDuBwA3MKR9k/YJ/5A2+WkALr4tOiYYipv84Jp0ANF9JJRd+4AcIuIGelZ7WMRF1Ngm tRy/UylBYKJufMsu6opTzulI5eceLKCFRMf0J8jfmc97F1LYjYyEkINonGrPiG9SM5+7 x4+SHASHqfZcj0QKk+ARk1619sjCbuuLRZnKULpKglrYdNOdLMzdrE8tkk3cJeoQDDgF 79bIIh+VbDgdUupiYOVtCitkBAKl6/bRAA129f07t514tanJWBTuIGIrZpySfM7HHVNZ Dm7A== X-Gm-Message-State: AOJu0Yxgp8k+N9U1VAvyy6e6DhUeBacFPP6rkfjs/J9i4uII5aBPkGDL BiI5p02vxSmJiQOlIaV0p/qhbwZI36+Hx5E8kUo= X-Google-Smtp-Source: AGHT+IGUM8ymdxjj4POLq8H28T5j0ptbAtl7ppCRBLRUAtI5mr/Ss0hb0+yr4ezvyyOGjEHgf0CnDw== X-Received: by 2002:a17:90a:e547:b0:268:1355:b03e with SMTP id ei7-20020a17090ae54700b002681355b03emr9292692pjb.38.1695112612649; Tue, 19 Sep 2023 01:36:52 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:40a:900d:e731:5a43]) by smtp.gmail.com with ESMTPSA id n20-20020a17090ade9400b00274b018489asm5508204pjv.1.2023.09.19.01.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:36:52 -0700 (PDT) From: Chen-Yu Tsai To: Matthias Brugger , AngeloGioacchino Del Regno , Mark Brown Cc: Chen-Yu Tsai , Zhiyong Tao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] regulator: mt6358: return error for get/set mode op on linear range LDO Date: Tue, 19 Sep 2023 16:36:46 +0800 Message-ID: <20230919083647.3909889-1-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The buck and linear range (VSRAM_*) regulators share one set of ops. This set includes support for get/set mode. However this only makes sense for buck regulators, not LDOs. The callbacks were not checking whether the register offset and/or mask for mode setting was valid or not. This ends up making the kernel report "normal" mode operation for the LDOs. Instead, make the callbacks return -EINVAL if the mode register mask is not set, signaling that it is not supported. Fixes: f67ff1bd58f0 ("regulator: mt6358: Add support for MT6358 regulator") Signed-off-by: Chen-Yu Tsai --- drivers/regulator/mt6358-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt635= 8-regulator.c index b9cda2210c33..120c60d40ed4 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -408,6 +408,9 @@ static int mt6358_regulator_set_mode(struct regulator_d= ev *rdev, const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int val; =20 + if (!info->modeset_mask) + return -EINVAL; + switch (mode) { case REGULATOR_MODE_FAST: val =3D MT6358_BUCK_MODE_FORCE_PWM; @@ -433,6 +436,9 @@ static unsigned int mt6358_regulator_get_mode(struct re= gulator_dev *rdev) const struct mt6358_regulator_info *info =3D to_regulator_info(rdev->desc= ); int ret, regval; =20 + if (!info->modeset_mask) + return -EINVAL; + ret =3D regmap_read(rdev->regmap, info->modeset_reg, ®val); if (ret !=3D 0) { dev_err(&rdev->dev, --=20 2.42.0.459.ge4e396fd5e-goog