Message ID | 20230913082919.1631287-2-wenst@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp935398vqx; Wed, 13 Sep 2023 01:32:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5EP1jJHnVt9wbWN7mGT0Bf14QteRQYG5B0hxRconVlHluDEDva5d93KMuOXFDIw01AHjK X-Received: by 2002:a17:90a:c58a:b0:26d:1a46:1646 with SMTP id l10-20020a17090ac58a00b0026d1a461646mr1359956pjt.48.1694593963782; Wed, 13 Sep 2023 01:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694593963; cv=none; d=google.com; s=arc-20160816; b=jLD2hbl2ttsxjM1NfTJBReUw3GDsfeyBRGVMXrXVM0zD8kuZ76f7pns1mMsLYxNRLI YrKzlg2Np1UNcayxPtW/7I1steQ0gqfEwnTD/F9cqD63xBcaciO5Zi8ySP7/ZcqyRDzF hT+fuNWWmwg1A9EuPXx6W1wv6nRY77ONhTHf1r3SfNo4zLs+IqckMjQRAZPw7NGGzi7h lxUX+m4JvrvXRgj3nwPgNgNqz/Fq6dFybQFERscL0I6kSyPBHYSkTDhIYXqaEuCDoqCq F1eQAvLP4zxKprUEPMD1iM1yzlqa4OsrUVFVCvFgf35hUJiq51RGLxHEIfKvxBxlzzBz 8jNQ== 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=vVZVDk0nVt9xPkuQ7kA0rk+skb+IlHVfGj8ZHv+S3fY=; fh=wBVKhHxP+aiKKEc0CXv83BiJU0jx+njW2h0/fqvl19U=; b=V+sbHNyoeN+1q66Bit2fQd8uc+vJQybpQ8fyxe4wJfYDcWAAFaSqENQVFCy4C6qPD5 pAee4e2AgaTAudn8RGCiORQ0HBPi7x3pdetFHX0y7FU4cIdyQ3nAQZ7OjzH+sPHnbRJJ G+QzPEJ7SnLTXXxRyKlu2Y/5FffFwY+5lNEMU38ilMLFYK7hQeYy3LGTeCaVgxX8d/Jm zMn7XPOP2jvuFhEdCuL5E6pLQlXwRqHgZr8jyYaVH/VaXNek5V20mwB0UuoZVN4goym8 1Fa3tVGmxdv4a8jPSMqLn1COth6RY3nB5JMliot8ioLqVJ6Vg28hbXKRbsDkfFd4NkQI msgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="jKa3B/dH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id om15-20020a17090b3a8f00b0025eeb3cc4b2si491002pjb.9.2023.09.13.01.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 01:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="jKa3B/dH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 934A78260FB0; Wed, 13 Sep 2023 01:29:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238889AbjIMI3l (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 04:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjIMI3j (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 04:29:39 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38DE10E6 for <linux-kernel@vger.kernel.org>; Wed, 13 Sep 2023 01:29:35 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fe2470d81so1896919b3a.1 for <linux-kernel@vger.kernel.org>; Wed, 13 Sep 2023 01:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694593775; x=1695198575; darn=vger.kernel.org; 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=vVZVDk0nVt9xPkuQ7kA0rk+skb+IlHVfGj8ZHv+S3fY=; b=jKa3B/dHMq6nA0fizblnER5n4wbGN2DVUwzxpgOii3l3AF7Q6J015p2ZF8kubTr+U6 QF6h7CGGfm3SmBCfTl5/V4j+CtF0fVlqbOhGUQTd9O+C45qQmyyXbAoQKAXLZXpIsmgm SAqcjJdH7RGhv5QoLHgUL9Ss8ytBHCDoSf9l8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694593775; x=1695198575; 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=vVZVDk0nVt9xPkuQ7kA0rk+skb+IlHVfGj8ZHv+S3fY=; b=ohYm1+9gHv2akA74LyqhCKipf9ExO9lcVz+Oe3y5wxbLIUQ9nrWL5n7CWvhW+OVRTT qNZ+PNgWaQKYE4ikrkbW2aakgyWUr0cbIv4CbzL5++YZ2k2RfGRPf4tPRJwX7cUjZwLo VsflEa2irhHiKB2DiZDjANYHta/tlbZSw/gUzMKdFLAIOWJFiBwJ4sJVzCa209eq1TKx W3amqqXSl0QEQX9hV/s++HUpzQO+JpqV+SUvCpXRSbsxFTNw5Ygu7nYzqEL/iLQf9XqC iFdS675pTZDc8ZNqkZ4PTVm4Nr23IrO6/D3EQ7kvjdjaEADeYVJTIiDO5EEv7lz6q+Ds +OUQ== X-Gm-Message-State: AOJu0YzpWuXzUrLaXqAEe8S3YJa8hxWklRspkDCr2X6VdiOaXHanLGIV BbhKQCnHZrudvEDJVmitTDDStA== X-Received: by 2002:a05:6a20:2444:b0:134:30a8:9df5 with SMTP id t4-20020a056a20244400b0013430a89df5mr2039361pzc.43.1694593775198; Wed, 13 Sep 2023 01:29:35 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:b24c:3be4:d952:d3b1]) by smtp.gmail.com with ESMTPSA id g6-20020aa78746000000b006901bd3a9e4sm418781pfo.104.2023.09.13.01.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 01:29:34 -0700 (PDT) From: Chen-Yu Tsai <wenst@chromium.org> To: Lee Jones <lee@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Mark Brown <broonie@kernel.org> Cc: Chen-Yu Tsai <wenst@chromium.org>, Zhiyong Tao <zhiyong.tao@mediatek.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 1/3] regulator: mt6358: Fail probe on unknown chip ID Date: Wed, 13 Sep 2023 16:29:16 +0800 Message-ID: <20230913082919.1631287-2-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230913082919.1631287-1-wenst@chromium.org> References: <20230913082919.1631287-1-wenst@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 01:29:52 -0700 (PDT) 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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776910560216227802 X-GMAIL-MSGID: 1776910560216227802 |
Series |
regulator: mt6358: Remove bogus regulators and improvements
|
|
Commit Message
Chen-Yu Tsai
Sept. 13, 2023, 8:29 a.m. UTC
The MT6358 and MT6366 PMICs, and likely many others from MediaTek, have a chip ID register, making the chip semi-discoverable. The driver currently supports two PMICs and expects to be probed on one or the other. It does not account for incorrect mfd driver entries or device trees. While these should not happen, if they do, it could be catastrophic for the device. The driver should be sure the hardware is what it expects. Make the driver fail to probe if the chip ID presented is not a known one. Suggested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Fixes: f0e3c6261af1 ("regulator: mt6366: Add support for MT6366 regulator") Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/regulator/mt6358-regulator.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt6358-regulator.c index 120c60d40ed4..935c7ad56c7e 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -682,12 +682,18 @@ static int mt6358_regulator_probe(struct platform_device *pdev) const struct mt6358_regulator_info *mt6358_info; int i, max_regulator, ret; - if (mt6397->chip_id == MT6366_CHIP_ID) { - max_regulator = MT6366_MAX_REGULATOR; - mt6358_info = mt6366_regulators; - } else { + switch (mt6397->chip_id) { + case MT6358_CHIP_ID: max_regulator = MT6358_MAX_REGULATOR; mt6358_info = mt6358_regulators; + break; + case MT6366_CHIP_ID: + max_regulator = MT6366_MAX_REGULATOR; + mt6358_info = mt6366_regulators; + break; + default: + dev_err(&pdev->dev, "unsupported chip ID: %d\n", mt6397->chip_id); + return -EINVAL; } ret = mt6358_sync_vcn33_setting(&pdev->dev);