From patchwork Fri Oct 6 00:50:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 13410901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2477EE92FD2 for ; Fri, 6 Oct 2023 00:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbjJFAwK (ORCPT ); Thu, 5 Oct 2023 20:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbjJFAv0 (ORCPT ); Thu, 5 Oct 2023 20:51:26 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341B110B for ; Thu, 5 Oct 2023 17:51:17 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-1e0ee4e777bso1025862fac.3 for ; Thu, 05 Oct 2023 17:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1696553476; x=1697158276; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZI34v4vwW5XM25KikYNf+BGSccyPUhljKdJ83kHWmf8=; b=W88TPZ6QR+KDZ+09EoFJ/KBVc4pnUxcEojw+6zoyfpGjhich4bo2/seVj2CM5P1GNu 7/Smx4NQk2BkDjEjLhUSkClE7CreWs8lT5BILrr0nX1yUba1hENSZKbhEBiA1Ktjf62/ OVQpRMzZgKS922x8uTqI3SDfupHT8RQ9+bRVcOSvbynji/DEnOZihy2RIkY+LdJ+j4V7 yDRLxYEBUK5jPbP20g4C0ea76UwaJlZZggAQUkQHrHB4QLskbLKzTpAZp4y4Q8o4FFqF wOYGFcjQENIVLP3un9bI5hESapaYutfu21I7zATPf1dsw1GAGTXya6ibPy+IbQsMesC/ pBlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696553476; x=1697158276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZI34v4vwW5XM25KikYNf+BGSccyPUhljKdJ83kHWmf8=; b=IPG1MExkULUl0r/Ub/x7nixIeT9VjWEKQ6l48MKyA+/znVYw51kMJ2rxHfTIZ+5fSA cEEZ7ZjRCr/WYFddftQAwv0wRWlLUCHrxkBdtIfyy7fcBLw14hrQMn5Ea0i77p/9VuYE RZdXaw3R3Jer/ybeN65ZJQZnM+LsVzBIKZgIAA5o2CatJ52gf9nVnWASuAGMxPZhVIq7 vvURaKVH3rdvx0xFmxsbnwIM+B0bPCcgvwx+yIFNk0ufvrUV82b6MRz/KwZzk/NQCetu nZDGvyK7unaZagTK9Xw+2PwZYdDZ4ZpsppROES0p/W7+6gJQT/isGby5GMzq45xb6kzp nmQA== X-Gm-Message-State: AOJu0YzUysp266ISmc2Bx9qCLJJ4vLCQgB+kZJy1zrOGBHWQwx6qjWN8 XUqaf+ub2H4VjXzEe0gWvMdt76UQikLCdQJXsb6ilQ== X-Google-Smtp-Source: AGHT+IEchoMTXOEbw8NFS2gMIPHbq+oGOliYuhmKz8ENK3CaoNOlDvSRLvdogehnLIb+B2nw1m1lEg== X-Received: by 2002:a05:6870:1490:b0:1d6:56d8:a788 with SMTP id k16-20020a056870149000b001d656d8a788mr7430599oab.40.1696553476450; Thu, 05 Oct 2023 17:51:16 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id mo9-20020a056871320900b001dd0ff401edsm545072oac.51.2023.10.05.17.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 17:51:16 -0700 (PDT) From: David Lechner To: linux-iio@vger.kernel.org, linux-staging@lists.linux.dev Cc: David Lechner , Jonathan Cameron , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Axel Haslam , Philip Molloy , linux-kernel@vger.kernel.org Subject: [PATCH v4 15/17] staging: iio: resolver: ad2s1210: add label attribute support Date: Thu, 5 Oct 2023 19:50:32 -0500 Message-ID: <20231005-ad2s1210-mainline-v4-15-ec00746840fc@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231005-ad2s1210-mainline-v4-0-ec00746840fc@baylibre.com> References: <20231005-ad2s1210-mainline-v4-0-ec00746840fc@baylibre.com> MIME-Version: 1.0 X-Mailer: b4 0.12.3 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The ad2s1210 resolver driver has quite a few channels, mostly for internal signals for event support. This makes it difficult to know which channel is which. This patch adds a label attribute to the channels to make it easier to identify them. Signed-off-by: David Lechner --- v4 changes: * Adjusted for channel rearrangement in previous patches. v3 changes: This is a new patch in v3 drivers/staging/iio/resolver/ad2s1210.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 51490fea1647..59c8eed26701 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -1158,6 +1158,34 @@ static int ad2s1210_initial(struct ad2s1210_state *st) return ret; } +static int ad2s1210_read_label(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + char *label) +{ + if (chan->type == IIO_ANGL) { + if (chan->channel == 0) + return sprintf(label, "position\n"); + if (chan->channel == 1) + return sprintf(label, "tracking error\n"); + } + if (chan->type == IIO_ANGL_VEL) + return sprintf(label, "velocity\n"); + if (chan->type == IIO_PHASE) + return sprintf(label, "synthetic reference\n"); + if (chan->type == IIO_ALTVOLTAGE) { + if (chan->output) + return sprintf(label, "excitation\n"); + if (chan->channel == 0) + return sprintf(label, "monitor signal\n"); + if (chan->channel == 1) + return sprintf(label, "cosine\n"); + if (chan->channel == 2) + return sprintf(label, "sine\n"); + } + + return -EINVAL; +} + static int ad2s1210_read_event_value(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -1338,6 +1366,7 @@ static const struct iio_info ad2s1210_info = { .read_raw = ad2s1210_read_raw, .read_avail = ad2s1210_read_avail, .write_raw = ad2s1210_write_raw, + .read_label = ad2s1210_read_label, .attrs = &ad2s1210_attribute_group, .read_event_value = ad2s1210_read_event_value, .write_event_value = ad2s1210_write_event_value,