Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1192655ybi; Sat, 8 Jun 2019 04:36:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLj1/TTgC1xeqEECIQMbmgE+GSO7Tvei+65PBD6R+6t5HPL1sqL4ven82zgSD4jXAaVGKs X-Received: by 2002:a17:90a:8a15:: with SMTP id w21mr10852777pjn.134.1559993811624; Sat, 08 Jun 2019 04:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559993811; cv=none; d=google.com; s=arc-20160816; b=WJkHeAOB491TRwB2OXIPg13ltl6sYNn+ssmoehG8oeLW2TZaurUrnljekma/1xOCAh 3hFHkbDaZy8P03xztYCmIZIJOaeynFj8LAwpBJPT+O9PZooYyotQ1NEEPZIZrANIDK54 oy1ETBA0W8g99TmsT2ze/cA4PDEXtEaQca5KHTTNeKMT88yxZ1wGDnNB9KO9NRxCtzul oRtLZ0Wu4FfEwI0j0in7EyxBxBnMQKji1LNgw2IL/WQv8AaCrNIW4jzgVhop3IcWB42t hjJ7y5kHAN24ajvXE0v+x72Mv3n4ZKK3I6BKzBCpj7I9zvLTUntDc6smBGCaRSrtV6UU p5jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=HscAelPeQ8U27VV2YoFDO0rvkhesRLoW6D23BjYc+6k=; b=z0kJnk5ZKXTjHM0iaCn2yte39+7EI1TxF9s8EW2vTUppc2rK0lwrgOaAdSCj46S0Nq KQ0543BtGEDydULAEmUhrwzQOHjPvC7/WL0n1wP1D5ADgOzbm9/J2CcyeC0CbrOmIN2i SMyQHa5Wdfw0J7+6ybrjWn3ev3aX869qkWlKv8FRVtd2coMIAbjShXHX9RqyfjBBNSvA fz0+3jGuotD86E1T3eQezBn4E2Dq9tG+5bKrHp+bwG88F6eNIaAoAE8KPTjhT3H1sleM 8uRrFHOe7T8fDHAlZLN4Fpzkx+4h8yWN/JbOTl4S1iotkd5zlwPeOsoXy4DwJxzVaA9r MsbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="BqEPKE/N"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y19si4329683pgi.587.2019.06.08.04.36.35; Sat, 08 Jun 2019 04:36:51 -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=@kernel.org header.s=default header.b="BqEPKE/N"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbfFHLei (ORCPT + 99 others); Sat, 8 Jun 2019 07:34:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbfFHLeh (ORCPT ); Sat, 8 Jun 2019 07:34:37 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D5AC22146E; Sat, 8 Jun 2019 11:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559993677; bh=5o3WJ+PlDP4ACOl8NEp4Y7t3xVI0OyqdulVA5Cshjk4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BqEPKE/NNqSsqN3rY2sMii1L6Z4fGDv4u6ybd1DlIY1fJK7gf95lAVRQMsxa6QUkD yMBZaRY8SDsWxHnKVoEej6gnM/K2l2BKy9FzXgH89I0r/dlK6652P9keGLw4bgE4Xe Tl0jef6D1lVt5u/9lXtVIpoh0qMVxQ5t4T8jgM9k= Date: Sat, 8 Jun 2019 12:34:31 +0100 From: Jonathan Cameron To: Beniamin Bia Cc: , , , , , , , , , , , Subject: Re: [PATCH v2 4/4] iio: adc: ad7606: Add debug mode for ad7616 Message-ID: <20190608123431.14f8dd07@archlinux> In-Reply-To: <20190527125650.2405-4-beniamin.bia@analog.com> References: <20190527125650.2405-1-beniamin.bia@analog.com> <20190527125650.2405-4-beniamin.bia@analog.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 May 2019 15:56:50 +0300 Beniamin Bia wrote: > Support for register access was added for spi devices. > > Signed-off-by: Beniamin Bia > Acked-by: Jonathan Cameron Applied. Thanks, Jonathan > --- > 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, > };