From patchwork Tue Nov 15 10:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier MOYSAN X-Patchwork-Id: 20296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2639480wru; Tue, 15 Nov 2022 02:38:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hm4qS33b6+wSDdCh2Lj23T4cQUFHnANj891n6wbz7viwifyfgY3SxPbCXhe8mVe8ty+Jj X-Received: by 2002:a63:1c09:0:b0:42a:9ba8:8c6b with SMTP id c9-20020a631c09000000b0042a9ba88c6bmr15422419pgc.407.1668508734632; Tue, 15 Nov 2022 02:38:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668508734; cv=none; d=google.com; s=arc-20160816; b=s4hWToOwCsEA4OY9oEQ+hGzvZmjutFindt1SDBweMFsuFPCkzqgyp8JjFQcLd2DvwQ 2zjXqBDGEhtpdnqQuj+oO2gCvQAuSm8pmWUjmIOcEOMdcemCO2+j/xwtFximdplwucjs anCkTxxkjIkdh8oks1e/OG+yUG0AvpI4Wd6r0lz+VBepoJkuXhRp0b4KkrPmmA8DzTLN 3OeiXhEghhKqAoR0FdbQaRZandkKz8gRBEKlvCF7QFjxZLRqST9nMrOPrvJUvDuF+aSv +a3h+ESpH+iDgWddDY8B+rUFm7jxSH8PlmR7XzTxhdpbaxBe6DQwK0IE/1PhWfE4LRoH Fqcw== 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=hIRd56RJEPsYoe2M/RxriY/Cri8HJyV+94pW088mtLc=; b=Ko5agxAsNs/2l3SDekGyhU1wjzJrivlpxM0BabinBYyd7/YkcsqAdEu/gmqQU/Gf/s n2xf5rpinapOwbMa+Uaf097tio6a9fgczDd45+3wlO0n7AW/7CAEA/cm+1RTXO8SlOjU L8t//G46nLWzTaKmQvCMjphIiUB0QDrTy4TUBNnXJ0BZU58ugEY5wbR9nUc/SpvSxKU4 D/Bo4BWwE61zE7siRi8ITMDfT7NwUjIrPnIkQQm0TUiKZTfhlGqxgVuF+HCj/DQoNznc LtyWTrooKh+TDaZip/cnUx2fm9h55smb3hawhY5M89lePSeP/4SDYiifP6dM7vqqpQC2 kY7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=GiP3oC2I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik26-20020a170902ab1a00b00186bb4a081csi11214989plb.393.2022.11.15.02.38.41; Tue, 15 Nov 2022 02:38:54 -0800 (PST) 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; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=GiP3oC2I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbiKOKfN (ORCPT + 99 others); Tue, 15 Nov 2022 05:35:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238338AbiKOKfF (ORCPT ); Tue, 15 Nov 2022 05:35:05 -0500 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7532D7653; Tue, 15 Nov 2022 02:35:02 -0800 (PST) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AFA98s2007401; Tue, 15 Nov 2022 11:34:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=hIRd56RJEPsYoe2M/RxriY/Cri8HJyV+94pW088mtLc=; b=GiP3oC2Ij8aYXoCYqNIF4asqEr9kzlst//gEGyr1+H54Q/lHFDyqsCZ8GxTNiUdGpjf4 q22kay7Tq7Es+N5nl47k7ojvc5qeFSrZs08Awz3rpJONuR77MpG7VowseCUIo9evu4Jb FtEcgEdwsYviknqUJqDYTDNN+EbToZMKebztniKXkslrXYd56Iz/mTjQKsnolMzmvwGM qFVldb+LHcnuPmeAedF0mVUHvsx3rBafQRN9EePjWf4BIcvtgM/fwUgonQ/hgpSYUlrx QnW228kKFtsJ5IPh3WjER6F5N5kcmbwM4u4SzZK+1Xxdp0EBbIUrtnbAa+TCMAT1YS7R Og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3ktq2ynee2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Nov 2022 11:34:38 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 02FA0100039; Tue, 15 Nov 2022 11:34:34 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F01CF21A206; Tue, 15 Nov 2022 11:34:33 +0100 (CET) Received: from localhost (10.201.20.178) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; Tue, 15 Nov 2022 11:34:33 +0100 From: Olivier Moysan To: , Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue CC: Olivier Moysan , , , , Subject: [PATCH 3/3] iio: adc: stm32-adc: add debugfs to read raw calibration result Date: Tue, 15 Nov 2022 11:31:23 +0100 Message-ID: <20221115103124.70074-4-olivier.moysan@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115103124.70074-1-olivier.moysan@foss.st.com> References: <20221115103124.70074-1-olivier.moysan@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-15_05,2022-11-15_01,2022-06-22_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS 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?1749558214866967817?= X-GMAIL-MSGID: =?utf-8?q?1749558214866967817?= Add debugfs to read linear ADC STM32 self calibration results. Signed-off-by: Fabrice Gasnier Signed-off-by: Olivier Moysan --- drivers/iio/adc/stm32-adc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 65dd45537505..45d4e79f8e55 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -1879,6 +1880,23 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = { {}, }; +static void stm32_adc_debugfs_init(struct iio_dev *indio_dev) +{ + struct stm32_adc *adc = iio_priv(indio_dev); + struct dentry *d = iio_get_debugfs_dentry(indio_dev); + struct stm32_adc_calib *cal = &adc->cal; + char buf[16]; + unsigned int i; + + if (!adc->cfg->has_linearcal) + return; + + for (i = 0; i < STM32H7_LINCALFACT_NUM; i++) { + snprintf(buf, sizeof(buf), "lincalfact%d", i + 1); + debugfs_create_u32(buf, 0444, d, &cal->lincalfact[i]); + } +} + static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev) { struct device *dev = &indio_dev->dev; @@ -2465,6 +2483,9 @@ static int stm32_adc_probe(struct platform_device *pdev) pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); + if (IS_ENABLED(CONFIG_DEBUG_FS)) + stm32_adc_debugfs_init(indio_dev); + return 0; err_hw_stop: @@ -2493,6 +2514,7 @@ static int stm32_adc_remove(struct platform_device *pdev) struct stm32_adc *adc = iio_priv(indio_dev); pm_runtime_get_sync(&pdev->dev); + /* iio_device_unregister() also removes debugfs entries */ iio_device_unregister(indio_dev); stm32_adc_hw_stop(&pdev->dev); pm_runtime_disable(&pdev->dev);