From patchwork Mon Apr 29 06:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13646335 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85BA8DDB1; Mon, 29 Apr 2024 06:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714372186; cv=none; b=XJI9SjZ/1chZ/XbI2QWRk6ZJ1LLMhh6aYPO6NHN+2Smy6zxyAxprlj+uszezi6eghyRUEomZ/xdd6brhuRhYIeVHW4U1xVfggNPOIq7vIVjC+ajARzN82IVCO5bvMvBg3VuZTH+inKobxs3K6ciJkjx3aJePkkLq74W952OtYQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714372186; c=relaxed/simple; bh=WAtsg6riz3q48rqIwE1ZDk97CIJGt3cqu3KYT76J45c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FEVNZlaGnH5J7tjkbYRs1g56tX8fs/ywzSDHYtYELQHgZIRomC+qhmuuydlh0uqm5abG3x9T/EQruGcbXlhEuv15wMNU5ecPSdDIeNLfVwlXHCioM07Z9H5xd7twqZ+CDE0EKfJYXWVHapWuu/RfhSDoGQdKLPqwI443qGqWKok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E6PQi0YE; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E6PQi0YE" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e09138a2b1so3759161fa.3; Sun, 28 Apr 2024 23:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714372183; x=1714976983; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=OM8DP/40dDc9CpeuAebHNnI+MP/jkRlaYkjhPYB7kH8=; b=E6PQi0YEppfaaxmPPmyATcHpPrQOTmJm0S4PaQ5DsYy+sYPwQbLhSxHPVn0zGCdqQs Ka+i5xPkvwVCkVWhGOsJow52icax0c0Dam5y/wPRam2jIdeBIleZs8tvDwEczoX46zpl LjQ67vlBwRzLNlEj69zquIGBjUeq1nZwEXA6eaBkRQD4t6Eh69tU5eNskrgaU7gWZyBX YKhV87boGETsqQzuEkw2bgI9vev2EzeSnAbwOa/M6oFL5DN6USzrTMC+8QmKrOyw6Ekr kvrwb/cM1y+6LcCW5RYnRq3hFVySS+sTys9Id6zcR4Z3kV2B1nPEPKfh7upcSnXXIkUh 9FOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714372183; x=1714976983; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OM8DP/40dDc9CpeuAebHNnI+MP/jkRlaYkjhPYB7kH8=; b=h0L/TV4P5QYXfP8m0QzJtOp3sMWaZjCbNAxeVBSdVBzhEuhtF1viK2NktKiZdIVVX7 4cqr4ELyeRwkhTUwIHddxz1gS5Eb2f5ZO3tZ70qLATfs+tgchylWoDkymmD7cmXuShzB eFuJ3uYaBAwFTPep19k8zzZWKN++JTwxzTzOMnczoELGgA62Cb9D2NWcGSGIz7vK5KhQ eaGauGhf7NP2NjlUBjA3NIaXOfBwZsAwPyz6KoZUVN8XidNUsYrtAV2L6YGgMO/a6kxp pMWZZ6uuqc/1X6sBZUFgGuArrSieq34x5Knwd/ZT8rQktzz9TOvNOuR5iBdHtKNz3HAb +AyA== X-Forwarded-Encrypted: i=1; AJvYcCUrAn0oKWEoro7pH/95PInnDAPKo4VpgQjYLuBQFF/MbwgmMNX0LFl3z0ePP1NhruP/LIULa+QJvjWruubAv1FyRgM2IIMS6X4w3iDZ+YO5htWM19QdX4hpIeKG4hVyyanA3C53iyD2 X-Gm-Message-State: AOJu0YxRIMKAwSSw2Itox1k6SOLbpymUAodzGxIjVPPK/pu9v5BE6Dp0 bWja2YSI1qAxQ2vBvJ/YqnfGEy4K3IpGRn2WBqgzXwaMTjHc8nYI X-Google-Smtp-Source: AGHT+IEl8KgNaSEUOyX9FDK7SvJ8iwg4IfFKgqTphVmzYsM9+dosFBK1MSubwCKCx9N8LM9Q7fcMxQ== X-Received: by 2002:a2e:9fc5:0:b0:2df:6b06:b5dc with SMTP id u5-20020a2e9fc5000000b002df6b06b5dcmr7050501ljm.15.1714372182521; Sun, 28 Apr 2024 23:29:42 -0700 (PDT) Received: from fedora ([2a10:a5c0:800d:dd00:8cfe:d6e7:6701:9dfd]) by smtp.gmail.com with ESMTPSA id z7-20020a05651c11c700b002d80a2da6d2sm3575758ljo.129.2024.04.28.23.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 23:29:41 -0700 (PDT) Date: Mon, 29 Apr 2024 09:29:37 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Chenyuan Yang Subject: [PATCH 2/2] iio: test: gts: test available times and gains sorting Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The iio_gts helpers build available times and scales tables based on the times and gains arrays given from the driver. The driver should be able to list all valid register values so that conversion from register valu to correct gain/time works for all supported register values. It might be more convenient for drivers to list these times and gains in the order where they're listed in the data-sheet than ascending order. However, for user who requests the supported scales / times it is more convenient to get the results in asscending order. Also, listing duplicated values is not meaning for the user. Hence the GTS heler should do sorting and deduplication of the scales and times when it builds the tables listing the available times/scales. Note, currently duplicated gain values aren't handled by GTS-helpers. Unsort the gain and time arrays in the test code, and add duplicates to time array in order to test the sorting and deduplicating works. Signed-off-by: Matti Vaittinen --- drivers/iio/test/iio-test-gts.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/test/iio-test-gts.c b/drivers/iio/test/iio-test-gts.c index cf7ab773ea0b..5f16a7b5e6d4 100644 --- a/drivers/iio/test/iio-test-gts.c +++ b/drivers/iio/test/iio-test-gts.c @@ -70,6 +70,7 @@ */ static struct iio_gts gts; +/* Keep the gain and time tables unsorted to test the sorting */ static const struct iio_gain_sel_pair gts_test_gains[] = { GAIN_SCALE_GAIN(1, TEST_GSEL_1), GAIN_SCALE_GAIN(4, TEST_GSEL_4), @@ -79,16 +80,17 @@ static const struct iio_gain_sel_pair gts_test_gains[] = { GAIN_SCALE_GAIN(256, TEST_GSEL_256), GAIN_SCALE_GAIN(512, TEST_GSEL_512), GAIN_SCALE_GAIN(1024, TEST_GSEL_1024), - GAIN_SCALE_GAIN(2048, TEST_GSEL_2048), GAIN_SCALE_GAIN(4096, TEST_GSEL_4096), + GAIN_SCALE_GAIN(2048, TEST_GSEL_2048), #define HWGAIN_MAX 4096 }; static const struct iio_itime_sel_mul gts_test_itimes[] = { - GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8), - GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4), GAIN_SCALE_ITIME_US(100 * 1000, TEST_TSEL_100, 2), + GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8), + GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8), GAIN_SCALE_ITIME_US(50 * 1000, TEST_TSEL_50, 1), + GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4), #define TIMEGAIN_MAX 8 }; #define TOTAL_GAIN_MAX (HWGAIN_MAX * TIMEGAIN_MAX)