Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp736295ybh; Wed, 18 Mar 2020 08:13:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvfIE0LtNPI6h/pVeV1vzI6gWzl7jb3waXqXIf8eq2hnJ2PdpHmsBlMxctQ5UhQDz7JQ3QX X-Received: by 2002:a9d:7a8d:: with SMTP id l13mr4484145otn.286.1584544386400; Wed, 18 Mar 2020 08:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584544386; cv=none; d=google.com; s=arc-20160816; b=zUXW34OnK9iKATcOs8JGUlJJrQvMABVbah1m3uj7h/Hx2sGL9UN83EPN/FEMxBZ3gs hPbCn7Q2jm+Dery/p9rOybCCAahErQ2WHPlcAa8I2AHvHZ5Mke2iwnG5AcW9w6y/Z50d I9NEplZUvrUbgjFsJfD4tnowOFL/w2cqkQLszLWipe151ElchQa3rXDlaUPetY8ERbp8 jUhvcQlD5JJ7S4c53gHNFqcqFmmU3r0Pxa4rTl03f67YuVspwiS4WmQRrojdpJ8i/JLO jbM1qa76h4nTO9xvLJymrR3VEw9v9/thYqSfK8aj9wAHD2sIclIKsAnywXOSZ9ABLPsI d3AA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=fVkLEgRzM/r0AyOZ8ZF2WRxdioYlNEatN5ixEHTn2Mw=; b=xh9vj/lMJaU2ZvLbOPaJ+f9cmkuTYH2KkAf0CcTmZRPM2fRJjvqmdm/Qfxp/zQGjZW V8Snb4i9+XjvPnJSal1tb6yuIL9NbAPqxSYdQjo6DAmahE55opTZPYVhAcEhDtH3ljEl kxrsj0RVI3ZpMF9D07+wybi66GN8NdaAkxfvapIsQG0CyKdqMZ53cVUSdGe169c0WaBT pRV5FJh9p1PBSvsJxwXenKGbqZzBZa5+8QiU0vchJRwDDZPAVrCRuq7tX3Q7CrM6Quwh bHd6spmXIK5+W/mWFV+TZ75E5w0vXY9gdLIMIqFxmpKibi1p63B4ADYOfD1NEmCywzel qeLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metafoo.de header.s=default2002 header.b=IPjbKREK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si3383384oib.260.2020.03.18.08.12.53; Wed, 18 Mar 2020 08:13:06 -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=fail header.i=@metafoo.de header.s=default2002 header.b=IPjbKREK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727534AbgCRPKN (ORCPT + 99 others); Wed, 18 Mar 2020 11:10:13 -0400 Received: from www381.your-server.de ([78.46.137.84]:42922 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbgCRPKN (ORCPT ); Wed, 18 Mar 2020 11:10:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fVkLEgRzM/r0AyOZ8ZF2WRxdioYlNEatN5ixEHTn2Mw=; b=IPjbKREKP5ktPaPLKl56Z5kfgs zMxcPemxNVIrqOhPpFuAe+bgIi7HUS/0fA7Cm4KHGOnyQ2yX+GFTFRv8+bP3l67c6g2De2/DMUx4W 38gOqzDg16WE1LsaB5qVMah58eip4ovBRgh8Y8PyTIyjGZTaNT/aKKZx1ujo8LsUxNNG93YbymBe7 kmyGQt6hnLB7ZPhgIhHd+2I7yAq3BKWRacBr4u1eQRI/ulmtBvmS5AaJPvoJ5P3D2QElkp9yKuUk8 ZZcvCBHao4+GQNLKP9NuK2AJPcESrpLekirPtQ2olYLg3F6AvUljKlA0wuptx9gZKa1DGrkqDRSYG /p+UgaeA==; Received: from sslproxy03.your-server.de ([88.198.220.132]) by www381.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jEaKg-0002za-7F; Wed, 18 Mar 2020 16:10:10 +0100 Received: from [93.104.115.49] (helo=[192.168.178.20]) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEaKf-000JOc-SW; Wed, 18 Mar 2020 16:10:09 +0100 Subject: Re: [PATCH 5/5] iio: adc: ad7793: use read_avail iio hook for scale available To: Alexandru Ardelean , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael.Hennerich@analog.com, renatogeh@gmail.com, jic23@kernel.org, mircea.caprioru@analog.com, Alexandru Ardelean References: <20200318134042.30133-1-alexandru.ardelean@analog.com> <20200318134042.30133-6-alexandru.ardelean@analog.com> From: Lars-Peter Clausen Message-ID: Date: Wed, 18 Mar 2020 16:10:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200318134042.30133-6-alexandru.ardelean@analog.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.2/25755/Wed Mar 18 14:14:00 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/18/20 2:40 PM, Alexandru Ardelean wrote: > This change uses the read_avail and '.info_mask_shared_by_type_available' > modifier to set the available scale. > Essentially, nothing changes to the driver's ABI. > > The main idea for this patch is to remove the AD7793 driver from > checkpatch's radar. There have been about ~3 attempts to fix/break the > 'in_voltage-voltage_scale_available' attribute, because checkpatch assumed > it to be an arithmetic operation and people were trying to change that. Yeah, probably a good idea! > > Signed-off-by: Alexandru Ardelean > --- > drivers/iio/adc/ad7793.c | 53 +++++++++++++++++++++++++++------------- > 1 file changed, 36 insertions(+), 17 deletions(-) > > diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c > index 5592ae573e6b..fad98f1801db 100644 > --- a/drivers/iio/adc/ad7793.c > +++ b/drivers/iio/adc/ad7793.c > @@ -354,29 +354,28 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( > static IIO_CONST_ATTR_NAMED(sampling_frequency_available_ad7797, > sampling_frequency_available, "123 62 50 33 17 16 12 10 8 6 4"); > > -static ssize_t ad7793_show_scale_available(struct device *dev, > - struct device_attribute *attr, char *buf) > +static int ad7793_read_avail(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, > + const int **vals, int *type, int *length, > + long mask) > { > - struct iio_dev *indio_dev = dev_to_iio_dev(dev); > struct ad7793_state *st = iio_priv(indio_dev); > - int i, len = 0; > > - for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) > - len += sprintf(buf + len, "%d.%09u ", st->scale_avail[i][0], > - st->scale_avail[i][1]); > + switch (mask) { > + case IIO_CHAN_INFO_SCALE: > + *vals = (int *)st->scale_avail; Can you change the type of scale_avail to int so we don't need the cast? > + *type = IIO_VAL_INT_PLUS_NANO; > + /* Values are stored in a 2D matrix */ > + *length = ARRAY_SIZE(st->scale_avail) * 2; > > - len += sprintf(buf + len, "\n"); > + return IIO_AVAIL_LIST; > + } > > - return len; > + return -EINVAL; > }