From patchwork Mon Jun 12 12:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 106565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2559865vqr; Mon, 12 Jun 2023 05:46:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IilYYak0w1wYHnWpgI59dclrHJ59Q5lqqk+FuTIu/QVEt9NZlf/mMKXdDI7BnId3auVH1 X-Received: by 2002:a05:6402:518e:b0:516:41ed:fd40 with SMTP id q14-20020a056402518e00b0051641edfd40mr6167233edd.12.1686574002209; Mon, 12 Jun 2023 05:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686574002; cv=none; d=google.com; s=arc-20160816; b=H41nBcFBz/R1DIdcuTtfMlFNThX9xGF0Ph5oN/aFiWjmZjssLtyLxPvgKflM0AdlTr BtPtzcQ5auiyXPHxA8gMdWFhdnhvIzNEkP/WIip1l+TDPYa2rPsQ3Hdj1K5uv4YnYW1X 3c/j8YwBuFuceePKs8NRyhNGScN17hR+QMAF9LquI10p9rFTdgCp83SnXeGvouALxM6M aR10m8099sLnDGA35fXbrEcUr42vI2bxXmVc8Tw/3MKwF/U51ws0m6xC2ujpM8Pofdf0 JIA/FDGz1wFWVlfE0YLIEyBmNliZfNCzv3y2JFtFA15z3WoprxElfZ4qOWlMFY0Bm4dF dV+w== 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=GcN60f95EyHfAlDdNZvBkHTH/4nZm0eD62az2U/xx6A=; b=AZ6dkvylvTI2OU1jXAPD+KrnmCuLrG/fOCbdq/9UI/BI+Su176Tn5WhhEblNoD3B+1 w5/5eJ+mZE5U3f+omO7tcjiPL0yG5FTlLWVeqPdmqug02fdfbuP4+hfe5WE0fvaGjGg7 BCWhKmlKQKmJcSnvt5yLhnWVPapsIpMkzd6XKdRJCh7QbtD9EIdYGN17a+D90/xUHrrL jS8cuMWO5cHxkSu+MnczMbekRuJV1dgw0YOmoxpe5aT1V7cPGMqcDxFbwIUJJrcBpZnv pbldQOTFhRLpFdbF2rg/ETCSGvrooVM1rNtuPuHqLabd/JJzDoSDU3sA9k0wBv1YSBv/ 6hyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Ipm5aZF+; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020aa7c389000000b00514a084ad5asi5749444edq.654.2023.06.12.05.46.17; Mon, 12 Jun 2023 05:46:42 -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=Ipm5aZF+; 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 S233855AbjFLMbI (ORCPT + 99 others); Mon, 12 Jun 2023 08:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234123AbjFLMaa (ORCPT ); Mon, 12 Jun 2023 08:30:30 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E311210EB; Mon, 12 Jun 2023 05:30:17 -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=1686573016; 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=GcN60f95EyHfAlDdNZvBkHTH/4nZm0eD62az2U/xx6A=; b=Ipm5aZF+MxH/0yVuujxyILOsgp7H4wrDD1HcDBSi09vhPAyrcu2+JBURS2FlQBRIUAlqTt Jja8UVv5RfwlSCpisQfZAi+JX+mnr9jfrnLQbZ4mfwqDrFFED/4zlnwVQps9w3ZSupCiNk ohfmRQj3WQO3uzC705E0o6llbnpkmI0mUiudj1ZwkHwyelmftlADuFTTZSa9vFGDsL0zUI lGj25+tvQOdtgrO+Si6qOQI6Uj+ZgCzP7CAjP9LBgiBoKzutzcwnN4qBA5APJBSyb2hRQN wr844zVXq1KfJhygxGHI7bXDY9iXpI/s/91pWfjjSYYDaYPBs75MmKoQOj9Qrw== 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 16402240019; Mon, 12 Jun 2023 12:30:15 +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, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 07/12] iio: inkern: Use max_array() to get the maximum value from an array Date: Mon, 12 Jun 2023 14:29:21 +0200 Message-Id: <20230612122926.107333-8-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612122926.107333-1-herve.codina@bootlin.com> References: <20230612122926.107333-1-herve.codina@bootlin.com> MIME-Version: 1.0 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768501020951645047?= X-GMAIL-MSGID: =?utf-8?q?1768501020951645047?= 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 --- 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 ce537b4ca6ca..ae1a41d3a559 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -8,6 +8,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 */