Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp868075pxj; Wed, 16 Jun 2021 15:50:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoGRmpvjwXj5bRsH+ZWiDm2iujb34rneC0kg3qAOxkuK2fSKax8VssvrRNbn+SETkHFmJ4 X-Received: by 2002:a5e:db02:: with SMTP id q2mr1288507iop.103.1623883800290; Wed, 16 Jun 2021 15:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623883800; cv=none; d=google.com; s=arc-20160816; b=llM6aQvJlzrgyiXshQ0mlrHIc+8vdZiC2R6+bJh2EP6/VvBTwUbwBfGIPmYjuhfjLQ /tMuv3A5f43MtwmYvpvjc/LG0xfGAve0+WnvcghES7bJsZGnGlJqYCa00pJYNJSnAwZR m9IKDeJCwSUDiO9HSTYm+oiDI815Zb5+fOQBfQtb1m5i1ToF14Tra5hjn+xwOe15nVb0 6hShb8coCrerxKEnjmaWaoJ+XWXQRZdsHHAiGOhYXtsU3FiYJWjbjMEFO5/mtXQ8uC1B c22l7DRM6/VjTlO74241+QQpKGOJ9eWeXY+u/5if2WIAHPW5JoSTShHQmhQQyt+ZX4+s 9p/g== 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; bh=Pnumao7m9HXp0x+GuD1hRFlXt5xfVohRABdpAn04g+Q=; b=STasqX9bLUtjuYfVv1YvhwvQP16atDa1bx7IZ53rZZo7hjbrUdaROWhwGBPHVQifO6 d5jxDIknA01UuVEjsvHTbhcpZ1O2/0daYFScL7VUdOt+L9MbM8qYCdqO2etV3hstRfBo Kxf2VfgfSfCSuKJ/SmuJEnJKM5OT4OJOTER/nz9iF6L0xmSXJyZhbA7HlYvr7eAsjMAg hMJ1frf1WXwQOVAdgg0C+29zSd3tSpzyme4ELVADKMP+gytQ6RLi1tevIzZrNGXmX0Ja 4LOpSgeuW+4XBhmkHSogPUfgy7hvoF/EwllXzXoIyGnvezCk0R7FO0kpzPRBTWWZ6XwX v3tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si4627810jan.14.2021.06.16.15.49.48; Wed, 16 Jun 2021 15:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235250AbhFPQAO (ORCPT + 99 others); Wed, 16 Jun 2021 12:00:14 -0400 Received: from aposti.net ([89.234.176.197]:51040 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234677AbhFPQAF (ORCPT ); Wed, 16 Jun 2021 12:00:05 -0400 From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH v2 1/2] iio: core: Forbid use of both labels and extended names Date: Wed, 16 Jun 2021 16:57:05 +0100 Message-Id: <20210616155706.17444-2-paul@crapouillou.net> In-Reply-To: <20210616155706.17444-1-paul@crapouillou.net> References: <20210616155706.17444-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extended names are a problem for user-space as they make the filenames in sysfs sometimes not parsable. They are now deprecated in favor of labels. This change makes sure that a device driver won't provide both labels and extended names for its channels. It has never been the case and we don't want it to happen. Signed-off-by: Paul Cercueil --- drivers/iio/industrialio-core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 59efb36db2c7..81f40dab778a 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1836,6 +1836,24 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev) return 0; } +static int iio_check_extended_name(const struct iio_dev *indio_dev) +{ + unsigned int i; + + if (!indio_dev->info->read_label) + return 0; + + for (i = 0; i < indio_dev->num_channels; i++) { + if (indio_dev->channels[i].extend_name) { + dev_err(&indio_dev->dev, + "Cannot use labels and extend_name at the same time\n"); + return -EINVAL; + } + } + + return 0; +} + static const struct iio_buffer_setup_ops noop_ring_setup_ops; int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) @@ -1860,6 +1878,10 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) if (ret < 0) return ret; + ret = iio_check_extended_name(indio_dev); + if (ret < 0) + return ret; + iio_device_register_debugfs(indio_dev); ret = iio_buffers_alloc_sysfs_and_mask(indio_dev); -- 2.30.2