Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12161634rwd; Fri, 23 Jun 2023 02:08:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46y5TRRbQOBiTyN7POxTXq59dsZGJ5GI80hAol7hNc3PiwKLWyTZfs6K5LX2C7ioTOCqNb X-Received: by 2002:a05:6a20:160a:b0:11f:6391:3ae6 with SMTP id l10-20020a056a20160a00b0011f63913ae6mr25543232pzj.28.1687511333615; Fri, 23 Jun 2023 02:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687511333; cv=none; d=google.com; s=arc-20160816; b=FPRI5AMFGaz4sPNjWsFO1hlhTb/Ja813Pxk1ZbxdrVozmVJ2IxdWiSN/u+UMtiulew 61q/yLssersM7KyDiJGX34YICgYH9lxS8fzsLYZJgyubm96rhzZ5F05DF7nP5yHsMY4d FWnJUrnucLfgfPCJ2CHQa4Vle4PKULdcQizAmPxTZ3e39ejnEjH1rgivxMAHbi4MXhZI ycKIdSnAnA5+BEQ+fCWQ/XIDDcq9tgANEMiUDN2SPX9/kLBwahiNVeFgsWlPxj2O5ip4 Z4vQowSSrv8Yb6elrhuYrbkXbYNExpMOsnNFdocgddQOheEdiyqcWW+v9ahPR0m4UnmO smAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E9t2e1q3XqXgkAJ8mkN8CCPIM4SOxAmZg6pkigwfbv4=; b=UcnhP/NHvrjNLvfDYAEhp8kcHp4la2tXlAbo9nfedSxP2sB1jinvpyj/5KzKgyUE/f R0+CAot/cGIsg9rMpJ5+3Td6+Ar/yNdy1cuUtA0Ycad6oqJRVbZ/o/34Hr2DThQm9MnS FeIPZLDTISyw+ZhqkAG6W+irLjdrwNZgVvW+Je7eCNvOQ3hvw4/Xu2hNJHrgErqyxk0T mshRymY0jQfe/VZHFpMF5IoJtCJJ/N8ZR6MmjTMFTs2suwfcL3p567v2qiPyZCYAOe+C 3r6qniTWGy+4WKha3KECRGr44buv2wb4lXsWaY2mi1SZ90ioduseyuZYYJSzl15VPikx eRqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LEQ97ShR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k62-20020a638441000000b0055390a944c1si3722465pgd.551.2023.06.23.02.08.42; Fri, 23 Jun 2023 02:08:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LEQ97ShR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbjFWI7X (ORCPT + 99 others); Fri, 23 Jun 2023 04:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbjFWI7E (ORCPT ); Fri, 23 Jun 2023 04:59:04 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C5B26A1; Fri, 23 Jun 2023 01:58:57 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1687510735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E9t2e1q3XqXgkAJ8mkN8CCPIM4SOxAmZg6pkigwfbv4=; b=LEQ97ShR1EMDXWLw8NWSlhKLPMTuk+/B/eKxLPY/qhtYF6SRZwlX2JrVaLWrq4TnQnGEQC 4d3JhmMIvOowmnxRcxn3Si9I6Yc39FqHSL9RIBAFhDtIcqtfSF6mf+mldQ6bkAi8gL43Qr SDI6gwfa1OnNFQ+N/zHFVsKFPcF99J49K8zCtJqgyUAHMhVbQXiibUsQ1AgUBpjeAtlW8n E9lb+Pe/C0I42rRMp0mCPuJmgcwDG57v/dTE4f/2YZ/JQCNaQthZS6cwMW3hjxI+yxY0U5 h8Kq0JpayMWc79ddAyyfso4nj+bCyfpoZhjvt7o0t6aG2f42QWVJv8k3fFzLiw== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id DBB0FE000C; Fri, 23 Jun 2023 08:58:53 +0000 (UTC) From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Andy Shevchenko Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Wojciech Ziemba , Christophe Leroy , Thomas Petazzoni , Jonathan Cameron Subject: [PATCH v6 08/13] iio: inkern: Use max_array() to get the maximum value from an array Date: Fri, 23 Jun 2023 10:58:25 +0200 Message-Id: <20230623085830.749991-9-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230623085830.749991-1-herve.codina@bootlin.com> References: <20230623085830.749991-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use max_array() to get the maximum value from an array instead of a custom local loop. Signed-off-by: Herve Codina Reviewed-by: Andy Shevchenko Acked-by: Jonathan Cameron --- drivers/iio/inkern.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 71d0424383b6..8bfd91f74101 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include #include @@ -875,11 +876,7 @@ static int iio_channel_read_max(struct iio_channel *chan, return -EINVAL; switch (*type) { case IIO_VAL_INT: - *val = vals[--length]; - while (length) { - if (vals[--length] > *val) - *val = vals[length]; - } + *val = max_array(vals, length); break; default: /* FIXME: learn about max for other iio values */ -- 2.40.1