Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3778037ybi; Mon, 27 May 2019 05:58:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhFI7qbIOOxWHgale48J+IEHiHWoXyWD45D2gOcVP7CIG8QtIgMQZJtWVzKMkmXZs8C5Zq X-Received: by 2002:a17:90a:32c1:: with SMTP id l59mr31210557pjb.1.1558961908775; Mon, 27 May 2019 05:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558961908; cv=none; d=google.com; s=arc-20160816; b=0msjVPoaktT9tsv8R6kUk4z12u9kKwlOtSHRFmpd76zOHV/Z16RO/7LUTVBmIv49SJ 8Uz+9e7vOVmZDhVMUhDIyOx60LCXS3RI2ouD3T356u2UHNxoiEQ5mdLGYImLp4I7sNqU /rktyrbMyunAW4dSW9PY7WE467nUzg/ZooMJa4IkNa/9OGbonNzLe0j0vq9PCNohdOUB LDQr/dlFZ8No0Llpz1xJCDuNawWcXwklLtrWEAdpS0MSjmGyE9b1XfEyQYP5FcXT61pa qh5KC/ahHIOdviAqTiq44ONsXBZfF2AnaMMzYWIrpg63DCCPB1FnYIhd7SvVtTPvGEyF zTqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=662tjqK9oljOciz7ZFmGFdjYxExMiNz4NCgMjETdjAU=; b=vQIl3msQDSTlsZiKiHYaDhWRnaVMS6gNtfgBjYV7e8Y78vMjcH46oa86wuFZROcvQC e4AJ/LOzp7SxirNQEV8+Z5ar6CKdRxwUgpcqX0FaGk5VPLeHEiTjY0LUKxOaN7vpoeZs BCEqRDQEj00vTnFiNIZkdrXZIexbkU0tCglzR55BqXdZoUyTWoCi6ELP6RLNjwieMb6F izu2xE65e6cq8/+uwQ1ITtHS7T9f8aZDWc7hfIhoc+4mI03UnM6D5dWasLjiY5Hwn3TU cMiSiQUpCHmqXFab8t7RWntXJVkjSrDoDpMfP28qQviaj2xFDFWf2qCvvJUsHfMvb5Or F8ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@analog.onmicrosoft.com header.s=selector1-analog-onmicrosoft-com header.b=A8YHAEWn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si17085262pgv.128.2019.05.27.05.58.13; Mon, 27 May 2019 05:58:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@analog.onmicrosoft.com header.s=selector1-analog-onmicrosoft-com header.b=A8YHAEWn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbfE0M47 (ORCPT + 99 others); Mon, 27 May 2019 08:56:59 -0400 Received: from mail-eopbgr800052.outbound.protection.outlook.com ([40.107.80.52]:53315 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726234AbfE0M46 (ORCPT ); Mon, 27 May 2019 08:56:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=662tjqK9oljOciz7ZFmGFdjYxExMiNz4NCgMjETdjAU=; b=A8YHAEWnCjVsJORRIP+pe+nQbclBBTtdDbj+ZQQgLJSSmOLezMwVmNa+/iKzSMtjxPisbTGVFvp3RQxWwJf8ko2IvhUN0F09cy9vZtTe2t0IPSWaZxzO3ZxS2EHWSQe+a9/IF7kFZVpEXoX9Vj9XBPKVF7ToFkOsDr9sEJuCYl0= Received: from BN6PR03CA0018.namprd03.prod.outlook.com (2603:10b6:404:23::28) by SN2PR03MB2270.namprd03.prod.outlook.com (2603:10b6:804:d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.16; Mon, 27 May 2019 12:56:55 +0000 Received: from BL2NAM02FT063.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by BN6PR03CA0018.outlook.office365.com (2603:10b6:404:23::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1922.16 via Frontend Transport; Mon, 27 May 2019 12:56:55 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT063.mail.protection.outlook.com (10.152.77.121) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1922.16 via Frontend Transport; Mon, 27 May 2019 12:56:55 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x4RCusff022711 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 27 May 2019 05:56:54 -0700 Received: from ben-Latitude-E6540.analog.com (10.50.1.100) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 27 May 2019 08:56:53 -0400 From: Beniamin Bia To: CC: , , , , , , , , , , , , Beniamin Bia Subject: [PATCH v2 4/4] iio: adc: ad7606: Add debug mode for ad7616 Date: Mon, 27 May 2019 15:56:50 +0300 Message-ID: <20190527125650.2405-4-beniamin.bia@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527125650.2405-1-beniamin.bia@analog.com> References: <20190527125650.2405-1-beniamin.bia@analog.com> MIME-Version: 1.0 Content-Type: text/plain X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(39860400002)(346002)(396003)(2980300002)(199004)(189003)(70586007)(1076003)(186003)(77096007)(50466002)(6916009)(70206006)(305945005)(2906002)(246002)(2351001)(106002)(48376002)(54906003)(86362001)(50226002)(8676002)(47776003)(8936002)(26005)(7636002)(478600001)(7416002)(72206003)(336012)(476003)(44832011)(14444005)(5660300002)(107886003)(36756003)(4326008)(76176011)(51416003)(7696005)(356004)(53416004)(426003)(446003)(316002)(16586007)(2616005)(126002)(486006)(11346002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2270;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c09e0c6-3adc-469a-0922-08d6e2a2cbee X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709054)(1401327)(2017052603328);SRVR:SN2PR03MB2270; X-MS-TrafficTypeDiagnostic: SN2PR03MB2270: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-Forefront-PRVS: 0050CEFE70 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 0WwhvngExQwO+8ExQalcw75MyceI0uL5y8tX3EUIl3WzEnjhIK2zS8gUdEsSE0iCz+zzaG0WWuhqtkqa/fXD7Qa2kON+wcgmdp0j8UjBvTriXAah2W/g8WpzFAKDHZq6/JV03Jpa9dmQO0ojchcS71k7WiuROiT7bjA56v1NwxooG3gy/OqAbc/1oo1tAOYC3eC0Va7s3DhPbaVdKW5dYUvplSITJ21W1kDCheAuHbw3UKeIv751/clIAipJf89l0QYLJXMnRhsbhvfPiokSKtH0Dkuj/GUQ/iQijABhe5FE/RbvL9PF/joT6ZN72BOTuPqvL7NOcqZmy49ncUKCxpQ3292OhVW6PCwgCbU8ed7TtMXZqUqp0d9BBP3hLP8Xy6YMz39osOkNjpvSga5Ox3Tmq2zE8ObDRtP7RdluK24= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2019 12:56:55.2447 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c09e0c6-3adc-469a-0922-08d6e2a2cbee X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2270 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support for register access was added for spi devices. Signed-off-by: Beniamin Bia Acked-by: Jonathan Cameron --- Changes in v2: -nothing changed drivers/iio/adc/ad7606.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 8e09ad4bb72e..0eccfc873802 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -134,6 +134,30 @@ static int ad7606_spi_write_mask(struct ad7606_state *st, return ad7606_spi_reg_write(st, addr, readval); } +static int ad7606_reg_access(struct iio_dev *indio_dev, + unsigned int reg, + unsigned int writeval, + unsigned int *readval) +{ + struct ad7606_state *st = iio_priv(indio_dev); + int ret; + + mutex_lock(&st->lock); + if (readval) { + ret = ad7606_spi_reg_read(st, reg); + if (ret < 0) + goto err_unlock; + *readval = ret; + ret = 0; + } else { + ret = ad7606_spi_reg_write(st, reg, writeval); + } +err_unlock: + mutex_unlock(&st->lock); + + return ret; +} + static int ad7606_read_samples(struct ad7606_state *st) { unsigned int num = st->chip_info->num_channels; @@ -645,6 +669,7 @@ static const struct iio_info ad7606_info_no_os_or_range = { static const struct iio_info ad7606_info_os_and_range = { .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, + .debugfs_reg_access = &ad7606_reg_access, .attrs = &ad7606_attribute_group_os_and_range, .validate_trigger = &ad7606_validate_trigger, }; -- 2.17.1