Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1561890lqz; Mon, 1 Apr 2024 09:48:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5aWHbwQc2S9qFOsHU7gBUVrZ5UzsTA+AbwqKyL8sZBh+7gA/YcKXi42KQBsakulzkvr31BGJUg3bqBJEbeAxQNyZkLH3fzkOIUowXHw== X-Google-Smtp-Source: AGHT+IEKjxpwik/PaDNOtOFljpOcO/t70aGqBdEkXEAbSWbPypRpjs7JanwEQlmFcqQxF+EzEeIx X-Received: by 2002:a05:6a20:c891:b0:1a3:cb50:b52d with SMTP id hb17-20020a056a20c89100b001a3cb50b52dmr14536093pzb.31.1711990092214; Mon, 01 Apr 2024 09:48:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711990092; cv=pass; d=google.com; s=arc-20160816; b=O53Eyh8ICpQvFCR5SF8bLg+GeiHbTwl0M+1iGju7hDbEHhsyE8KY3WQFYn8ZhXjd62 z3hbTeONWeGaYlt5uNWIesJLuYqxLWp0duk/1PVi56EMsF2388gdj9FBz8eC1pcqAnhu Shk1NTakR1/9j4w/eJC9DNVXH3CLKMgtEPziwpIuM8zGqQkSS194XlbS5R9BZfIijLFF duEltFG6/D2FYth+wkB7dlK6I/ePFhPywJuBeBA+6nIq4fHY3dYi2sBUxx9r0ouzv5pn 0+ruBtRoWEXvdNcRnnZKX5kWXU7AI/IFnPQtZRgK6b8yutmBdmfJtSR0n3PGWQkHYVMj xQFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=jP7yH1L0395d91fy4k5VLj3ACpYrVSxQN7+L+l8qwLQ=; fh=fG7lb0bAiMtML71awQlmd8rLWChPakYr9NUwMFSeD5M=; b=CMBmcYqcL1n2JfWS0zWx9Z9aMzUCesGga45myrONz/cNMk+KdgLpvJXplVhbbZ4Bip PIgLJm7hTFh6WXYsHPnlkU0RExnIjthXa2wPlgAHq9KSt/4QHZ6xDl8nZiFoA73Vz9sK eI0agWU6MCUGv+FrNHcKROKcLrQ4xcW9GtMyZINFDylTaGbz1kygMtuVXgX0rRWfwJ8A jseSggGQlJKuh6xNCA4ipOS0dArNyDegOWKID6hyQOiJjO6XEROZh6rmfvwSeM7tay0a yqKrljbjTxPWBVGfGVOG+PQ3QyWI9tzp0qUGrgUAqzuQiSCEBbvL2hLT6XrBAo9kjQtv iyyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-126867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e8-20020a17090ab38800b0029dd816e84fsi11264278pjr.180.2024.04.01.09.48.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 09:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-126867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D495928352F for ; Mon, 1 Apr 2024 16:48:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7ACE9482F6; Mon, 1 Apr 2024 16:48:05 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AB95481C6; Mon, 1 Apr 2024 16:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711990084; cv=none; b=bMZ9wNCXyXg5HkdoaRSlqINupYquyPOSUC4QbRcrUwCZS0dlQHCm2sZkITA5xgWEcTmkQejmCIRZDJLryl9S34j7OBD5pdTFDse30KH+ixxSdAa4bvCediPjvQsv8yoGMuR9Z3r13yv/8Y0aEYzHvLvqt12fkCVfpSoLibanhQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711990084; c=relaxed/simple; bh=804Vw/RbErS2pmzr890A96kbwN5Kbbf7T2Xg3aXgqik=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HX7eknx49X4YYDrjW9oSrSRsZUFPc1jb7IBAiSTauuzVc5Oth4pwYesVzjYmeHyxbIhBm1+aFGi42GFf4IPdYXx2UDVh1B5+0Fz32QhRK8JEkTz7PC2GiYzznyHhoK1oxRL9rV3TVbKGoAvCy6phYwJHCdCvpU/O998x3yoTSrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4V7cJq34QHz6K7JS; Tue, 2 Apr 2024 00:43:23 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 728E51400D9; Tue, 2 Apr 2024 00:47:58 +0800 (CST) Received: from localhost (10.48.156.172) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 1 Apr 2024 17:47:57 +0100 Date: Mon, 1 Apr 2024 17:47:56 +0100 From: Jonathan Cameron To: Dominique Martinet CC: Jonathan Cameron , David Lechner , Krzysztof Kozlowski , Syunya Ohshio , Guido =?ISO-8859-1?Q?G=FCnther?= , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , , , Subject: Re: [PATCH] iio: industrialio-core: look for aliases to request device index Message-ID: <20240401174756.0000786a@Huawei.com> In-Reply-To: References: <20240228142441.00002a79@Huawei.com> <20240318122953.000013f3@Huawei.com> <20240331152042.394b4289@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500005.china.huawei.com (7.191.163.240) On Mon, 1 Apr 2024 17:18:31 +0900 Dominique Martinet wrote: > Jonathan Cameron wrote on Sun, Mar 31, 2024 at 03:20:42PM +0100: > > Hi, got back to this finally... > > Thank you for taking the time to express your thoughts! > > > So the problems compared to other 'alias' users is that IIO is a bit more > > complex than for example LEDs. A single DT node/compatible (or equivalent) can > > result in a 1+ IIO devices and 1+ triggers. > > Right. I'm no longer really arguing for it at this point, but for > comparison in the patch I sent, the alias sets the start of the idr for > the device index, so if you have a driver that creates two IIO devices > you could just "reserve" two for this DT node and assuming the order > within this node is constant you'd still get constant numbering, so I > think it still somewhat holds up here. > > For triggers though the numbers are separate and it wouldn't make sense > to use the same alias, if we wanted a coherent design with this we'd > need to add a second alias (such as iio_trigger = ..), but that makes > much less sense to me given they're also likely to be dynamically > instancied via configfs from what I've seen; I wouldn't want to do this > kind of mapping, so I agree with you. > > > So I've messed around a bit and can think of various possible options to make > > this simpler. > > 1) Use a tmpfs mount and link from that. > > Now we 'could' put an alias directory somewhere under /sys/bus/iio/ that > > is a mount point created via sysfs_create_mount_point() - I abused the > > /sys/kernel/debug directory to test this (unmounted debugfs and mounted > > a tmpfs). That would provide somewhere in sysfs that allows suitable > > links. However, this is unusual so likely to be controversial. > > Agreed that's probably not something we want to put our hands into. > > > 2) Alternatively the relevant platform could create one of these somewhere > > outside of sysfs and use udev rules to create the links. > > I'm not sure I understood this one, something akin to the udev rules > I've showed that made links to the /sys iio device in /dev? > "relevant platform" here would be vendors? Yes. Just somewhere other than /dev because I agree that feels wrong. > > > 3) Stick to the oddity of doing it under /dev/ > > 4) Access the things in the first place via more stable paths? > > /sys/bus/i2c/devices/i2c-0/0-0008/iio\:device?/ etc > > Relying on the alias support for i2c bus numbering to make that stable should work > > and if you are sure there will only be one entry (most devices) that matches > > the wild card, should be easy enough to use in scripts. > > > > My personal preference is this last option. Basically if you want stable paths > > don't use /sys/bus/iio/devices/ to get them. > > Hmm, I wouldn't call that path stable given the '?' portion can change, > but at least that certainly is a single glob away so it's definitely > simpler than checking every labels all the time. Agreed - this does rely on that wildcard. > > My second nitpick with this is that while these paths are stable for a > given kernel version, but we've had some paths changes over many years > (not sure if it was 3.14 or 4.9 but one of these perhaps didn't have > /sys/devices/platform yet? and things got moved there at some point with > some subtle name changes, breaking a couple of scripts). > OTOH /sys/bus/iio/devices feels less likely to change, but I guess this > is something that'd come up on tests when preparing a new kernel anyway, > so this is probably acceptable; I'm just thinking out loud. Agreed they have changed in the past. Mostly a case of fixing up devices that didn't have their parents set (there are lots of those left - that reminds me that I was cleaning up perf drivers that do this wrong last year and only got part way through it :( We will keep the /sys/bus/iio/devices/ path the same and continue to support all paths below there (there are already compatibility links in place for buffers for example from when we added multiple buffer support). However, sysfs docs are pretty blunt on not relying on reliable paths for classes (and the IIO bus is effectively a class from this point of view). > > > With that said I can't think of anything that'd work everywhere either, > so I guess we can stick to the status-quo and I'll rediscuss what we > want to do with coworkers. Good luck. If you have time it might be good to hear what you end up with! Thanks, Jonathan > > > Thanks,