Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp844112pxb; Fri, 22 Apr 2022 12:24:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVViYI0jLJekSgVy+b4UOFaQM2kQVvmzkQsLiYs0mGCLvRlnfq4xI06Ul5+QWlDyjlm5Wf X-Received: by 2002:a62:a504:0:b0:50a:ceee:5f4 with SMTP id v4-20020a62a504000000b0050aceee05f4mr6575531pfm.13.1650655451784; Fri, 22 Apr 2022 12:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650655451; cv=none; d=google.com; s=arc-20160816; b=YoAEDNtGb/AirxD1YN71hpJs8ICWtfl6Jn9RQYG2ITZPfgPKAH7gUdVkkjCnwZfwA7 qO6Cut5naEni9VSPITx8Ne0MIU5MvsBLSLwnQVN8WAAKe8WoHg0dPEt+vHfl7y2AiRzC 3qlBK6EYVoLXthaMHcC6srcN/O7Wfs7dQJ2sotuFzr4459/BY1W7p/ECqqzh9/cLPjQu xuoB+wnYWpZv4j+UL4CFRNFtkF/pcF0UG7wim3N2fOIVtnMND/DeZzQQZOn4938kYeJ0 o9mQNFPmnvJfTfsSE/H2KBEYC6JbX9U9Fh1hu0D6fJ4m35VX4zQCsSJ+NUiKNMVko0Re iLNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zZKj1C/7IWF1iYJGVivOJHvLTfKPwwnbxFO7kqmcYXc=; b=1JciYDBqjlrvhtsDTNvbNR5CVc3MsZC42IcpBCXtCO0JGroK+BCv3Pe3Lkl7v5ieG3 cWiqOVKT64PSgSmwH97kl6V65EyHxgWClWfoZszCmzQ6mkzlqJR7ifktnUr63Vb98FDn tEEsGcHXRqHN99BbEmcRw0CbDNifPBOuQZLs2LaeHOLVwnGmX8/L7PgmpEQbGvkHt5xz 4x+Z7lVEtY/ayBe7Rh8O2P/jQ5JR9la/honURbUIG56l+eYhtm2lAZ63gJstzrs3I9nB XZccK4Wd8eSWQ5/QKJXX9L70S3jhFkie6Yc7EEP0asmwi55d252zcHUIAQDFCFzGlCr4 e7HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VVH2HU+P; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c7-20020a056a000ac700b004fa3a8dff62si9350718pfl.25.2022.04.22.12.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:24:11 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VVH2HU+P; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 20E931C9CC1; Fri, 22 Apr 2022 11:36:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388950AbiDUOLL (ORCPT + 99 others); Thu, 21 Apr 2022 10:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388967AbiDUOK5 (ORCPT ); Thu, 21 Apr 2022 10:10:57 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B6AC3B00C for ; Thu, 21 Apr 2022 07:08:07 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id bu29so8979698lfb.0 for ; Thu, 21 Apr 2022 07:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zZKj1C/7IWF1iYJGVivOJHvLTfKPwwnbxFO7kqmcYXc=; b=VVH2HU+P5/bdjm7H3wzAdQ7BcWbgJCF7v1P82ysb8AVZD3iccsTHzkFCl8Y/gMyyBl qPbuNS8l4NofUrpKlHZ8maQ+cDnVSeKdOdR57Eujj79fMAkNWAmnuY3kE0AC86rXN3uj eTSAqUDNMsVZoAtc1ZBbeRlRtzOT+2rF/wZlnYOzxRmj/AIQgvBrba3TaAG6t90YVqI/ P+rI4f1hCrPlbWZP2vjCOsIxACq1zH/0UT1K8dXDNPHGBGqFC1w1DuiP1icoaXrBNjyS ERYqfURAbUs0JEAKRxF8EMGd5dNnQJcLngybujXSNP9rgYZ4jIudsK8WAbSPXmjjKaWx y9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zZKj1C/7IWF1iYJGVivOJHvLTfKPwwnbxFO7kqmcYXc=; b=i23wpzHp4c2NGWXNbqbhZQbP1F7Kq2QwzNEKj6ExTo7NqthNELmepGhsppKydqWT8U yRJBSwpAlTBEPnuU8RCKfWDrNAhiCNpWPMhy2LHn8C90yS+4DzrkL/G7rVLf4zCalqZS nOGECcjlHIzWj/k8GTfwasYplg5vOkUj0UPh4if82LHJkksSTUlvhimFISARBZd24lMH 0uqwSPWrIv3B/38l6mKvRsO02IUCGgUlH/3x6x+nNq4GxTRbp7IRHg0JnVJzPprk9y9i hpktP4SLFX17pCM6StzdxdD0weZPXFxzoJlfnqCOaZ+6sHUFH4BBDEd3/mJ2uR82g+jU JBWg== X-Gm-Message-State: AOAM530Qo1J0qEVGBawOR3PXcKo47YQ24JKju5zvcvW7SoMqwAUAXas2 7y7dhuzdtuQYEZbTJPqCybliKIix2zt620+6nNyCEw== X-Received: by 2002:a05:6512:c12:b0:471:a932:cfe1 with SMTP id z18-20020a0565120c1200b00471a932cfe1mr9020055lfu.358.1650550085053; Thu, 21 Apr 2022 07:08:05 -0700 (PDT) MIME-Version: 1.0 References: <20220409034849.3717231-1-zheyuma97@gmail.com> <20220410165425.6c2f60e7@jic23-huawei> In-Reply-To: From: Ulf Hansson Date: Thu, 21 Apr 2022 16:07:28 +0200 Message-ID: Subject: Re: [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe() To: Linus Walleij Cc: Jonathan Cameron , Zheyu Ma , lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 On Thu, 21 Apr 2022 at 01:14, Linus Walleij wrote: > > On Sun, Apr 10, 2022 at 5:46 PM Jonathan Cameron wrote: > > On Sat, 9 Apr 2022 11:48:48 +0800 > > Zheyu Ma wrote: > > > > > When the driver fail at devm_regmap_init_i2c(), we will get the > > > following splat: > > > > > > [ 106.797388] WARNING: CPU: 4 PID: 413 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0 > > > [ 106.802183] RIP: 0010:_regulator_put+0x3ec/0x4e0 > > > [ 106.811237] Call Trace: > > > [ 106.811515] > > > [ 106.811695] regulator_bulk_free+0x82/0xe0 > > > [ 106.812032] devres_release_group+0x319/0x3d0 > > > [ 106.812425] i2c_device_probe+0x766/0x940 > > > > > > Fix this by disabling the regulators at the error path. > > > > > > Signed-off-by: Zheyu Ma > > + CC Linus W as it's his driver. > > > > Fix looks correct to me, though the handling of runtime pm in here is > > probably more complex than it needs to be (and hence this odd error > > handling for this one place in the probe). > > At the time I discussed how to do runtime pm with Ulf Hansson a lot > and I think it was the state of the art at that time. It might have > changed since. It still looks good to me. One could switch the order of the calls to pm_runtime_disable() and pm_runtime_put_noidle(), but it's not a big thing. Whether it looks complicated or not, that's a different story. :-) Note that some drivers are always being built with CONFIG_PM being set, which allows some simplifications. Although, I don't think that's the case here, right? > > > > --- > > > drivers/iio/magnetometer/ak8974.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c > > > index e54feacfb980..84bbf7ccc887 100644 > > > --- a/drivers/iio/magnetometer/ak8974.c > > > +++ b/drivers/iio/magnetometer/ak8974.c > > > @@ -862,6 +862,7 @@ static int ak8974_probe(struct i2c_client *i2c, > > > dev_err(&i2c->dev, "failed to allocate register map\n"); > > > pm_runtime_put_noidle(&i2c->dev); > > > pm_runtime_disable(&i2c->dev); > > > + regulator_bulk_disable(ARRAY_SIZE(ak8974->regs), ak8974->regs); > > Reviewed-by: Linus Walleij > > Yours, > Linus Walleij Kind regards Uffe