Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3718415pxv; Mon, 26 Jul 2021 10:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxA5vz4xITRWeas/CmFy6SQ3GT3p3SoYrJixiQOcV7zrNBuCjbkZ4JO9cd77e65my4Dr9Q X-Received: by 2002:a02:cf2e:: with SMTP id s14mr10746622jar.74.1627319361822; Mon, 26 Jul 2021 10:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319361; cv=none; d=google.com; s=arc-20160816; b=ztRrVlVyIVPNp/RE6DqiTk6tbb6ijqG4kCur06BvHlEgV9OdWPuCTZu0g2BVNIxlMX S1ZFhsb3RHC0NepxxTG24guK9BwqN9nSlVI+dDO0pOQ0FiuLG1Vk1tWlaIRfrdzHpZjY y41dLQd7/+La0G8YsWSsyCRsldt3JMalTn51AAgkmV9AQW/yhJkXb389qC5ekPikJCKr tkiU4iyINQAdldZCBKsnLFaMTGEDqKHxJg3kCkWjthhPyXHb0tUYHMoo7Lp0BXZPXUxW RWETw2CB7PvCkERZrbhRgMpb+nlho8Y1IuQRu1t9NqaaN/XMS3jaRB/oG4cwpvRyXKFf F14A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iqrJ6g35pjAMKHds6ASaGeRdmTCxwzBkJYY0nS3TuLI=; b=oqXTvD7mb12NuP3xn3dQPFI+HxtcCHSv/HYz2qlGOW69wMbVyt3W4iOfKKjaPm/L3T f0ifcOxk1H1iVNoM1Cg55diBoNB5zb+jG37YGIMwcDfP1ZjA+5QEpSxOsG0a+RH916U1 LSuu9DLJU3tuI3LY8jryd7NEBVAOjwer/4akSrScu3jF325iZ8iVppSgJ4IQ2YCBg7Pj Qe3TsZmlzFR8g1HJdp6IaW9/NTmUQp3dZqQ1GPFE/4Kw8Tt9hkEVoQEaUFhH0Nj+GhBW uvvTBmlhGXGw93aBhSdKBrCA55633HktbdwHYdXn1oiJWojd9lASCzqutSD5O1l3jdFR biPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TtJlFcPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si420152ilu.53.2021.07.26.10.09.09; Mon, 26 Jul 2021 10:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TtJlFcPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239027AbhGZPtC (ORCPT + 99 others); Mon, 26 Jul 2021 11:49:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:45420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232041AbhGZPaL (ORCPT ); Mon, 26 Jul 2021 11:30:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DB1C60F5E; Mon, 26 Jul 2021 16:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315839; bh=u+nrYs8kgIxkE78GC04cHDkkMC7HisEe6KV2i+EgDj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TtJlFcPjoKYNtz0yLGZ1TqzUO7STcUwiklu8laJbIFPa07sq9r3sCrhLCMhhpIIXk hEXfMTFQiiplolaKEY3DwAHMt5QocBOdsj293Mphi8vWfW0D+it/XCMEoALF1wWxXv RuKU9N7A5L/hVLznOXmYJvMEaeBh4K0Wl32IU5lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.13 070/223] regulator: hi6421: Fix getting wrong drvdata Date: Mon, 26 Jul 2021 17:37:42 +0200 Message-Id: <20210726153848.545127465@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin [ Upstream commit 1c73daee4bf30ccdff5e86dc400daa6f74735da5 ] Since config.dev = pdev->dev.parent in current code, so dev_get_drvdata(rdev->dev.parent) call in hi6421_regulator_enable returns the drvdata of the mfd device rather than the regulator. Fix it. This was broken while converting to use simplified DT parsing because the config.dev changed from pdev->dev to pdev->dev.parent for parsing the parent's of_node. Fixes: 29dc269a85ef ("regulator: hi6421: Convert to use simplified DT parsing") Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20210630095959.2411543-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/hi6421-regulator.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/hi6421-regulator.c b/drivers/regulator/hi6421-regulator.c index bff8c515dcde..d144a4bdb76d 100644 --- a/drivers/regulator/hi6421-regulator.c +++ b/drivers/regulator/hi6421-regulator.c @@ -366,9 +366,8 @@ static struct hi6421_regulator_info static int hi6421_regulator_enable(struct regulator_dev *rdev) { - struct hi6421_regulator_pdata *pdata; + struct hi6421_regulator_pdata *pdata = rdev_get_drvdata(rdev); - pdata = dev_get_drvdata(rdev->dev.parent); /* hi6421 spec requires regulator enablement must be serialized: * - Because when BUCK, LDO switching from off to on, it will have * a huge instantaneous current; so you can not turn on two or @@ -385,9 +384,10 @@ static int hi6421_regulator_enable(struct regulator_dev *rdev) static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev) { - struct hi6421_regulator_info *info = rdev_get_drvdata(rdev); + struct hi6421_regulator_info *info; unsigned int reg_val; + info = container_of(rdev->desc, struct hi6421_regulator_info, desc); regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val); if (reg_val & info->mode_mask) return REGULATOR_MODE_IDLE; @@ -397,9 +397,10 @@ static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev) static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev) { - struct hi6421_regulator_info *info = rdev_get_drvdata(rdev); + struct hi6421_regulator_info *info; unsigned int reg_val; + info = container_of(rdev->desc, struct hi6421_regulator_info, desc); regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val); if (reg_val & info->mode_mask) return REGULATOR_MODE_STANDBY; @@ -410,9 +411,10 @@ static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev) static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev, unsigned int mode) { - struct hi6421_regulator_info *info = rdev_get_drvdata(rdev); + struct hi6421_regulator_info *info; unsigned int new_mode; + info = container_of(rdev->desc, struct hi6421_regulator_info, desc); switch (mode) { case REGULATOR_MODE_NORMAL: new_mode = 0; @@ -434,9 +436,10 @@ static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev, static int hi6421_regulator_buck_set_mode(struct regulator_dev *rdev, unsigned int mode) { - struct hi6421_regulator_info *info = rdev_get_drvdata(rdev); + struct hi6421_regulator_info *info; unsigned int new_mode; + info = container_of(rdev->desc, struct hi6421_regulator_info, desc); switch (mode) { case REGULATOR_MODE_NORMAL: new_mode = 0; @@ -459,7 +462,9 @@ static unsigned int hi6421_regulator_ldo_get_optimum_mode(struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA) { - struct hi6421_regulator_info *info = rdev_get_drvdata(rdev); + struct hi6421_regulator_info *info; + + info = container_of(rdev->desc, struct hi6421_regulator_info, desc); if (load_uA > info->eco_microamp) return REGULATOR_MODE_NORMAL; @@ -543,14 +548,13 @@ static int hi6421_regulator_probe(struct platform_device *pdev) if (!pdata) return -ENOMEM; mutex_init(&pdata->lock); - platform_set_drvdata(pdev, pdata); for (i = 0; i < ARRAY_SIZE(hi6421_regulator_info); i++) { /* assign per-regulator data */ info = &hi6421_regulator_info[i]; config.dev = pdev->dev.parent; - config.driver_data = info; + config.driver_data = pdata; config.regmap = pmic->regmap; rdev = devm_regulator_register(&pdev->dev, &info->desc, -- 2.30.2