Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2807921rwb; Mon, 15 Aug 2022 11:45:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4aEaejA5EtRXXJPx2lhSUSxMweLq0gvXIgM7VCqn/E2M05M/HwZQm34mxSHb7wOT6wbK5V X-Received: by 2002:a05:6402:110a:b0:443:225c:6822 with SMTP id u10-20020a056402110a00b00443225c6822mr15184538edv.81.1660589120187; Mon, 15 Aug 2022 11:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589120; cv=none; d=google.com; s=arc-20160816; b=aCf/uqTBzMRsxe4MMYxqFHIKJsUviS0F5WzUeTT831N5va5JEHvU2PjufaOY+Ft7HD DRyOTa0+Xx4CD7Kz01QSrg6+jM2Vy0aeGHe0SzlYG5wRbAQZBwXYRC1VWM85SqrUibub rUwrKJzPl8A6BbsD4Wo9qGy9meFPC1B3cRAvtUKFgAecqDo/H+ZSYF8zXPe5UkDWvjfC NnWayhs6rhN2pgkMpz4JQy4zv+7QPlxfeIdHqskBYBPq4t9q2OwoHjDDqLEmbsooSK9j Ud/PB7Yczq29jGw7En3ZuY2rqFva0nwnH+1q/svN0zX59TA6ZqWlwJ//Go4Mmw93XsSE zDpg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dQpcnMpdHs6VSX9MtU7JkbT+wTyP+pAnkICwS96+vSg=; b=v9FBauotFr9r7gdxVsclL6Tc4B33JUYJ/N16Bjwg98saL361n988vPrA/syJRwgulz yptctt28BVPiBpPogC/fylkJT9I3rEJpSuD4J+047OUf6taGJq8SCVohxMeKE5Qely+W Tu5UOIs1neowmsdg64PcAKCPacVZCXfhp8s5yLEPt2jLrc9kqDN+tT3RivqCoaY7DnwI 1w64xKIGJ/MdZa82jsdVjZLeq/uE1DRxB2hyadsZZvPt1yQYHIeGpbNNxMWYMqMwdSey gpunUKZb+idSoe8udvTBP+mPaEehBF98GLdAb57BN5Wk+nMfoTW8vd4fVDPN3eUA9LCr e6ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aCg4oG3S; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a056402354c00b0043bb8df080fsi8027672edd.606.2022.08.15.11.44.54; Mon, 15 Aug 2022 11:45:20 -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=@linuxfoundation.org header.s=korg header.b=aCg4oG3S; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240882AbiHOSVu (ORCPT + 99 others); Mon, 15 Aug 2022 14:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240654AbiHOSUo (ORCPT ); Mon, 15 Aug 2022 14:20:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 429D02C669; Mon, 15 Aug 2022 11:16:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D950CB8106C; Mon, 15 Aug 2022 18:16:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31FC0C433D6; Mon, 15 Aug 2022 18:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587406; bh=Atfdsdi8h9Ub1cnJDu2gkrI2QGWBUcfrKIUIaTCa4Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCg4oG3ST7hmD+wOEyVZ+wfnPBt+4bqWf0Z7Cb0PO3M5tbQN7zqqbk8lC94Jpvt7W gmKibv0Dz3MhtJSmxZAJHYu2zVhcT2swwB9yDX/qEldXeMz6bInfQHxDKB3JgjGzFp N82rhLYAL+/WOa1yXILXPnQ4LbJVNyenyXksJiR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fawzi Khaber , Jean-Baptiste Maneyrol , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.15 076/779] iio: fix iio_format_avail_range() printing for none IIO_VAL_INT Date: Mon, 15 Aug 2022 19:55:20 +0200 Message-Id: <20220815180340.548731211@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Fawzi Khaber commit 5e1f91850365de55ca74945866c002fda8f00331 upstream. iio_format_avail_range() should print range as follow [min, step, max], so the function was previously calling iio_format_list() with length = 3, length variable refers to the array size of values not the number of elements. In case of non IIO_VAL_INT values each element has integer part and decimal part. With length = 3 this would cause premature end of loop and result in printing only one element. Signed-off-by: Fawzi Khaber Signed-off-by: Jean-Baptiste Maneyrol Fixes: eda20ba1e25e ("iio: core: Consolidate iio_format_avail_{list,range}()") Link: https://lore.kernel.org/r/20220718130706.32571-1-jmaneyrol@invensense.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/industrialio-core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -818,7 +818,23 @@ static ssize_t iio_format_avail_list(cha static ssize_t iio_format_avail_range(char *buf, const int *vals, int type) { - return iio_format_list(buf, vals, type, 3, "[", "]"); + int length; + + /* + * length refers to the array size , not the number of elements. + * The purpose is to print the range [min , step ,max] so length should + * be 3 in case of int, and 6 for other types. + */ + switch (type) { + case IIO_VAL_INT: + length = 3; + break; + default: + length = 6; + break; + } + + return iio_format_list(buf, vals, type, length, "[", "]"); } static ssize_t iio_read_channel_info_avail(struct device *dev,