Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1987571lqo; Sun, 19 May 2024 07:58:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDrY/oIezZCfGqG4j//FaHsAWHTCMtm4QGSiX/Yvq1avRL8GG5CiL41g75cuHfWUgK3sv72NAfsJ6bUhg5KnPqzk7VRq9onUVtont64g== X-Google-Smtp-Source: AGHT+IFYfLdaw2qbSrZQ4cxF7+Kww+HGGt3mtw0OFAOH5wJBBH1o1Dq6HyAQmcsVYj515dBv7iIA X-Received: by 2002:a2e:8907:0:b0:2e6:f1d3:9e7a with SMTP id 38308e7fff4ca-2e6f253dbc2mr98014671fa.19.1716130688314; Sun, 19 May 2024 07:58:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716130688; cv=pass; d=google.com; s=arc-20160816; b=E+US0QN8C59wO4G6cto/IM5wN9LiY/BpkKDhYuBK0TfT+romaIrW988uxa5GJn2Klm 7T0zRQGv5T8xIK/QPU8RSpaHTu/iVQSViYcMTD7vK8xqb8rGPNbhWy9rueAdcMWtG2ri KWdWKLy5zi3VwFvAR/EoGb9yaDOgdNiqSi1PEcdUvWRkhYBpgmb3dn0NrPPFKj9+AlU9 ZKpp45Do1DW7g5mEOeb4ZI+3/GOip9mdMl2Fg21ADtCtXQ+1e6Dc5fa2deFroBOxHcJZ yObTF+InGU+zuNK1QD2BW2om3GKBF5oLKNxh2BLwafY/sIq9kf1EdMXm2YM+vWSqOh+H OWDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=0GQttIYVZJFn3RowTVlnrJ+Xt0DDilmFIEg9l1RqqJA=; fh=lrKJEuNGjj6wFFW3++lIiLGeo+C9znRs/F/0TeZwjEg=; b=f7+h69dRsjIjN0LirfcYB1RIon19UbTDkcEX4CObDrBoOHyqvHK+HRaWrzRQ9SZKV+ 6W0WvPxcKswJ1OMsBRWhzr9xNTUa+eFGHLGTnyeyx9CL3HVYekYriU+UBngRCQqfmiFL F1FFXmGC37EgY5PskEbecaeuNrx9oIa6SM/ywSS1BmcVlSXs3oinDQ/Bj50TOiNvoUXl 7eywLLRXWJFRGXtgKE1EMfBb0tpxo1qpfUtxlRDS0tTKI7nrVkeotNIUq4NVwZTWXr+G h6R4WYLq9Zkydcwj0mNM1qXo062a+49h6L/mTPc8nEkuNUwdvZMGwIQbafCoFRL4krp/ O8kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (body hash did not verify) header.i=@freemail.hu header.s=20181004 header.b=OHk9Jm0i; arc=pass (i=1 spf=pass spfdomain=freemail.hu); spf=pass (google.com: domain of linux-kernel+bounces-183136-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183136-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c3782acsi734882a12.649.2024.05.19.07.58.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 07:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183136-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@freemail.hu header.s=20181004 header.b=OHk9Jm0i; arc=pass (i=1 spf=pass spfdomain=freemail.hu); spf=pass (google.com: domain of linux-kernel+bounces-183136-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183136-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 088411F210E1 for ; Sun, 19 May 2024 14:58:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 487CD4CE09; Sun, 19 May 2024 14:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=freemail.hu header.i=@freemail.hu header.b="OHk9Jm0i" Received: from smtp-out.freemail.hu (fmfe13.freemail.hu [46.107.16.206]) (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 3DB9C4C3D0; Sun, 19 May 2024 14:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.107.16.206 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716130681; cv=none; b=Bn7tkdRChuzc7vSmqmKDEiwhzuQaoAao3RSvLLIc5MMeAdgRahjL9FOyr/LAIzHq2zvKs5XnR4yuddmEqbMmMTW5h+To2T/+3Pz3GqN5PpyLI1IGuLc1P9y0T/ZySteBrYjEkKvth3XC31k3+GVXnO8NE5/tSzru8lOwFFYJKWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716130681; c=relaxed/simple; bh=dWYOsLIM7FL8+/64nPxITcuD7Qb2BvNMwaAg0W2ZHg0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=OKdQLjlxAuU4q99oGdhygBeDLXXnCWse22d+HOogGeSZ5DaSCZfXCTVSDOuP33A344jMUxDdqaFgog3vlUEhj9i3wFcbZ2U4O0RbRRghwVDZSjKHrL2XLFIzm7SX5nlBicqJuQlb+bTRDtPIWCW/ZeVjEpmCNxCV3Qe1iP83zWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freemail.hu; spf=pass smtp.mailfrom=freemail.hu; dkim=fail (2048-bit key) header.d=freemail.hu header.i=@freemail.hu header.b=OHk9Jm0i reason="signature verification failed"; arc=none smtp.client-ip=46.107.16.206 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freemail.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freemail.hu Received: from fizweb.elte.hu (fizweb.elte.hu [157.181.183.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.freemail.hu (Postfix) with ESMTPSA id 4Vj3WC6mS0z2wb; Sun, 19 May 2024 16:49:27 +0200 (CEST) From: egyszeregy@freemail.hu To: linus.walleij@linaro.org, brgl@bgdev.pl, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Benjamin=20Sz=C5=91ke?= Subject: [PATCH] gpiolib: Introduce "linux,gpiochip-name" property for device tree of GPIO controller. Date: Sun, 19 May 2024 16:49:20 +0200 Message-Id: <20240519144920.14804-1-egyszeregy@freemail.hu> X-Mailer: git-send-email 2.39.3 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=UTF-8 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1716130168; s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1538; bh=0GQttIYVZJFn3RowTVlnrJ+Xt0DDilmFIEg9l1RqqJA=; b=OHk9Jm0iKdTFvzScjmcsHlxMIVR1jFsbsshLzUR5mEHD8v9kK6ByNumfSwwzzirz G7ItD5IAnuLl8cbjI1JEwkuP8ssUPmr5VTEl3tIfh0/gy48o628DQKvRLQv1OHRtbmE pqAh85X0rwz8S/XXHxj7X+5DIFb5jBEanFDgAlwhYI2btBDYjC2P9vF4s1PZ/Elrxcz awFCWJa0rvbJLUw/RPRwPm5PzjbhxfQOjxnHcs7ewvbeB/JhK8WzBaTb9okX1zRQ6hi bFKwgJfIIe4v9EG7Ii+1mTeBsWLOZewvCVdF9wh6Sx/JLmD+PKRHhdp2fjKJGlDiv/p Q5G2v5ofiA== From: Benjamin Szőke Optionally, a GPIO controller may have a "linux,gpiochip-name" property. This is a string which is defining a custom suffix name for gpiochip in /dev/gpiochip- format. It helps to improve software portability between various SoCs and reduce complexities of hardware related codes in SWs. Signed-off-by: Benjamin Szőke --- drivers/gpio/gpiolib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ce94e37bcbee..e24d8db1d054 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -860,6 +860,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, struct lock_class_key *lock_key, struct lock_class_key *request_key) { + const char *name; struct gpio_device *gdev; unsigned int desc_index; int base = 0; @@ -896,7 +897,16 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, goto err_free_gdev; } - ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); + /* + * If "linux,gpiochip-name" is specified in device tree, use /dev/gpiochip- + * in Linux userspace, otherwise use /dev/gpiochip. + */ + ret = device_property_read_string(gc->parent, "linux,gpiochip-name", &name); + if (ret < 0) + ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); + else + ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "-%s", name); + if (ret) goto err_free_ida; -- 2.39.3