Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp697585rdb; Tue, 19 Sep 2023 07:43:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElJEGxmeyC9TgISjkuo3yiwnKot4DFvnzwjTCIXcva3fUpgS7ApJ+5HT4XNWLuBj602jZC X-Received: by 2002:a17:90b:b14:b0:271:c207:b285 with SMTP id bf20-20020a17090b0b1400b00271c207b285mr11340226pjb.9.1695134623185; Tue, 19 Sep 2023 07:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695134623; cv=none; d=google.com; s=arc-20160816; b=vVO/Xgn8Biwi69OZh4N5E0Xy2Jp8pItL9blMmZO4sDTu55jwbppglN9gcilNWp5P0Q 3iFz+8aZG8RIgnUwR9zXDRnkAFtXsunISRXZQNTNOk65wcwbQRKzyYVxrxOWq+8KqdgE rWXUfh3wwn3tPPotjFSpk2RV76QxnJhZjpRUAjromz5qImyi3omM9MqqKhUp0NKCWKvK RagUdIMsjY81fmAdJNE27HSD3a19rHPq/JiqZxFychJI/qzI4lLTwkAQeNRWb3oM79E8 k+XKg5E+BsLaR3wJDcYze5y7QiuQoVs90t5FFGkyy7rXasx4h9d5XNqjYFeRQ8Hih0KT wSIw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=rr0rzH364XaNlv4Ch4vJHddJ1dIwCer3aBMaygdxvC8=; fh=MgYOQmqCa+CdgaxlV56hi/NHE9IipXAKmdg1c8Tch7E=; b=h5wCN2vMNJwEU4GLwSpAWW7eqx7IWLo2JfVZUEfllFdbLxoEdAM8bAk1XY4sNsvxp5 VuTyKlcJTOlBC1QWr8xzcvytobU6BbdWBfHnKKXveOHK4QXpzuik+WadMFjcbTEz3nbi ErLXwi1IlAcLVxFPK6i41qcPdhDrqJrpYhJgcOc0odCZYp7sEF4aEOAIdej38yfNqjU4 ncVYSy0/0fmj95y8UXaG5iA8F3YHIwKWAd5fTYmCMySAePWRa+0g7Z8TGZJpD/iUI4a+ RD8B9odjz0uXrx3VZ6qaDaWMLPhgiSrF3+eeD5jkPw9U/tTznQSvWPQ55tb+fvA8EKsS UysA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id pg8-20020a17090b1e0800b0026343b62cdasi7713394pjb.154.2023.09.19.07.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:43:43 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BEBE18118760; Tue, 19 Sep 2023 07:29:44 -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 S232781AbjISO3U (ORCPT + 99 others); Tue, 19 Sep 2023 10:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232727AbjISO3T (ORCPT ); Tue, 19 Sep 2023 10:29:19 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF62BBC; Tue, 19 Sep 2023 07:29:12 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RqkWf14Jnz6HJh1; Tue, 19 Sep 2023 22:27:10 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 19 Sep 2023 15:29:09 +0100 Date: Tue, 19 Sep 2023 15:29:08 +0100 From: Jonathan Cameron To: Wadim Egorov CC: Jonathan Cameron , "lars@metafoo.de" , "robh@kernel.org" , "heiko@sntech.de" , "mugunthanvnm@ti.com" , "peter.ujfalusi@ti.com" , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "upstream@lists.phytec.de" , "nm@ti.com" Subject: Re: [PATCH] iio: adc: ti_am335x_adc: Make DMAs optional Message-ID: <20230919152908.000041be@Huawei.com> In-Reply-To: References: <20230914121300.845493-1-w.egorov@phytec.de> <20230917114552.3f5cd081@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=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 07:29:45 -0700 (PDT) On Tue, 19 Sep 2023 10:21:28 +0000 Wadim Egorov wrote: > Hi Jonathan, > > Am 17.09.23 um 12:45 schrieb Jonathan Cameron: > > On Thu, 14 Sep 2023 14:13:00 +0200 > > Wadim Egorov wrote: > > > >> DMAs are optional. Even if the DMA request is unsuccessfully, > >> the ADC can still work properly. > >> Make tiadc_request_dma() not fail if we do not provide dmas & > >> dma-names properties. > >> > >> This actually fixes the wrong error handling of the tiadc_request_dma() > >> result where the probing only failed if -EPROPE_DEFER was returned. > >> > >> Fixes: f438b9da75eb ("drivers: iio: ti_am335x_adc: add dma support") > >> > > No line break here. Fixes tag is part of the main tag block. > >> Signed-off-by: Wadim Egorov > > > >> --- > >> drivers/iio/adc/ti_am335x_adc.c | 7 +++++-- > >> 1 file changed, 5 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c > >> index 8db7a01cb5fb..e14aa9254ab1 100644 > >> --- a/drivers/iio/adc/ti_am335x_adc.c > >> +++ b/drivers/iio/adc/ti_am335x_adc.c > >> @@ -543,8 +543,11 @@ static int tiadc_request_dma(struct platform_device *pdev, > >> if (IS_ERR(dma->chan)) { > >> int ret = PTR_ERR(dma->chan); > >> > >> + if (ret != -ENODEV) > >> + return dev_err_probe(&pdev->dev, ret, > >> + "RX DMA channel request failed\n"); > >> dma->chan = NULL; > >> - return ret; > >> + return 0; > >> } > >> > >> /* RX buffer */ > >> @@ -670,7 +673,7 @@ static int tiadc_probe(struct platform_device *pdev) > >> platform_set_drvdata(pdev, indio_dev); > >> > >> err = tiadc_request_dma(pdev, adc_dev); > >> - if (err && err == -EPROBE_DEFER) > >> + if (err) > > So this looks like a more subtle change than you are describing. > > In the original code, we backed off only if the return was a PROBE_DEFER, otherwise > > we carried on. > > > > Your change seems to make that happen for any non -ENODEV error, including PROBE_DEFER. > > That's fine, but it's not what the description implies. > > > > Whilst tiadc_request_dma will fail today if the dmas etc is not provided, that seems > > like correct behavior to me. A function requesting dma fails if it isn't available. > > The handling of whether to carry on the job for the caller. > > That makes sense, yes. But stm32-adc is doing the same in its dma > request function. > So I assumed we can do it like that. > > > > > So I think it should just be > > if (err && err != -EINVAL) > > goto err_dma; > > We will end up failing if no dmas are configured because the request > returns -ENODEV. > So I think it needs to be a check for non -ENODEV. That makes sense. I wonder if a long time back that returned -EINVAL, hence the wrong value here. If you can do a bit of checking in the git history that would be good as it will change how far we backport this. > > > > > and no change in tiadc_request_dma() > > > > However, the case you describe should have worked find with existing code > > as it wasn't -EPROBE_DEFER, so I don't understand why you were looking at this > > code block in the first place? > > Providing wrong dmas in the device tree should've made the driver fail > to probe. Agreed, Thanks, Jonathan > > Regards, > Wadim > > > > > Jonathan > > > > > >> goto err_dma; > >> > >> return 0; > >