From patchwork Fri Jun 16 02:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: ChiYuan Huang X-Patchwork-Id: 108801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1059908vqr; Thu, 15 Jun 2023 20:17:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51tZsXQMYmRXU+HKB5yFdBleKZ/MPe5HKkVZCloX0p6E4+j+VhZkOzYSVjs3JDSxH/cIiX X-Received: by 2002:a05:6359:588:b0:125:6f8e:67e9 with SMTP id ee8-20020a056359058800b001256f8e67e9mr498802rwb.18.1686885444133; Thu, 15 Jun 2023 20:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686885444; cv=none; d=google.com; s=arc-20160816; b=YwogfKnV/QK2d13WavrGBzrr/Ph1NsZWSM2RpqIJyd69gMT+r+JgiUkO5pLrASXH3S AValROjVqcxolAg992vzVEzgefCU1KTSA0HufLqpmYrEkxvcFOgfq1gDKy56y22pw9I8 zfFCz9kiV3gw7ylqBM2gLV0I/2RWKJc43G0eXRzIKNlTJnJSKfTVcJaGcdr5AxVzIy5e KU/Hw+BD244AixtwONtlZ3QFzXbj/kYylFIKLrImkqzrgWU6hzxL17p24Hb/Eq8C2GZx le2+r1dB/9emy6Zg7l8/rgDzIHpuiLBhrKvnsUrKGkAHaGrx33evdLXpzNgKX9O9QkW+ Ifzg== 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; bh=OOyre36V7vvtLhF1SHuNQgBPHRm5V532iqUDH5GVF/c=; b=pTGHSjpeQ1d7mrl2lPn+/P1XPv3kAqw7w7EpalIbtSg4m/ZfEQSxlENdLW01dcvnhK 9vdBRXiVRtdv8WD8M1UufjMdxA15pFnid//2jUMPiiixbhtWaD/bECQTxVxwO8sMJiNa RJ2sVN20j8fGDshPfzoRx+A6xOLOuAf9jDavN/Rp1iffQ7kJlqPWgqNgZljIJp7S4ViD rz3ZBxNjOYAvG8lMUgBQk6Kw2kpZgGhgnMfM49z+X99Ao8qhqU/Y4kYYdvkfOOWiYNmW g5OvFsp9c0PBsHIrfT9lzsqiO6zcEXgKwFcF+ZVddtb2yGTAYTLKrhkw3BaRs28u0zH/ 2eWw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p37-20020a635b25000000b00550e8b3614asi1981459pgb.901.2023.06.15.20.17.11; Thu, 15 Jun 2023 20:17:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238338AbjFPC7p (ORCPT + 99 others); Thu, 15 Jun 2023 22:59:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjFPC7o (ORCPT ); Thu, 15 Jun 2023 22:59:44 -0400 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 648252953; Thu, 15 Jun 2023 19:59:41 -0700 (PDT) X-MailGates: (flag:4,DYNAMIC,BADHELO,RELAY,NOHOST:PASS)(compute_score:DE LIVER,40,3) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTP Server V5.0(18395:0:AUTH_RELAY) (envelope-from ); Fri, 16 Jun 2023 10:59:25 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Fri, 16 Jun 2023 10:59:25 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Fri, 16 Jun 2023 10:59:25 +0800 From: To: CC: , , , , , ChiYuan Huang Subject: [PATCH] regulator: tps65219: Fix pointer assignment in tps65219_get_rdev_by_name() Date: Fri, 16 Jun 2023 10:59:24 +0800 Message-ID: <1686884364-31447-1-git-send-email-cy_huang@richtek.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768827590974625833?= X-GMAIL-MSGID: =?utf-8?q?1768827590974625833?= From: ChiYuan Huang For the pointer assignment in function body, double pointer must be used as the input parameter. Fixes: c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support") Signed-off-by: ChiYuan Huang --- Hi, I try to fix W=1 build warning for tps65219-regulator. W=1 warning: parameter ‘dev’ set but not used [-Wunused-but-set-parameter] struct regulator_dev *dev) ^~~~~ But the issue is not what the warning message described. In tps65219_get_rdev_by_name(), it must return the found rdev and assign it in 'dev' pointer. Due to pointer assignment issue, it doesn't. The original code may not cause any problem. But it always takes the last registered regulator rdev for all tps65219 regulator interrupts. --- drivers/regulator/tps65219-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/tps65219-regulator.c b/drivers/regulator/tps65219-regulator.c index b1719ee990ab..8971b507a79a 100644 --- a/drivers/regulator/tps65219-regulator.c +++ b/drivers/regulator/tps65219-regulator.c @@ -289,13 +289,13 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data) static int tps65219_get_rdev_by_name(const char *regulator_name, struct regulator_dev *rdevtbl[7], - struct regulator_dev *dev) + struct regulator_dev **dev) { int i; for (i = 0; i < ARRAY_SIZE(regulators); i++) { if (strcmp(regulator_name, regulators[i].name) == 0) { - dev = rdevtbl[i]; + *dev = rdevtbl[i]; return 0; } } @@ -348,7 +348,7 @@ static int tps65219_regulator_probe(struct platform_device *pdev) irq_data[i].dev = tps->dev; irq_data[i].type = irq_type; - tps65219_get_rdev_by_name(irq_type->regulator_name, rdevtbl, rdev); + tps65219_get_rdev_by_name(irq_type->regulator_name, rdevtbl, &rdev); if (IS_ERR(rdev)) { dev_err(tps->dev, "Failed to get rdev for %s\n", irq_type->regulator_name);