Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp165989ima; Thu, 25 Oct 2018 17:46:29 -0700 (PDT) X-Google-Smtp-Source: AJdET5dsoiL66tw3Rt/yNWijndEJf2vmgwau8NS5tp18z3Y/Aj2N8cuSMMRsaKkldfdPhuUyuteh X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr1356275pls.217.1540514789743; Thu, 25 Oct 2018 17:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540514789; cv=none; d=google.com; s=arc-20160816; b=tNslC0byRv/r7EdwypyJegbRXLYzTZjmxbcsA+24n+w5XeY5qBM1sGx0bygEvxnB3t FgsoFqhBMHnzgLpb/CC5exTFp24EjZEfsYKfTYVXB9+x0QfTgkqnPyWZ0ewMj0uKFcjv 8/EcZylJdFm373d57p5XcrojFKCubHPDMm0PdeHHErPPgc14F+cXI+SXgjBaz0cfVanR fkFBEnIgAzmlGRFKJqo+ZBSH4nWZEs/5lqOzvOBCXY4/+u+zbpRS8If/z/pMubiIw63M r+IsQLXPAiWRFelSWR5N4Se7tQVSVR2z1QAfuRzkzGTGexBe3bG92UlN9cuvTqf4T/5p dxzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=NU6uEhiDTDfMKDT6vIKylD1JcOmwJKYVJFXwnpeU4xs=; b=Bq7DZ+TvUVz4+QFZC5UuVHihp+OFp2IKg0Kye5LyMP+q4VyQwPPaxBpRFWzmGlXMlz zyWkj5z234w0iUjvGaGJyM/lNZo6ouJz5jkZbbI1Ncgo2mVdN8r4UNohLta9yA8XtPFZ SSMUu6T4oUPso8spNuDz4bEM3PADk3o1BA9sBzCqfCq+nNU6kffU1gU6/T+CWviUZqbN hvQmKOqTl+j4bPdbgg6aSFBYvVBCxx+WtScGS4BJRF+zFQiwseEJxnDGxVAVp+8b2uqD Cv4/EbNdRzzv/DtovFxRiXz9xqFPkp6vlgwz4VLZjJb9E+XUheBb0pLinDQgia8M+jP2 67sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=ZdVgjW8o; 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=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si786885pgi.348.2018.10.25.17.46.14; Thu, 25 Oct 2018 17:46:29 -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=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=ZdVgjW8o; 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=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbeJZJUd (ORCPT + 99 others); Fri, 26 Oct 2018 05:20:33 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:36249 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727538AbeJZJUc (ORCPT ); Fri, 26 Oct 2018 05:20:32 -0400 Received: by mail-qt1-f195.google.com with SMTP id u34-v6so12199237qth.3 for ; Thu, 25 Oct 2018 17:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NU6uEhiDTDfMKDT6vIKylD1JcOmwJKYVJFXwnpeU4xs=; b=ZdVgjW8o5j0hFmycZse60LAYwk8ZLgVMTfFc/PlA8x3OYy9kyQRpq8HWJbsiY+9TzA H5/mEniByRs99eSMaHt7o8ISGkpv6ucZtejmliUQgB5uUc/g1n+OsbI9cFN7S2KySPVg Ff3J75XU6zXHQzSZdPj9qTCTsk4C8EzDUstNEsTMqYknQV3ES1bTACfcRQIaUCOnIwR0 u3jwsYXFQ4hFa2KKQzzQ3ex8ITB+pBOuh5Yhnmhfl3kTIqvmRy+huxwDF8+YiAVtukdW 0oQ4PdYwbkQrgZYTuEvE1PzCK1kkdwN8c8ClZZTFIVd5pY4zHmN+CjCRz7izB3EyDHbV azfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NU6uEhiDTDfMKDT6vIKylD1JcOmwJKYVJFXwnpeU4xs=; b=Qi8U7bxxEymoZyP9UJLldBgIwp509q/oYFYbHNRHFJPEnWyK9YQL/vfmWgxJWtqu6h jj4e+rkwc3LY1/I8W7M/0zBve4GbeqlNgx7BCqRKMW+RCp1+OgkHblkTpsHpvc317zLT 37+JEwbx0WhSDivxU5R+xQPgf2Gar20bYvJ5PsaRJAvpImJO907O+/3b2PFadOsdWNCL fLV3XRGrzXVZQl/BfOO4WMzmyDgLL+3nJAlUHTNTvBt4siU+bLpV95zakm03XFwc6qdi sseugNleio2JWg8sYMPQy0aH08Zmh/mTmm+b1nIL5mjQ5jHw+q7cdJ77Crwp4N/bi25Q OzZg== X-Gm-Message-State: AGRZ1gJbyuTjAA0FvW+zLSp6oUwKlNASqPTKsRa/321rVQxBlX4IY/IT wwiIwTmeIFIfdFqmspdVTCQ4qQ== X-Received: by 2002:a0c:9d01:: with SMTP id m1mr1412459qvf.192.1540514741602; Thu, 25 Oct 2018 17:45:41 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id y3-v6sm2371735qti.27.2018.10.25.17.45.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 17:45:41 -0700 (PDT) From: Matheus Tavares To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 6/6] staging:iio:ad2s90: Check channel type at read_raw Date: Thu, 25 Oct 2018 21:45:12 -0300 Message-Id: <20181026004512.31012-7-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181026004512.31012-1-matheus.bernardino@usp.br> References: <20181026004512.31012-1-matheus.bernardino@usp.br> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 52b656875ed1..24002042a5c5 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 - 1) ~= 0.001534355 */ -- 2.18.0