From patchwork Wed Mar 12 18:48:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 874044 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 7C254256C9E; Wed, 12 Mar 2025 18:51:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805510; cv=none; b=KXZPocsQmDLEr1fB3GAXLTaZcr13PMp9NPgeL8JOG9lisqHiPyWMUd55qB6n9uhyGOUmZWP4Qr6M4JViO1LfzMz+Qnqun5jqG1e/nCBwKTj/ymGB1KBbFUYMARQ/ldnImAM/f4VSikJnM/mKsE9aOhYoW9aPIchmpAVLQc5JKNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805510; c=relaxed/simple; bh=E1EKhvH/3/E+I7074KzqGnDYkH6JWY+UHDd5lGqMH2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qHYKaAAxgVHJk7WBhXP934cLdqQs606lM7BgaErkAagahZP/n9HjfcCzYPbWV0rV3i8EjCUMh806h91Ezmd5mYu4RLaOqCJztKc6OVhZz51gJ5a23h6Gy4fs14Do81EkhtGZf+WT/meBRKbWllFhGrir68DJEUuO4klIGm1p5wQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iNYjjBrC; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iNYjjBrC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805507; x=1773341507; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E1EKhvH/3/E+I7074KzqGnDYkH6JWY+UHDd5lGqMH2Q=; b=iNYjjBrCauEhY52kUAY/hVbal22HoQwcoaVZEgvLL+R8yw6lZyhKGLno lHjVAju2sB2mDMHLyZKzzDvgjg3elu6KyE34tK/xDxS9KkTf31va1Vzii c7szg5IXYytTJecEKyI3qBoAPW/5/Fntxx0STOHKuh85S9KJmr+vdJkg+ HdvUshH2pufUYT6qeFSRALDQpVm4sLsLVjLmrEan5t6RKLRLpEejKxCDk Xzfphu1+6q/+5W2vuMCTRW38ZD1xG9Ev9MRIgbNmdpajJf4v0oYetT7nA zEeSNaljhrE644CeJhxRmOSYwDcgo+8OzbPl+tJgDrnD9cvlgmycpx8hO g==; X-CSE-ConnectionGUID: cn30z4f6REK0rN5vBKhEDQ== X-CSE-MsgGUID: Wh+s2fZMQjir9Ccm7+2eSA== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487208" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487208" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:44 -0700 X-CSE-ConnectionGUID: sb07XPEfQhSBLbSfJbryZQ== X-CSE-MsgGUID: 9s291pTaQ+OuH5pgDbdNzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895061" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 23271130; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/6] i2c: core: Drop duplicate check before calling OF APIs Date: Wed, 12 Mar 2025 20:48:48 +0200 Message-ID: <20250312185137.4154173-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 OF APIs are usually NULL-aware and returns an error in case when device node is not present or supported. We already have a check for the returned value, no need to check for the parameter. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 7ad1ad5c8c3f..c14ffd6190d3 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1209,11 +1209,9 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, u32 addr = default_addr; int i; - if (np) { - i = of_property_match_string(np, "reg-names", name); - if (i >= 0) - of_property_read_u32_index(np, "reg", i, &addr); - } + i = of_property_match_string(np, "reg-names", name); + if (i >= 0) + of_property_read_u32_index(np, "reg", i, &addr); dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr); return i2c_new_dummy_device(client->adapter, addr); @@ -1651,12 +1649,10 @@ int i2c_add_adapter(struct i2c_adapter *adapter) struct device *dev = &adapter->dev; int id; - if (dev->of_node) { - id = of_alias_get_id(dev->of_node, "i2c"); - if (id >= 0) { - adapter->nr = id; - return __i2c_add_numbered_adapter(adapter); - } + id = of_alias_get_id(dev->of_node, "i2c"); + if (id >= 0) { + adapter->nr = id; + return __i2c_add_numbered_adapter(adapter); } mutex_lock(&core_lock); From patchwork Wed Mar 12 18:48:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 874045 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 6A29E1D54E3; Wed, 12 Mar 2025 18:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805507; cv=none; b=hCc8k5YUdo1gJs60xb5NOzuUQjRYovBdR8+0B4a+XOa1kHu/LVk7JAJ3kL/UcPIz5r16z8empF1SArRAzBxonZ5ouckZfqlHfd8It4FTlw4dn08uIVixDmPxHshB9ByWpyLv1Si2h1FaZPpgBmoDRYNDB74v96Yg5wVrymv009I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805507; c=relaxed/simple; bh=vyGpTGR+0J7cloQuQwzgkB0zVZ12nAhFlIiabYUYYYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lr++Qm/x3idwR2r6I4oxr4EosOkZB0GjcdNngqJ1rXvHMIyj3pL8H31o8FbUT4BXzUsfQ/8ABN4VEmpJtGdfzN1V4S4prxN5KPN78rKBayovthRBPoj3YoB+/bYz6HUioDoyn2dCnBEpu9PiJnE88ggXsEaRBHi6cA+mIE3jShE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TFpRZUHh; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TFpRZUHh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805505; x=1773341505; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vyGpTGR+0J7cloQuQwzgkB0zVZ12nAhFlIiabYUYYYc=; b=TFpRZUHh1QQebx8O9HDVsPU1piNL7lacDzSn6K8yjnuz76aBUABe9VUd tYsf2n12jx0k/NyH2d8Lq8fF370okHh1d/ghOtUB6GsewtKt9L7uu8ADo nK6ezVdARKMY7eLELrqCUTUnVkKAeBmeBjr/SGQ/ZD/W7EpMGKyXTFrJU 4geSwEMHNrUUcREMmUDbFQyCW0R07aFbhatLvVkZEy4U9GXQOXSu6qmlb aY/o7jhHKvEdOPCK0Svsy//OfjM7ZEJwSVSatDST97bRdLncizsZKQaeI j8OOaSGmeEJg4VQwChRKg7Njn/RXK/wQovbQ4V21QYWDdHiey13V9Ih52 A==; X-CSE-ConnectionGUID: W7J0L3nsTZC4BD860cMjMQ== X-CSE-MsgGUID: mFb3tPhMSTKfVekfMFWunw== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487207" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487207" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:44 -0700 X-CSE-ConnectionGUID: eo/RDybZSXy76lUdg+SGLA== X-CSE-MsgGUID: xuO7XNMwS+iQMBB76uveMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895060" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2CBFB1FC; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 2/6] i2c: core: Unify the firmware node type check Date: Wed, 12 Mar 2025 20:48:49 +0200 Message-ID: <20250312185137.4154173-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 OF and ACPI currently are using asymmetrical APIs to check for the firmware node type. Unify them by using is_*_node() against struct fwnode_handle pointer. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index c14ffd6190d3..edab56e5d5e5 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -490,6 +490,7 @@ static int i2c_smbus_host_notify_to_irq(const struct i2c_client *client) static int i2c_device_probe(struct device *dev) { + struct fwnode_handle *fwnode = dev_fwnode(dev); struct i2c_client *client = i2c_verify_client(dev); struct i2c_driver *driver; bool do_power_on; @@ -508,11 +509,11 @@ static int i2c_device_probe(struct device *dev) /* Keep adapter active when Host Notify is required */ pm_runtime_get_sync(&client->adapter->dev); irq = i2c_smbus_host_notify_to_irq(client); - } else if (dev->of_node) { + } else if (is_of_node(fwnode)) { irq = of_irq_get_byname(dev->of_node, "irq"); if (irq == -EINVAL || irq == -ENODATA) irq = of_irq_get(dev->of_node, 0); - } else if (ACPI_COMPANION(dev)) { + } else if (is_acpi_device_node(fwnode)) { bool wake_capable; irq = i2c_acpi_get_irq(client, &wake_capable); @@ -1054,15 +1055,16 @@ EXPORT_SYMBOL_GPL(i2c_new_client_device); */ void i2c_unregister_device(struct i2c_client *client) { + struct fwnode_handle *fwnode; + if (IS_ERR_OR_NULL(client)) return; - if (client->dev.of_node) { + fwnode = dev_fwnode(&client->dev); + if (is_of_node(fwnode)) { of_node_clear_flag(client->dev.of_node, OF_POPULATED); of_node_put(client->dev.of_node); - } - - if (ACPI_COMPANION(&client->dev)) + } else if (is_acpi_device_node(fwnode)) acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev)); device_remove_software_node(&client->dev); From patchwork Wed Mar 12 18:48:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 872939 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 2D6992586EC; Wed, 12 Mar 2025 18:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805510; cv=none; b=LwUO1fEfrrXTrRdy3Z/JDKapNNcVp5nmy+UcRRKBPRRG4B41cgUjgVGxEe8k/m73lP0ugjr0ZvFpQTqxDzvepSwBakM8U6sO59AcJwyAEzrHhECDvfc0fEYLbrvklRQff9fcXX2S1TvdF6RFydcm8QaNHjO4HUCqoWttdOUU/2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805510; c=relaxed/simple; bh=w1F7q9x4UbMGJHmiVVAtQYhl6DX9oD/ywOPprqltldk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MXr5TCS1TVeKBJ93tZCIVmydndJHJNw/gjm6EZBcL3E4zLFmyZsg3cUgGUsYJNYiY/BjMCKuedOcOoec4Q6nYXpf6rxeg6tXVQGij2nCRhDVabzYbE2YzcTRyyGd7iL3J/UowCUSORJ/09VlCf/tiADVj5vP/b/wZa6WBp7+vyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QJWvBqVG; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QJWvBqVG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805509; x=1773341509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w1F7q9x4UbMGJHmiVVAtQYhl6DX9oD/ywOPprqltldk=; b=QJWvBqVGnbt+m8HeToTvXGgc4Ijgqy0RkHOvVOYN5/aatwrSBxc1T98F QLzEU7w2EIyDxBNCGVOPBdJdiQ/tKggtqAcFOkWUclNcPP4UPhhbKfhOv LJyVIBj+/kHnyYdfIr8JfuL+nitDz+P6V+uBDfiKh7ICM3d8zjJm7iXsj 5q3W7kuN8j1RLoWEQWVw5sLVdHxdx0oenzuk/5d2xhTgCml6WDAy8+Fp2 rLClLPhdVVrRdw79abvHn/9QKqKjRrH76P789D64+mcsshXnSa7CGthDg EzRZ/IwjQYQfp9ieN3/xLc42F1qsy/ZrhnqoHeXqZ/lgsPe0rFXzG15zX A==; X-CSE-ConnectionGUID: t9/pzS45Q0y0Ka/J7vdXmQ== X-CSE-MsgGUID: KbdWQ0qyQKqJcw2/65vvYA== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487213" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487213" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:45 -0700 X-CSE-ConnectionGUID: 6wH/17GsRpih9z/bB12qeQ== X-CSE-MsgGUID: 0Mwrh9w+Tg2+C6honWpK4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895063" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3F8E326A; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/6] i2c: core: Switch to fwnode APIs to get IRQ Date: Wed, 12 Mar 2025 20:48:50 +0200 Message-ID: <20250312185137.4154173-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch to fwnode APIs to get IRQ. In particular this enables a support of the separate wakeup IRQ. The rest is converted just for the sake of consistency and fwnode reuse. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index edab56e5d5e5..f0420cc0df26 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -510,9 +510,9 @@ static int i2c_device_probe(struct device *dev) pm_runtime_get_sync(&client->adapter->dev); irq = i2c_smbus_host_notify_to_irq(client); } else if (is_of_node(fwnode)) { - irq = of_irq_get_byname(dev->of_node, "irq"); + irq = fwnode_irq_get_byname(fwnode, "irq"); if (irq == -EINVAL || irq == -ENODATA) - irq = of_irq_get(dev->of_node, 0); + irq = fwnode_irq_get(fwnode, 0); } else if (is_acpi_device_node(fwnode)) { bool wake_capable; @@ -547,7 +547,7 @@ static int i2c_device_probe(struct device *dev) if (client->flags & I2C_CLIENT_WAKE) { int wakeirq; - wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); + wakeirq = fwnode_irq_get_byname(fwnode, "wakeup"); if (wakeirq == -EPROBE_DEFER) { status = wakeirq; goto put_sync_adapter; From patchwork Wed Mar 12 18:48:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 874043 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 ACAED258CD0; Wed, 12 Mar 2025 18:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805511; cv=none; b=nXr04+yErsO28JkjgSqeftxVR1/Zdztkvt7mhZkLavXzX0wex52XHhveD2K3fd+WPqHbs2o8Ak+L9+/8KH5VgvGSWlKMtPrgxvTRDH4P6mbca1+nCT1zhn61UKTARESf1jKdt56l6TPTUT8Xq5Ne0wNWPyAFrKJUNnvBfbZZYQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805511; c=relaxed/simple; bh=1sXys2aY5ZFW72nOUdu/mEFqc3tcXF3J8tzEyHNpwMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gQvZ41Tbt71JbBH/CcBPIXbhqog7mU7ymlwfhklqN0osU6RDjNgW8DqcRP1YFBTKeuTGyyO/MC5qTOqaZXeRlSMlvMFLhcr4lsbt2lIJb+UQ1z54yZX4rCBAT1SjWOESxyEbebqtgLI9PN7razGrn9/w0DYtDe5uwCjp1NHvKs8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WrOnxxR4; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WrOnxxR4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805510; x=1773341510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1sXys2aY5ZFW72nOUdu/mEFqc3tcXF3J8tzEyHNpwMk=; b=WrOnxxR4EwUCmab5H8TW/zcQUE7aERSbsEfnTCyugTgNmT1RTv5Hu7mS 6gVF1yuvt4PN/Qwp+flUAGffAowFwEXQm0JltHV6OgCTfdWEwXIhNGGsu Cu1rdqud7rX1DiYwbT+Ua+e26JDxsmakp5jZUTz+m0Rf1LvJ1ZQjku2sU c0UDhbKZc2QYXSnQTKVM6XXrTWudYy2fTaYJtbS8DITJNK8JRrSIUL40s NixzeChNNGe9qm1OjmRHTXzGHaOT+KiT1OIgKQ6Ee3Bix9g3FyAVCX0C2 +4hpKdGCRwf6mO6n5cJk3a/hmHrrLGUgxU3b/tTHbuTUF/MBvksQ4sDFa w==; X-CSE-ConnectionGUID: TuPqK5nGSPCkzKkytjWwFg== X-CSE-MsgGUID: 0ulPcA+QQ+eMpBUE0/uJoQ== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487215" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487215" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:45 -0700 X-CSE-ConnectionGUID: M1jHYTVpQKqeRG7Kmc+veg== X-CSE-MsgGUID: VHGXyTN/T3SdiG4sUck3/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895064" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 44C7E214; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 4/6] i2c: core: Reuse fwnode variable where it makes sense Date: Wed, 12 Mar 2025 20:48:51 +0200 Message-ID: <20250312185137.4154173-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reuse fwnode variable where it makes sense. This avoids unneeded duplication hidden in some macros and unifies the code for different types of fwnode. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index f0420cc0df26..1236061a78c3 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -568,7 +568,7 @@ static int i2c_device_probe(struct device *dev) dev_dbg(dev, "probe\n"); - status = of_clk_set_defaults(dev->of_node, false); + status = of_clk_set_defaults(to_of_node(fwnode), false); if (status < 0) goto err_clear_wakeup_irq; @@ -1062,10 +1062,10 @@ void i2c_unregister_device(struct i2c_client *client) fwnode = dev_fwnode(&client->dev); if (is_of_node(fwnode)) { - of_node_clear_flag(client->dev.of_node, OF_POPULATED); + of_node_clear_flag(to_of_node(fwnode), OF_POPULATED); of_node_put(client->dev.of_node); } else if (is_acpi_device_node(fwnode)) - acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev)); + acpi_device_clear_enumerated(to_acpi_device_node(fwnode)); device_remove_software_node(&client->dev); device_unregister(&client->dev); From patchwork Wed Mar 12 18:48:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 874042 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 04C10259489; Wed, 12 Mar 2025 18:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805512; cv=none; b=AsoOOeW54MdD0TYQQ3kZ5iyfkdEBrbNzKNDKnVsSeqSh7h1rSt1y1vd8txKu70EkysHP+4nsEvuVQUFX8eRPkgplp2JnvgcrrKb9AJpuNA8HT8w+NPkbIQGZnnnCWodZKXhR/A2KMb7xnmo3AjOZLJBUuit0F3n3Zvj/WXbMyRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805512; c=relaxed/simple; bh=V6+0IS7/fqFcASSZF65vr6gKqboR4LhF8+CjfKajdFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+sVo5KPGoEZoidArI7NJZpr6aFqnkxvmx2BBL277MbAqAeadEg6Ua8Z+0ZVamN1Nf1+u6O6r2IUoIb4FwxSaNlqpfMQgqWdnB+DijdvN+t/0qWoPOFU2xmmO9ZPWesoqzaQNiPkTtIt/ooQl5e4IoGg14JZWdnDf5mPAR1mvfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gKMzrJ0B; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gKMzrJ0B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805511; x=1773341511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V6+0IS7/fqFcASSZF65vr6gKqboR4LhF8+CjfKajdFo=; b=gKMzrJ0BD4fSnddjXjBdRde36WfB5BXDFTLqdCrv/ovnEphLFlGIJd5e 50Zzc0l8APLeBtrHzkoK8hMNGEyzPxqLWs+AFZ9VHf5UUswwMq0z4qcOX +O1yERTnqQ9kch26yIjUMDm4VgMAXkVvddQsyt4jVuRCRs8GTcidVyrWE 9IJpB80Cv2+0+N8vq1fm6xMYV3TH0W/XGIvKvh48R9u5s2LuVDQoMAQnP iHzFZ1VlyiHRzEGagvFBtlThqkhZWpFFdX5JDFJAiBXAl2k2iy5LbvO1c 1tKwDhG0xjHyXVzqb8as8gXqLjWdRb4dZBufIAf9jdpFtgWHBBTdm514W g==; X-CSE-ConnectionGUID: 5EexcDADRFuVUhcvYoxrWw== X-CSE-MsgGUID: vIsOLdE4TpaV50DJqypvzQ== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487222" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487222" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:47 -0700 X-CSE-ConnectionGUID: BWOY4Yn1RCusRoEyDrY+KQ== X-CSE-MsgGUID: Qgpdi5QDT3OYaLTrW6uPWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895068" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 53DC727D; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 5/6] i2c: core: Do not dereference fwnode in struct device Date: Wed, 12 Mar 2025 20:48:52 +0200 Message-ID: <20250312185137.4154173-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to make the underneath API easier to change in the future, prevent users from dereferencing fwnode from struct device. Instead, use the specific device_set_node() API for that. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-base.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 1236061a78c3..dba6c5ce9d42 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -962,6 +962,7 @@ static void i2c_unlock_addr(struct i2c_adapter *adap, unsigned short addr, struct i2c_client * i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *info) { + struct fwnode_handle *fwnode; struct i2c_client *client; bool need_put = false; int status; @@ -1002,18 +1003,19 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf client->dev.parent = &client->adapter->dev; client->dev.bus = &i2c_bus_type; client->dev.type = &i2c_client_type; - client->dev.of_node = of_node_get(info->of_node); - client->dev.fwnode = info->fwnode; device_enable_async_suspend(&client->dev); + fwnode = info->fwnode ?: of_fwnode_handle(info->of_node); + device_set_node(&client->dev, fwnode_handle_get(fwnode)); + if (info->swnode) { status = device_add_software_node(&client->dev, info->swnode); if (status) { dev_err(&adap->dev, "Failed to add software node to client %s: %d\n", client->name, status); - goto out_err_put_of_node; + goto out_err_put_fwnode; } } @@ -1032,8 +1034,8 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf out_remove_swnode: device_remove_software_node(&client->dev); need_put = true; -out_err_put_of_node: - of_node_put(info->of_node); +out_err_put_fwnode: + fwnode_handle_put(fwnode); out_err: dev_err(&adap->dev, "Failed to register i2c client %s at 0x%02x (%d)\n", @@ -1061,11 +1063,11 @@ void i2c_unregister_device(struct i2c_client *client) return; fwnode = dev_fwnode(&client->dev); - if (is_of_node(fwnode)) { + if (is_of_node(fwnode)) of_node_clear_flag(to_of_node(fwnode), OF_POPULATED); - of_node_put(client->dev.of_node); - } else if (is_acpi_device_node(fwnode)) + else if (is_acpi_device_node(fwnode)) acpi_device_clear_enumerated(to_acpi_device_node(fwnode)); + fwnode_handle_put(fwnode); device_remove_software_node(&client->dev); device_unregister(&client->dev); From patchwork Wed Mar 12 18:48:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 872938 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 8B2D8258CF2; Wed, 12 Mar 2025 18:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805512; cv=none; b=nDdvNntAERTyBJXTqGuOy5A+W/HDjTJke4imxOzZKEtbGv5T/NW9o+0O//FfbjM7XJw0ARQDaADox+A3ChllLqUwcGM4BWbNUtwituR18TMMZnyH8rqczNi7H5ndw9q1aBvzNolP8YVJsjkTg4YlsZm73ffFPLG4Mqrnu5AZwdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741805512; c=relaxed/simple; bh=VjmtEJxQyuUAeqbxtsbBB1tsOJr3EnKvfppmPlAeS9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HPGBZrBvvKfY8FW+I50nk7QnnyQfHDbMUh8j5sRKSUiQIpP1n34H4QNbl+KzS2SRn+6kGIYjLusrbUUYOzxTfIMUvCieKBc6SFbq91d3vQeKSjX9TWy222UhEuPKjLSGR/lAWWOi+eY7+gAnYzZqwo2kNBKxtKV2AA4mvSGdXV8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FhQqgvur; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FhQqgvur" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741805510; x=1773341510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VjmtEJxQyuUAeqbxtsbBB1tsOJr3EnKvfppmPlAeS9U=; b=FhQqgvur1/e6dL0ZMZIPWQHAdoUp0ZgbAjgRK93rx8ncKjzocNpD8EAN 79k0OGoP3xMjp9O8fXoo20yCG7u2UMmzzsLUXgmG6hNZziHt+oomw1xfo aPKLWlzhtjKekinU/2yVFdsmiKW0JHfK8YtXo8yDIjyOi6oS7P8ZFAwDq Rat7gQnI7ab6WsyVPGSmu9O9VPhdJTucm8ERWdAJtc05GUbw3KlL0mckm UvnIl7EWoBt2KINFManz3brAq6JVcz/mYp9u8IarvoJTEFudVYpaMeNEj fba9YnEGoX8/y/N/8P2lBrBkr+FcIog8hz9Lt5LjztrtAQKEYhEuAF+/c A==; X-CSE-ConnectionGUID: pSl04gNNRsKByn2mOA1gkQ== X-CSE-MsgGUID: xAqd3RiNRDmARVdW/64AQg== X-IronPort-AV: E=McAfee;i="6700,10204,11371"; a="30487221" X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="30487221" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2025 11:51:46 -0700 X-CSE-ConnectionGUID: RHRG1bCQRqKWRbCnaw6Tig== X-CSE-MsgGUID: +IVzrFM+T16rW1kVNJPy+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,242,1736841600"; d="scan'208";a="157895067" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 Mar 2025 11:51:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5D087271; Wed, 12 Mar 2025 20:51:42 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 6/6] i2c: core: Deprecate of_node in struct i2c_board_info Date: Wed, 12 Mar 2025 20:48:53 +0200 Message-ID: <20250312185137.4154173-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> References: <20250312185137.4154173-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Two members of the same or similar semantics is quite confusing to begin with. Moreover, the fwnode covers all possible firmware descriptions that Linux kernel supports. Deprecate of_node in struct i2c_board_info, so users will be warned and in the future remote it completely. Signed-off-by: Andy Shevchenko --- include/linux/i2c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 2e4903b7f7bc..cc1437f29823 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -405,7 +405,7 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; } * @addr: stored in i2c_client.addr * @dev_name: Overrides the default - dev_name if set * @platform_data: stored in i2c_client.dev.platform_data - * @of_node: pointer to OpenFirmware device node + * @of_node: **DEPRECATED** - use @fwnode for this * @fwnode: device node supplied by the platform firmware * @swnode: software node for the device * @resources: resources associated with the device