From patchwork Tue Sep 19 08:36:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 141843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3330768vqi; Tue, 19 Sep 2023 05:05:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqosmSbPixlF8fPlVlbwCRO3iX9UNjAT+kU55Y90x5FfPbxhYe8njrb6tHEpzeYlTNfq4t X-Received: by 2002:a17:902:cec2:b0:1b7:e49f:1d with SMTP id d2-20020a170902cec200b001b7e49f001dmr11592515plg.62.1695125119118; Tue, 19 Sep 2023 05:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695125119; cv=none; d=google.com; s=arc-20160816; b=dK6ACjkQBpYY0VXOtzbRagVUNSmonnn412Wgnp/LZ2KdU6kHaLkgfA8Oodef61ni6X jCm70z4gLaO8ikDC6wHL0ZJ7psca9iriEZwc4azHhG0loDTCEEif7UD17MPIQqGvs18x 1y+PNe5vlw28/Q5lXZHfk3bAStFuGIYaUmQFz9Fk4MxYRiDyszzOoqya3hbw2MNRYWXB cRi3loeLMWpchv9vw8H/tHIVTPSoJe0Hrg1E2GgUAI9WQH78UK4J+VFg/I6J6FDSON88 x2YmZNkkp/VigWBvR35Rghth0XpGjl2sdFE3vRLCODD6rq428jrRrRXzkhx09InXHM1V 23YA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AFgJ89zcFrRudWbk8kdaUIQLDil/i3wCbCwtmAyU7YI=; fh=Se/5zvXBdFaEBLHb+6jyWgjsseQl8o612ReIXrH5HYo=; b=gTu+jvmEKMni5m2bX8TTFlv1QOhpxo7U17Z+LKe3MjmXiD+t+1rjGVJ3yqfX3dZTO6 kOaH3Rk6aRuXr899cAWoO8zixgLYkwUfRUFzkBjjBdNJvYbfeU4vC66l5QdUHqvM0ekt zVnyL7jaJ5nG6GJ3Or5woVYYlI9nNcq9nYM+0Ian5dc642PqXn0m0jvAI1AjQSj3zwJo T5ErSI+otGDKgGR3mXymnhbED0Xqbovxc5we9xiWwapUfXxjBIDuWvLNHIu8Ok0Cg2h9 j6juH6t66vdJw4dpkchyuTcglJLK3jgGPQ04qd3FfTsKfKCNSJebKsrBgUbF4Ak/XlmO 07XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=im6qbHu+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y2-20020a17090264c200b001c45c05c3d9si5422743pli.182.2023.09.19.05.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 05:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=im6qbHu+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9A4A081F34D0; Tue, 19 Sep 2023 01:37:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbjISIg7 (ORCPT + 26 others); Tue, 19 Sep 2023 04:36:59 -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-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 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 01:37:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777467517137242733 X-GMAIL-MSGID: 1777467517137242733 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/mt6358-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_dev *rdev, const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int val; + if (!info->modeset_mask) + return -EINVAL; + switch (mode) { case REGULATOR_MODE_FAST: val = MT6358_BUCK_MODE_FORCE_PWM; @@ -433,6 +436,9 @@ static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int ret, regval; + if (!info->modeset_mask) + return -EINVAL; + ret = regmap_read(rdev->regmap, info->modeset_reg, ®val); if (ret != 0) { dev_err(&rdev->dev,