Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2035753lqo; Sun, 19 May 2024 10:02:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnEwPuRrvt05JhTJiL/iKiXPxr9IIeT4r6iAXdf84gXaSQ0hIotIbMb8L90BLa9F8zBZ0Nk+55sVh1QZYHy/Kbz6dsQJR32E5wWl3cHg== X-Google-Smtp-Source: AGHT+IGXJz+45gBsQ7fJkR07LyxvXzRuQu3TlXu5qjR7IBXz/eHjZBZg3LFQQNvN2vt5C1z3EDgr X-Received: by 2002:a05:6102:26cd:b0:47f:3e87:7350 with SMTP id ada2fe7eead31-48077dcf91cmr22005807137.1.1716138157168; Sun, 19 May 2024 10:02:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716138157; cv=pass; d=google.com; s=arc-20160816; b=v1eSie2+0qxQQpTkyxFYf7xoc76b3ASjcLm+HTOAVI1RKvJZQWxcQEoyJhW87d2GO9 gs+xpz0GPVIsPJ7bEnytzocki1P1WgBAZEe7sWmDyirTlJjsYmw1BEoiEUD8wCh5/+CU TQZpe4FaOzoAjibq9FhWsEaeqfwcY9LmRxLTl9tItCO3pKhJ31qFreDQsK7sEwS2aYyo Kgnde6SG7Esk8NpyeiEOxiS6vkP2Q5jKnogAsGfuawOs3nSoWOrWFypBttsf/VnVVPgD Kdixmfd9d1nmW1lYBNC7ATWoahhT52K9iTKdwAxvN96Ot15XdXsSJEbotxdcVQI3Y6nl vfTg== 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=SpZ0hi7sZoilYx08Os0iQ7zMl6chRN/0TUPqVc9082s=; fh=4RgFx6G4a702IkxVKw7/FfMONg0/6GTpqTzG9NCK3Sg=; b=rFPJZRRZEzncuP/ShdHAZoW+9DLUapS/i3LF/MtvdsWYJVu6bGuLYbw/1jBoRX912Y Ln+f/gYTxFn0W9/m5r8yoiuvfywtJhq5DemzzPMUCczhgwf9CbeSrtrnvQikGNdiyWfO JZ4laiK3Y+80zb8MaL3MRCmGiRt1fzRd3CsUB7Ab7Xxw1g6EargdbkX6mSitJTlENHdx mPtxZ8G3WqzLTvsbkFMeC/UCubgjrCjshgxufH8iYl1oNNcxXr0+/4iihD1CCQ30F4S8 P3hDlX1yjfqhguKJenuUTNGkzw3ARt3JNoQtEmXaZutagh86BYrJXvAmwR6J9DmcHc+N oTTw==; 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=PcgcU1SF; arc=pass (i=1 spf=pass spfdomain=freemail.hu); spf=pass (google.com: domain of linux-kernel+bounces-183163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183163-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ada2fe7eead31-4806cc40caasi4003529137.328.2024.05.19.10.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 10:02:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@freemail.hu header.s=20181004 header.b=PcgcU1SF; arc=pass (i=1 spf=pass spfdomain=freemail.hu); spf=pass (google.com: domain of linux-kernel+bounces-183163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183163-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C936D1C20BA6 for ; Sun, 19 May 2024 17:02:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DD654D9F4; Sun, 19 May 2024 17:02:31 +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="PcgcU1SF" Received: from smtp-out.freemail.hu (fmfe28.freemail.hu [46.107.16.233]) (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 7713A1E867; Sun, 19 May 2024 17:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.107.16.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716138150; cv=none; b=ic6KbYNZdATdr3afDmDC2vExXn9NKJ2gly8ZWDDaqwbQact+St2LA5PB94erMegwd/HV7+DVg2h0RNFxAxWDNZrg8ZadcFdf13BKZcZrLXbSpdCsdlqJ6HeRdOd1EfThpA+cx/Arkn+7tKNSq6ErYCkmkBSR6S+hkjrIr9fO37M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716138150; c=relaxed/simple; bh=z0HEpwuxgZUJe2+XFOQ3mW/AL7YeIiVbzyFq4gc3vbE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=ESd5Nat8pyPArAHn8omObx3VpQL6EhKZap2oi7J5SaLcPih/260EXaT+Au7fkUbYVFTwqZMH5QKj0Qkz9lwyePtlIacWtUzFBFd1vJNvNRMGmkWLWYk9oxc89awbypTezz4VcVZ5ppJp0ioxF67ylJMCkt9RJVub/Uxos/71+nw= 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=PcgcU1SF reason="signature verification failed"; arc=none smtp.client-ip=46.107.16.233 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 4Vj6JH3s6Lz4dp; Sun, 19 May 2024 18:55:11 +0200 (CEST) From: egyszeregy@freemail.hu To: wsa+renesas@sang-engineering.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Benjamin=20Sz=C5=91ke?= Subject: [PATCH] i2c-dev: Introduce "linux,i2c-dev-name" property for device tree of I2C controller. Date: Sun, 19 May 2024 18:55:04 +0200 Message-Id: <20240519165504.19627-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=1716137712; s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1506; bh=SpZ0hi7sZoilYx08Os0iQ7zMl6chRN/0TUPqVc9082s=; b=PcgcU1SF4t47qJMHd47C/PTdJAf+Z0cHl4+46HozeIKSY16BYsXFtOjdPhcOQP++ uc3KwZqMX992JtvPfoC2C/HaB1OnKU2gjVQdU0Kpg0nl+QZy2lGftFVsu38ssEzPW/Q 9zX9ep+t84aa2WQJjO7l/YEHwJcTAcE4u/qnrqgiqn6TfIJDp36Qm+PJjUY8UGpKX+7 DRCW56Rf09VQj9wtuH+WQSenE01qHsneU+fpUUuJOztA/I9PIADrkrmaIsdmVbK/o39 GjMG8aRzVDDc0TG5kqRM+NDUNFv60ABOJPxrheeIegW29Nrcdx5oOx8ZZj8Ih9Wr5z5 xxV756CF9w== From: Benjamin Szőke Optionally, an I2C controller may have a "linux,i2c-dev-name" property. This is a string which is defining a custom suffix name for I2C device in /dev/i2c- 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/i2c/i2c-dev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 8b7e599f1674..df4cec88ea59 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -651,6 +651,7 @@ static void i2cdev_dev_release(struct device *dev) static int i2cdev_attach_adapter(struct device *dev) { + const char *name; struct i2c_adapter *adap; struct i2c_dev *i2c_dev; int res; @@ -672,7 +673,16 @@ static int i2cdev_attach_adapter(struct device *dev) i2c_dev->dev.parent = &adap->dev; i2c_dev->dev.release = i2cdev_dev_release; - res = dev_set_name(&i2c_dev->dev, "i2c-%d", adap->nr); + /* + * If "linux,i2c-dev-name" is specified in device tree, use /dev/i2c- + * in Linux userspace, otherwise use /dev/i2c-. + */ + res = device_property_read_string(&adap->dev, "linux,i2c-dev-name", &name); + if (res < 0) + res = dev_set_name(&i2c_dev->dev, "i2c-%d", adap->nr); + else + res = dev_set_name(&i2c_dev->dev, "i2c-%s", name); + if (res) goto err_put_i2c_dev; -- 2.39.3