Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2078353imd; Sun, 4 Nov 2018 16:41:30 -0800 (PST) X-Google-Smtp-Source: AJdET5d9GSJ8Bo53UeinEvicnoMtdFcAeAPdqtF4TS7EZ15TmST5Sg1DB78U/NvYJobsykm7J2TL X-Received: by 2002:a63:3f44:: with SMTP id m65mr18790632pga.115.1541378490376; Sun, 04 Nov 2018 16:41:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541378490; cv=none; d=google.com; s=arc-20160816; b=yvozPd/R57YHe++1C12wOG5AANalYHPgXjflh+3n9ifasTpSEeBSOTbleQMW2eqmka dStmNfbXqXqJE+1bf7xf0uBrTncC/w3cTBcCR8tcnqFdJbZyVZZiXEWE6693ctSwYp7w zCByN3P7HzJ2OPjJz5viwsVXr3j18MMM/zBAx3Nl0vWH55Qe87U7AqR6yoTX/SwPx2q+ 8MTrnhsuSgvLVru8/0smgHh8SU+lr1Wiw7a5LYNxplbU/jTi2fkMd9CcffGuyis7NMPY fNW0O4nKMosYNpO8g9gTBaD6toixyvhcDWp/0aXpkXce87yfGqchpsFDNxEfv1WJLBpC E2mA== 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=rR77z+iFjvPoSFYturLeyyC4o8qwJbNKxdwmghcvgnE=; b=Y5/fbUjwZYtaoCQzHhH2C+kih0fpUCHb3dsDf7X5iPMR5USSK6GKmsnVw1HoT/snwg Gm3fdYZmoXXY5x8jIMNtrwKVpb0k3YF53+SqHZMIyXovtG+cuti2UuYfNAvG7sAU+VzC cAiLOdWagr2w/7E3HCUctGEOSipQnrgIC0vqhjqPTftg68I0MA4eSUXHup89zdLMi6jm sVJjyQaS8wW7hwSoUCylqYcUAlftqGwdmB1FZ5oKzxpQc18ijE75rqzI8Q2nLR1C6DvP 0M5xdvnLLU4bXs0+c6NiLpmG1qbbzznyy3dV+NcC4FQqs998mw2Bl7/Ejo1Ew6jmJ+oI Gwcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nVN6erYM; 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 b4-v6si24888597pla.189.2018.11.04.16.41.15; Sun, 04 Nov 2018 16:41:30 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nVN6erYM; 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 S1728963AbeKECGx (ORCPT + 99 others); Sun, 4 Nov 2018 21:06:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:43544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728899AbeKECGx (ORCPT ); Sun, 4 Nov 2018 21:06:53 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 F35322082D; Sun, 4 Nov 2018 16:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541350277; bh=X25ePno31afuYSmXkz75eWxXJ/J+vNLD5g5flXWmLj8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nVN6erYMYkOo+jhzMittbr/xks1laUOX28YstzXUUfY4B6H4pLe88KNOweuKbXJm6 ew03c8D8tL2bymU2QRmETBRwsn0VglLc3+S3o/OnzPwgGE02DtHbeez7TdQcdVjoe+ 85cOGfhvy88uz8MEFOMiS8Dt2nqSbhbsGhDjj9iA= Date: Sun, 4 Nov 2018 16:51:13 +0000 From: Jonathan Cameron To: Matheus Tavares Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: Re: [PATCH v3 6/6] staging:iio:ad2s90: Check channel type at read_raw Message-ID: <20181104165113.3549cd4d@archlinux> In-Reply-To: <20181103224948.31014-7-matheus.bernardino@usp.br> References: <20181103224948.31014-1-matheus.bernardino@usp.br> <20181103224948.31014-7-matheus.bernardino@usp.br> X-Mailer: Claws Mail 3.17.1 (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 Sat, 3 Nov 2018 19:49:48 -0300 Matheus Tavares wrote: > This patch adds a channel type check at the beginning of the > ad2s90_read_raw function. Since ad2s90 has only one channel, it just > checks if the given channel is the expected one and if not, return > -EINVAL. > > Signed-off-by: Matheus Tavares Given you can't actually get here with another channel type by any valid means, this is more a form of code as documentation than anything else. Still it does no harm and arguably does make it easier to read. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. A nice little clean up series. Thanks! Jonathan > --- > drivers/staging/iio/resolver/ad2s90.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c > index 9c168b7410d0..3e257ac46f7a 100644 > --- a/drivers/staging/iio/resolver/ad2s90.c > +++ b/drivers/staging/iio/resolver/ad2s90.c > @@ -34,6 +34,9 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, > int ret; > struct ad2s90_state *st = iio_priv(indio_dev); > > + if (chan->type != IIO_ANGL) > + return -EINVAL; > + > switch (m) { > case IIO_CHAN_INFO_SCALE: > /* 2 * Pi / 2^12 */