Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp833023imd; Fri, 26 Oct 2018 19:01:40 -0700 (PDT) X-Google-Smtp-Source: AJdET5dg3rS5/5+xCaWUVW+q67BXR7ectG40Key3Hc/O9l2THHMmDujQF3Cv1yBI/eu0rsVoo85u X-Received: by 2002:a65:4c8d:: with SMTP id m13-v6mr5271505pgt.83.1540605700725; Fri, 26 Oct 2018 19:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540605700; cv=none; d=google.com; s=arc-20160816; b=EIheQKPPQizkyQlwGqxm2G7AZDDBToG9nezTmMkeW+4z1HWkqV8O9Z8+KHblMJ/2Fo PCtTkFJk3HsfkspeicgzjNd24QrG2GfOPcv2Nt4rrlKVfhPUuqslI6h7ji9ES2t2+K4V CMZx+OrEGxv1pLiuNh3Lp/RiOQbCAy3LCWLfBeeuIpcwdLEP2lu/tRllN3mvuqlMnWRs gfxjBdzM6TfPB5m6TxlM3qYBnl8hhgiJ7EvhoY6aXDeYn3Csd3+xG/6qTMqHKAhOhFwE kJegKfTjK5x/UAjtpK0189qfGxC4s3na9pFlKvOuDkY1O5Dw4hEJgHmLnaY8h6LU+O1M uqRQ== 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=HOpN+KuwbTq7akDaovMPc7X581cLOX5tgzxsfiKRSOySHANVZhMEbfgrKheqL5+CyV m7ztxyARKyPxK7CL0yDA3UoXv5hwNFfymx6ZILlZ2FWUf/DN62gZFEb9ZBLjKJ6jsJV4 ysYS4OEtbD+sJkjFDx3LiIymnTo0kjWTVjZRPqyMXuVirkXf0swwkjBJJHR1fkLE3R3B ZZrYg4h885o5bLDcAuOSeH/yVHFccvmh80DyKI1hWbEDpTNvPmYvAXlBtjrxIAXB4wYh PXAtBZgnAf/DdKv5HKQVX1OmbOulwHci/UJ/tFiAPLz2I2ndgsFhv8XG5ueWXrxfU24y ETvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=sOjLj73h; 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 s1-v6si12068531plr.141.2018.10.26.19.01.25; Fri, 26 Oct 2018 19:01:40 -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=sOjLj73h; 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 S1727948AbeJ0KkO (ORCPT + 99 others); Sat, 27 Oct 2018 06:40:14 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:41294 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbeJ0KkO (ORCPT ); Sat, 27 Oct 2018 06:40:14 -0400 Received: by mail-qk1-f194.google.com with SMTP id 189so431595qkj.8 for ; Fri, 26 Oct 2018 19:00:53 -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=sOjLj73hbkjSNHCbjYdY/10ua9GvS5qgofryFwX7Al2Wq0Ah/5T0+uLHRFthjyBSJR fTxs1EBvwwPAxu2/CpX6Rp9IcNWvQ4Dczucmuj7hIBEjAjTCvnvcuzwYtr7a7BmczEqD EC9Hw3/QdPVRZ54nCM9GZYJzFYhzuMSUc9tSmxuHNoTrd9bXikADe/Jk/AAIe2pLYDxP CtEwaCma9AcArR9h9GULLKwSFz0RjwZ0m1s6diAdZp2M1n9k5D3V/8AAAZBJL2Jc4L4R +rRwBd4hm+ldGz7/+5i9pky/AHbNqQMzDVnqoYm/juj42YnPhnKwVJn6rjc8PQwroUSd GRvw== 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=Q9JmcUt8CpfUuwHG0sA1nEqPE0hQucqY/2iJqLd9PVBncWagxUw7hPztSvhuJwSKjh P7zlhzV2NAucMtUMo/vtU6wf1rbHtRq5U5DD2UFDIdZyvUkyDdXj75/RkAKq/Jccec2p UISYzz4wiqiQEImVYEd+yt3emu2nG2A5Btvje6/Jn7BajJtQoofqBxEBXVgHGd/4z9aE igbCY43vevG+jTGr+uTOwgIMnBBXswvJoMAvIQ5tD+ZIdeCsGNR2DGcN9PU0ay5uhxS8 iXy2L4cf9ODw0SQklUlFvdUC8o3x/5UwYsmVwalafHT9dshHSH9L6gtyo9io9t74JSHV 2l5w== X-Gm-Message-State: AGRZ1gK+tCcpp9po4KNnni8XpFQsHe8bbXyDV1INEPliphgHYefYca8H QYXYjRjSgHWEm5FCseB+rSRE2Q== X-Received: by 2002:a37:1ad9:: with SMTP id l86mr5001061qkh.54.1540605653316; Fri, 26 Oct 2018 19:00:53 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id h67-v6sm8499777qkf.32.2018.10.26.19.00.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 19:00:52 -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 v2 6/6] staging:iio:ad2s90: Check channel type at read_raw Date: Fri, 26 Oct 2018 23:00:05 -0300 Message-Id: <20181027020005.3140-7-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181027020005.3140-1-matheus.bernardino@usp.br> References: <20181027020005.3140-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