Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp172257ybl; Tue, 28 Jan 2020 21:15:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwse/i2n+K9MUR2ACh5z/KwE0YWYEkaXgY3LmPvD4utNUnLbb+Uugg19xHSYcYGoukhToPb X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr18851225otr.82.1580274957163; Tue, 28 Jan 2020 21:15:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580274957; cv=none; d=google.com; s=arc-20160816; b=vL4p/1EXpkPU7B5EZqGBWEAFq8qeHS+Scvj4fuXDjVMvsr6DGGUDgtDswsEzzVbckN D/B+6+zM6XVkApaviS+lRiYxL6WuDjcBgTw2FUNo/CpGgk5WmMOSZSfI46H9ViawKnD2 8v/iZxHNHkqaEmMuGMdwnI7HS60ZRUGlf/QI4VBEjYixZPJAxntxeEI3iVSBZ3sswaB+ FDXj+MT1OyxAH3J5/vL0G7icCfi8I2D11ztJ/vrgaUglJcYnGU3hw7Q4StWpqIfOHJih yT0X3Dfkvmmyz29bRJ19LtGc5y7CGruwHm3WSytQpVu6No504kfaNtDPsi38OcrOmyYd K0Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=oouMGbjGTvy111Eo3N9N7udXDbFzbprKedaFoSIwqhU=; b=VJh2w6npxXoIfuwjFg3JZPSReeA+icic3GFxq5ChjdRnVrLJw19MjsD9vZQQN2QrKi m+rDt9xQ+B5FGBN38VRKR3KVSqMGZWj4iPKA/FS4XcHWQL2oTKSF71mQfGMz4jAT//gW 3F/XpqVzarylhtvZES7lGpcj6bKgxbkRpwp3PQ32sMhgdj0eumQzLsnxo4nRAOOreGp1 fcCDqAuD2VaS5zWzg2EOIhN2bEaXHqo2b7K88VjWjXbMQsIrd+4rnilmxp4ugn/LJb6i jYIljBQ8uX2yhDBJeSMV0ve5ynsQPOBKx7NunrzrSlfdaW0vXVeljDLaHNncEgZK9GOI e+OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 105si575990otu.45.2020.01.28.21.15.44; Tue, 28 Jan 2020 21:15:57 -0800 (PST) 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; 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 S1726009AbgA2FOw (ORCPT + 99 others); Wed, 29 Jan 2020 00:14:52 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:35792 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgA2FOw (ORCPT ); Wed, 29 Jan 2020 00:14:52 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00T57JB0006396; Wed, 29 Jan 2020 00:14:37 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2xrkfak5dq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jan 2020 00:14:37 -0500 Received: from SCSQMBX10.ad.analog.com (scsqmbx10.ad.analog.com [10.77.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 00T5EZ3J030244 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Wed, 29 Jan 2020 00:14:35 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 28 Jan 2020 21:14:33 -0800 Received: from zeus.spd.analog.com (10.64.82.11) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Wed, 29 Jan 2020 00:14:32 -0500 Received: from mircea-Precision-5530-2-in-1.ad.analog.com ([10.48.65.114]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 00T5ESGQ028516; Wed, 29 Jan 2020 00:14:29 -0500 From: Mircea Caprioru To: CC: , , , , , , Mircea Subject: [RESEND PATCH] iio: adc: ad7124: Add direct reg access Date: Wed, 29 Jan 2020 07:14:35 +0200 Message-ID: <20200129051435.15366-1-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-28_09:2020-01-28,2020-01-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=818 clxscore=1015 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2001290040 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mircea This patch adds the posibility do read and write registers from userspace using the kernel debug direct register access option. Signed-off-by: Mircea Caprioru --- drivers/iio/adc/ad7124.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 52f45b13da4a..38e67e08a79a 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -93,6 +93,14 @@ static const unsigned int ad7124_gain[8] = { 1, 2, 4, 8, 16, 32, 64, 128 }; +static const unsigned int ad7124_reg_size[] = { + 1, 2, 3, 3, 2, 1, 3, 3, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3 +}; + static const int ad7124_master_clk_freq_hz[3] = { [AD7124_LOW_POWER] = 76800, [AD7124_MID_POWER] = 153600, @@ -360,6 +368,25 @@ static int ad7124_write_raw(struct iio_dev *indio_dev, } } +static int ad7124_reg_access(struct iio_dev *indio_dev, + unsigned int reg, + unsigned int writeval, + unsigned int *readval) +{ + struct ad7124_state *st = iio_priv(indio_dev); + int ret; + + + if (readval) + ret = ad_sd_read_reg(&st->sd, reg, ad7124_reg_size[reg], + readval); + else + ret = ad_sd_write_reg(&st->sd, reg, ad7124_reg_size[reg], + writeval); + + return ret; +} + static IIO_CONST_ATTR(in_voltage_scale_available, "0.000001164 0.000002328 0.000004656 0.000009313 0.000018626 0.000037252 0.000074505 0.000149011 0.000298023"); @@ -375,6 +402,7 @@ static const struct attribute_group ad7124_attrs_group = { static const struct iio_info ad7124_info = { .read_raw = ad7124_read_raw, .write_raw = ad7124_write_raw, + .debugfs_reg_access = &ad7124_reg_access, .validate_trigger = ad_sd_validate_trigger, .attrs = &ad7124_attrs_group, }; -- 2.17.1