From patchwork Wed Jun 21 06:26:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13286705 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 52D00EB64DD for ; Wed, 21 Jun 2023 06:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbjFUG1k (ORCPT ); Wed, 21 Jun 2023 02:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjFUG1i (ORCPT ); Wed, 21 Jun 2023 02:27:38 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C4D1B4; Tue, 20 Jun 2023 23:27:37 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id C4C645FD60; Wed, 21 Jun 2023 09:27:35 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687328855; bh=YQ2V6XFLUgswbRr9qW2w1qbMLzV+8NemKwLTVnCTW20=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=P0RFbgc1pyUJ+agr3Fgq7ek7/svzYSn2J7N/OS6uTcZg3B2a3hwDtBp3UxcU8q6C/ l9pVg5ImyYIR9AAxNXQXS52aA+jUJdlXNTYIZBOtshfy00OCyYV4EdqmHBkW/G3Swy IukM5IA8dgn1ha9uNv8TsLQ2RHNYvG+CnaDCe67Aqe6XzFvoqnwweXrd/KDLccrrv1 l8WPnwsu/9F9vQMyukKr0DfRSSZFL12ixfY8TTAHdEt7GxfowuUmjuH7/vHQoRki59 kLrG/ffRzaJEwQm0zAhP7YWY3rSEpmd5+6P1UvHswnO+gD3xszicSOy1ZB+NBVDjre vuVpuXmi3CRmA== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Wed, 21 Jun 2023 09:27:35 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v1 2/3] meson saradc: add channel labels Date: Wed, 21 Jun 2023 09:26:09 +0300 Message-ID: <20230621062715.455652-3-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621062715.455652-1-gnstark@sberdevices.ru> References: <20230621062715.455652-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/20 23:30:00 #21539802 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org patch adds channel attribute 'label' with channel name Signed-off-by: George Stark --- drivers/iio/adc/meson_saradc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 42f0389e123d..66d6f527122c 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -1044,8 +1044,20 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) return ret; } +static int read_label(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + char *label) +{ + if (chan->type == IIO_TEMP) + return sprintf(label, "%s\n", "temp-sensor"); + if (chan->type == IIO_VOLTAGE) + return sprintf(label, "channel-%d\n", chan->channel); + return 0; +} + static const struct iio_info meson_sar_adc_iio_info = { .read_raw = meson_sar_adc_iio_info_read_raw, + .read_label = read_label, }; static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {