From patchwork Sun Feb 18 17:27:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561921 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 55FEEE57E for ; Sun, 18 Feb 2024 17:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277268; cv=none; b=tQcckT0T0sr8FdY9lXmoEl39/joI4isTEU5sipSLVfK75xJSI3LiL/V6omNF6xO/1bY8+1kS2KKFOM07A6B2B6VzmZigP3zndK+5AmZppftxbefaeRinac1ofX7Qv5rvP2f4IVo0oQ6xOunuieK0doRgR4a6XT0r/KnuJN/m1pQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277268; c=relaxed/simple; bh=o1lLh65GUtfa9hxkj8+eltRC+aj0rZTrXzAplf0lXyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ul6Z9MTlZl6TV4eslSEn+hxO+mxYcqbfCdwUR/uBNRhJpmXKCz8yNTVQ81NQF96pzMjkftrV00g0eYpiTnm8e6OeBEWgFFLvPlZgZeur9ZPsyxUouTrm3gvF98KBShKsWIDnZsXr3sCC/6+I7StwzQqYismvHJV7yiX/XCPQDGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U7v3ZSAh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U7v3ZSAh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F1C1C43390; Sun, 18 Feb 2024 17:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277267; bh=o1lLh65GUtfa9hxkj8+eltRC+aj0rZTrXzAplf0lXyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U7v3ZSAhLr+tFfdzIBUY9apjRyIcZpprOlSr8qdFvKSgEAWRpTSdlHgOjcK3mU31e vwWFLJYDqiQG04drBR55ET6ZDXErOEGCwhZUkZOb8y2Ffx84OhEx/wVfzUumZxBkir fuEezQOWHorlcuWkjn1kdgBbzcxthEkNLHjhA+AkEtXLtRA5xRJAeEqpqjFeJGom77 M2nrgEjOnN3XJbz7F0BdtqS8MFLj5J3PheS0RDQ43+sqPWxzw77lGCIX9sCE4T7Gma DakUePne4b8pR+NaCOYFuj10+1jlCP1nXJjkk/b65Zi15TFcMhBmyhrHEMefCHd6UG imVJPk0/rUrmw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 1/8] iio: adc: fsl-imx25-gcq: Switch from of specific handing to fwnode based. Date: Sun, 18 Feb 2024 17:27:24 +0000 Message-ID: <20240218172731.1023367-2-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Using the generic firmware data access functions from property.h provides a number of advantages: 1) Works with different firmware types. 2) Doesn't provide a 'bad' example for new IIO drivers. 3) Lets us use the new _scoped() loops with automatic reference count cleanup for fwnode_handle Signed-off-by: Jonathan Cameron --- drivers/iio/adc/fsl-imx25-gcq.c | 54 +++++++++++++-------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c index 68c813de0605..534e73a24eb4 100644 --- a/drivers/iio/adc/fsl-imx25-gcq.c +++ b/drivers/iio/adc/fsl-imx25-gcq.c @@ -12,8 +12,9 @@ #include #include #include -#include +#include #include +#include #include #include @@ -198,8 +199,6 @@ static int mx25_gcq_ext_regulator_setup(struct device *dev, static int mx25_gcq_setup_cfgs(struct platform_device *pdev, struct mx25_gcq_priv *priv) { - struct device_node *np = pdev->dev.of_node; - struct device_node *child; struct device *dev = &pdev->dev; int ret, i; @@ -216,37 +215,30 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, MX25_ADCQ_CFG_IN(i) | MX25_ADCQ_CFG_REFN_NGND2); - for_each_child_of_node(np, child) { + device_for_each_child_node_scoped(dev, child) { u32 reg; u32 refp = MX25_ADCQ_CFG_REFP_INT; u32 refn = MX25_ADCQ_CFG_REFN_NGND2; - ret = of_property_read_u32(child, "reg", ®); - if (ret) { - dev_err(dev, "Failed to get reg property\n"); - of_node_put(child); - return ret; - } + ret = fwnode_property_read_u32(child, "reg", ®); + if (ret) + return dev_err_probe(dev, ret, + "Failed to get reg property\n"); - if (reg >= MX25_NUM_CFGS) { - dev_err(dev, + if (reg >= MX25_NUM_CFGS) + return dev_err_probe(dev, -EINVAL, "reg value is greater than the number of available configuration registers\n"); - of_node_put(child); - return -EINVAL; - } - of_property_read_u32(child, "fsl,adc-refp", &refp); - of_property_read_u32(child, "fsl,adc-refn", &refn); + fwnode_property_read_u32(child, "fsl,adc-refp", &refp); + fwnode_property_read_u32(child, "fsl,adc-refn", &refn); switch (refp) { case MX25_ADC_REFP_EXT: case MX25_ADC_REFP_XP: case MX25_ADC_REFP_YP: ret = mx25_gcq_ext_regulator_setup(&pdev->dev, priv, refp); - if (ret) { - of_node_put(child); + if (ret) return ret; - } priv->channel_vref_mv[reg] = regulator_get_voltage(priv->vref[refp]); /* Conversion from uV to mV */ @@ -256,9 +248,8 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, priv->channel_vref_mv[reg] = 2500; break; default: - dev_err(dev, "Invalid positive reference %d\n", refp); - of_node_put(child); - return -EINVAL; + return dev_err_probe(dev, -EINVAL, + "Invalid positive reference %d\n", refp); } /* @@ -268,16 +259,13 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, refp = MX25_ADCQ_CFG_REFP(refp); refn = MX25_ADCQ_CFG_REFN(refn); - if ((refp & MX25_ADCQ_CFG_REFP_MASK) != refp) { - dev_err(dev, "Invalid fsl,adc-refp property value\n"); - of_node_put(child); - return -EINVAL; - } - if ((refn & MX25_ADCQ_CFG_REFN_MASK) != refn) { - dev_err(dev, "Invalid fsl,adc-refn property value\n"); - of_node_put(child); - return -EINVAL; - } + if ((refp & MX25_ADCQ_CFG_REFP_MASK) != refp) + return dev_err_probe(dev, -EINVAL, + "Invalid fsl,adc-refp property value\n"); + + if ((refn & MX25_ADCQ_CFG_REFN_MASK) != refn) + return dev_err_probe(dev, -EINVAL, + "Invalid fsl,adc-refn property value\n"); regmap_update_bits(priv->regs, MX25_ADCQ_CFG(reg), MX25_ADCQ_CFG_REFP_MASK | From patchwork Sun Feb 18 17:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561922 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 216D8E57E for ; Sun, 18 Feb 2024 17:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277271; cv=none; b=swyezxjusguCYjjTM3XFG7z+p7LLrSaehCpd08tP5AyaDyF2g5eBgMYn+Jzccl/DNYDeuitYf2jBHehK8sfRA3QWMm5apJ7t/ZZN/zCScMXzeLDKyqx+MAsJQobHr+6GO9E3FOvq0gRUxec2WJ0k2tG4hR4nEUUVfyxfwbdgIq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277271; c=relaxed/simple; bh=z4DTzHGJHbs7Lxr/ITF+XsPRqfQa9jv7ILlO7XJNliE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6PNV9edG7E74UiHyEiY351UPKIh366i8e+vk77eFcHbyJ/WONaKpEJisnm/SuVKnTEIZ6eVQN+FkkU2U0Xjru66IEWm1R+f8szPL7WMTKDpDBuV9s4gWjjCDphMisU9dX0nycon3omIJ+WrUp8sQfiJh0po+Wbxx7Yll3QExEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qS0kptlQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qS0kptlQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BBE9C433F1; Sun, 18 Feb 2024 17:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277270; bh=z4DTzHGJHbs7Lxr/ITF+XsPRqfQa9jv7ILlO7XJNliE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qS0kptlQeF+oQwRhzzIJkF00F7Ug10tQHtdJ+Xjc/jdWWQWG/T1futjy1q+hn/hNZ e6OSURkLLAIzUTNs2ACnfJS08kn8nm0ANmZWMFAtiWJ8wkarOq0fAbaHutRIjD5zij shEqwW5lHsLc+s4kZ7WYjqPdfEnd2YlmwgoDKVJnJAu9JVyPk1gxW+iyfnGSvNozsE LM9azwFI0F22j/sqfuFAwpWaGwVhFTajx/0fohjDwUReJi1mnol5yC43dwJ395djFC 2y/9FW2XUhkZGYhkR+8K6e/erBIcXD6xmePNEjcwIPbZRPZu4nkrQ+bTrpBvrbEmtt Ir2Xwq9RwsDwg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 2/8] iio: adc: fsl-imx25-gcq: Use devm_* and dev_err_probe() to simplify probe Date: Sun, 18 Feb 2024 17:27:25 +0000 Message-ID: <20240218172731.1023367-3-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Custom callbacks are need for regulators (so there is a handle to read the voltage from) and the clk because it is retrieved from the parent rather than directly from firmware description. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/fsl-imx25-gcq.c | 86 ++++++++++++++------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c index 534e73a24eb4..394396b91630 100644 --- a/drivers/iio/adc/fsl-imx25-gcq.c +++ b/drivers/iio/adc/fsl-imx25-gcq.c @@ -282,6 +282,17 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, return 0; } +static void mx25_gcq_reg_disable(void *reg) +{ + regulator_disable(reg); +} + +/* Custom handling needed as this driver doesn't own the clock */ +static void mx25_gcq_clk_disable(void *clk) +{ + clk_disable_unprepare(clk); +} + static int mx25_gcq_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -303,10 +314,9 @@ static int mx25_gcq_probe(struct platform_device *pdev) return PTR_ERR(mem); priv->regs = devm_regmap_init_mmio(dev, mem, &mx25_gcq_regconfig); - if (IS_ERR(priv->regs)) { - dev_err(dev, "Failed to initialize regmap\n"); - return PTR_ERR(priv->regs); - } + if (IS_ERR(priv->regs)) + return dev_err_probe(dev, PTR_ERR(priv->regs), + "Failed to initialize regmap\n"); mutex_init(&priv->lock); @@ -322,69 +332,44 @@ static int mx25_gcq_probe(struct platform_device *pdev) ret = regulator_enable(priv->vref[i]); if (ret) - goto err_regulator_disable; + return ret; + + ret = devm_add_action_or_reset(dev, mx25_gcq_reg_disable, + priv->vref[i]); + if (ret) + return ret; } priv->clk = tsadc->clk; ret = clk_prepare_enable(priv->clk); - if (ret) { - dev_err(dev, "Failed to enable clock\n"); - goto err_vref_disable; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to enable clock\n"); + + ret = devm_add_action_or_reset(dev, mx25_gcq_clk_disable, + priv->clk); + if (ret) + return ret; ret = platform_get_irq(pdev, 0); if (ret < 0) - goto err_clk_unprepare; + return ret; priv->irq = ret; - ret = request_irq(priv->irq, mx25_gcq_irq, 0, pdev->name, priv); - if (ret) { - dev_err(dev, "Failed requesting IRQ\n"); - goto err_clk_unprepare; - } + ret = devm_request_irq(dev, priv->irq, mx25_gcq_irq, 0, pdev->name, + priv); + if (ret) + return dev_err_probe(dev, ret, "Failed requesting IRQ\n"); indio_dev->channels = mx25_gcq_channels; indio_dev->num_channels = ARRAY_SIZE(mx25_gcq_channels); indio_dev->info = &mx25_gcq_iio_info; indio_dev->name = driver_name; - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(dev, "Failed to register iio device\n"); - goto err_irq_free; - } - - platform_set_drvdata(pdev, indio_dev); + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to register iio device\n"); return 0; - -err_irq_free: - free_irq(priv->irq, priv); -err_clk_unprepare: - clk_disable_unprepare(priv->clk); -err_vref_disable: - i = 4; -err_regulator_disable: - for (; i-- > 0;) { - if (priv->vref[i]) - regulator_disable(priv->vref[i]); - } - return ret; -} - -static void mx25_gcq_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct mx25_gcq_priv *priv = iio_priv(indio_dev); - int i; - - iio_device_unregister(indio_dev); - free_irq(priv->irq, priv); - clk_disable_unprepare(priv->clk); - for (i = 4; i-- > 0;) { - if (priv->vref[i]) - regulator_disable(priv->vref[i]); - } } static const struct of_device_id mx25_gcq_ids[] = { @@ -399,7 +384,6 @@ static struct platform_driver mx25_gcq_driver = { .of_match_table = mx25_gcq_ids, }, .probe = mx25_gcq_probe, - .remove_new = mx25_gcq_remove, }; module_platform_driver(mx25_gcq_driver); From patchwork Sun Feb 18 17:27:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561923 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0B2E6E57E for ; Sun, 18 Feb 2024 17:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277274; cv=none; b=HKpz8ZI9r8k6UIq0PA51E/LOXmxs59J+4PWf+9LV716CjRdvzEYeAAFQojV7pK/IY0IQ43vrHCMPiyPiNkNgtI4h/1PtKBlIpzi1JNDS/G4nXLTvjBbLdf+HS/ZovUG2+pbROCMtPRYEdLHBIHqhnUc2cJ3qxVH9IGPXTffSUvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277274; c=relaxed/simple; bh=08pF1DNnMmRM/lqhXL1nTS7E8jqHMzKmhzuGlQfUP/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yg4XDgntVrZPqYa3l092juKWgSAOQ7rthFliI7h0X8HJojB8CNC9GyKljrvUYFJZO7y4bBvMHdGxoG9qvOquKFEituGLuz+kwgT7T+jppSCNqXG/mCZu0L+ciHjojy2Wd35I3OtVhAexRiTighhYQW9uGLKjyiPAPpaXrHphMvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cbgsDF5M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cbgsDF5M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F8FDC433C7; Sun, 18 Feb 2024 17:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277273; bh=08pF1DNnMmRM/lqhXL1nTS7E8jqHMzKmhzuGlQfUP/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbgsDF5Mo7DtpIq5i3Y+FHzCAjuEwqeHqfo5OjYb9DQ330zuZnVJ2GqvTRjDfyuKg bsnH9QfjDOJy/s87WvuQarkZoNraUH4PU3Gg73sKAgCRsDZCBe2BRFKpje9E9KzXUR TmXZmXuOk/UFXigi/IUNU2s6Qqvwk7ANbVwxszKNHH6GPnlN7AV8pzUcbVPzD5DQcc sHdXnTzLEkAKG6ayKzxblEiT2X8ZnbqZz1Ji3TIEwoknIikwMf5MVtwuBJVbDPCx1L gG40XX7I1TTj6F/JAf5X1EdQoGF4d4q0tYZHeqO9Fjnfk8DEYyS3Mo6f+6KCzaQj4a t372shoMQySbA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 3/8] iio: adc: ad7124: Switch from of specific to fwnode based property handling Date: Sun, 18 Feb 2024 17:27:26 +0000 Message-ID: <20240218172731.1023367-4-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Using the generic firmware data access functions from property.h provides a number of advantages: 1) Works with different firmware types. 2) Doesn't provide a 'bad' example for new IIO drivers. 3) Lets us use the new _scoped() loops with automatic reference count cleanup for fwnode_handle Cc: Lars-Peter Clausen Cc: Michael Hennerich Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7124.c | 55 +++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index b9b206fcd748..e7b1d517d3de 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #include #include @@ -807,22 +808,19 @@ static int ad7124_check_chip_id(struct ad7124_state *st) return 0; } -static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, - struct device_node *np) +static int ad7124_parse_channel_config(struct iio_dev *indio_dev, + struct device *dev) { struct ad7124_state *st = iio_priv(indio_dev); struct ad7124_channel_config *cfg; struct ad7124_channel *channels; - struct device_node *child; struct iio_chan_spec *chan; unsigned int ain[2], channel = 0, tmp; int ret; - st->num_channels = of_get_available_child_count(np); - if (!st->num_channels) { - dev_err(indio_dev->dev.parent, "no channel children\n"); - return -ENODEV; - } + st->num_channels = device_get_child_node_count(dev); + if (!st->num_channels) + return dev_err_probe(dev, -ENODEV, "no channel children\n"); chan = devm_kcalloc(indio_dev->dev.parent, st->num_channels, sizeof(*chan), GFP_KERNEL); @@ -838,39 +836,38 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, indio_dev->num_channels = st->num_channels; st->channels = channels; - for_each_available_child_of_node(np, child) { + device_for_each_child_node_scoped(dev, child) { cfg = &st->channels[channel].cfg; - ret = of_property_read_u32(child, "reg", &channel); + ret = fwnode_property_read_u32(child, "reg", &channel); if (ret) - goto err; + return ret; - if (channel >= indio_dev->num_channels) { - dev_err(indio_dev->dev.parent, + if (channel >= indio_dev->num_channels) + return dev_err_probe(dev, -EINVAL, "Channel index >= number of channels\n"); - ret = -EINVAL; - goto err; - } - ret = of_property_read_u32_array(child, "diff-channels", - ain, 2); + ret = fwnode_property_read_u32_array(child, "diff-channels", + ain, 2); if (ret) - goto err; + return ret; st->channels[channel].nr = channel; st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) | AD7124_CHANNEL_AINM(ain[1]); - cfg->bipolar = of_property_read_bool(child, "bipolar"); + cfg->bipolar = fwnode_property_read_bool(child, "bipolar"); - ret = of_property_read_u32(child, "adi,reference-select", &tmp); + ret = fwnode_property_read_u32(child, "adi,reference-select", &tmp); if (ret) cfg->refsel = AD7124_INT_REF; else cfg->refsel = tmp; - cfg->buf_positive = of_property_read_bool(child, "adi,buffered-positive"); - cfg->buf_negative = of_property_read_bool(child, "adi,buffered-negative"); + cfg->buf_positive = + fwnode_property_read_bool(child, "adi,buffered-positive"); + cfg->buf_negative = + fwnode_property_read_bool(child, "adi,buffered-negative"); chan[channel] = ad7124_channel_template; chan[channel].address = channel; @@ -880,10 +877,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, } return 0; -err: - of_node_put(child); - - return ret; } static int ad7124_setup(struct ad7124_state *st) @@ -943,9 +936,7 @@ static int ad7124_probe(struct spi_device *spi) struct iio_dev *indio_dev; int i, ret; - info = of_device_get_match_data(&spi->dev); - if (!info) - info = (void *)spi_get_device_id(spi)->driver_data; + info = spi_get_device_match_data(spi); if (!info) return -ENODEV; @@ -965,7 +956,7 @@ static int ad7124_probe(struct spi_device *spi) if (ret < 0) return ret; - ret = ad7124_of_parse_channel_config(indio_dev, spi->dev.of_node); + ret = ad7124_parse_channel_config(indio_dev, &spi->dev); if (ret < 0) return ret; From patchwork Sun Feb 18 17:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561924 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 71EF26D1D7 for ; Sun, 18 Feb 2024 17:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277277; cv=none; b=PpjecD9oV0UR5l/STKe9sNRra7MzgyPju1L3XVc4QMAwIgvm3jQY/3OlPr5Zkr2S1bI4sZcwo9Kj3cU/LXzDKgHIMEUgWWff1S1zXJV1isga+f9g3TjtUCs110k1CQ/2WCixS22Rey96zsWl7c8MLQI+N8LebisxEU0zYy5IauI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277277; c=relaxed/simple; bh=Qbh3KQu1U1jvsDTiIMYm3P9ePXI/Bg3MgT1Zef7Qpcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uGKTPliTc3IMh00toiCZou3ISCahdCI67BX+tisjKuwJjL1mTh39lxh3Eawt0voXhaOwRnTFPiD8F6ssdEb5zMCu9d1Orw3iT8MZyxUV84v5fC7LdQaEv4a10KU7jusV4UrQ+5zO04pNnLNqnvaGCrpaWVNhf2k8STRNOs9RSHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=buv6j611; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="buv6j611" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 238ACC433F1; Sun, 18 Feb 2024 17:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277276; bh=Qbh3KQu1U1jvsDTiIMYm3P9ePXI/Bg3MgT1Zef7Qpcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=buv6j611FbX9U8M+Bg5KQRHg7A8+Pp/HeRuDDqaZ0q6+raONCWDgc9s1dcMzCGHoQ kQ2/3zVgdGdsdvm7harBUH2qAZFBPjAUAqoFHwOsfSy77CatGoed8v42ZM+FVkDvcS zvKJ6m+rNWxQ0oEIK+QpDhzmyS7XVx2cfiLIB6DBDv6a+rrowRuCqMNPbxVs7KPqkr u9dPpTOXFtP1uQSbW39xjOHf50srTePKnchsJDjIJGikV6aQKAgeCrFjlxvwve7Chf ++4n6LLYx2fSIUPCOX3peBja9wOrtJ5NP83iLKPKR1TnfF+hqPvAWoVuUJOriWAkaW TbWLK0OhxF5pg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 4/8] iio: adc: ad7292: Switch from of specific to fwnode property handling Date: Sun, 18 Feb 2024 17:27:27 +0000 Message-ID: <20240218172731.1023367-5-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This reduces the wrong of device tree only IIO drivers that might be copied by converting over this simple case. Makes use of the new _scoped() handling to automatically release the fwnode_handle on early exit from the loop. Cc: Nuno Sá Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7292.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c index cccacec5db6d..6aadd14f459d 100644 --- a/drivers/iio/adc/ad7292.c +++ b/drivers/iio/adc/ad7292.c @@ -8,7 +8,8 @@ #include #include #include -#include +#include +#include #include #include @@ -260,7 +261,6 @@ static int ad7292_probe(struct spi_device *spi) { struct ad7292_state *st; struct iio_dev *indio_dev; - struct device_node *child; bool diff_channels = false; int ret; @@ -305,12 +305,11 @@ static int ad7292_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &ad7292_info; - for_each_available_child_of_node(spi->dev.of_node, child) { - diff_channels = of_property_read_bool(child, "diff-channels"); - if (diff_channels) { - of_node_put(child); + device_for_each_child_node_scoped(&spi->dev, child) { + diff_channels = fwnode_property_read_bool(child, + "diff-channels"); + if (diff_channels) break; - } } if (diff_channels) { From patchwork Sun Feb 18 17:27:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561925 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C2DC11E86B for ; Sun, 18 Feb 2024 17:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277279; cv=none; b=Pfj6SJP6V+gHB7s/dMv+CQM7FnzfllQJe1J81KDT1vULqKa0pRHUZYn0mhFTYoUdu4F5CndPpZYTLZvZLyAjHSDtWryin3r9HHg6rZS0HOAMOUBdg6ffhOqus3ImETOIdMk042zvgjjMN2hl2R3XVRQeB62l5ipF6opOrkvtfz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277279; c=relaxed/simple; bh=XeCS07l4BIxmyFSal6vNGmC2/PZ9hnxuZ+EuravMu8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T2+XQ9Uk/y6TwICFxf8jBgUTnvUtkXzMaWVsbsG/OOOHi2UGXEASOBM0WO9v4q3sOPpyq2b8HCKgf18F2jFw6UlNgGTcrWi1ma59Rm9n/tswnD0xm+xKfmXkh3c6ey+VAC0uLafSvb+5BoifvRsmoqdrjwJ4bQm2P3zi15fxyK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UEd5dv+/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UEd5dv+/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51A2AC43390; Sun, 18 Feb 2024 17:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277279; bh=XeCS07l4BIxmyFSal6vNGmC2/PZ9hnxuZ+EuravMu8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UEd5dv+/ZlL+bn3DyDYuiSp+0+7EsZ4PCC9bSnKab+yygzyFkYDWRlzY/PcbsnL1k pp41lWaHSWbIjjeT6q0KfTIylXQJqgyjJOIxdQuTDiFzSwFmysUnilfqS4E9jM5V+6 NlLfL/VVvyLauQ5k9YIPiW2cbkdYrikAIs/+Z05nUyFrB/ymgwjOA35YhsmNeiaqmf 7YNc6qpfxyNQRK+59RKcQSSWHxCqo+0alpOp8Tzp6TKJlGGqnNluWV6+AQCO4g2GcR Hdb9PWlk97uTQst7eB0ByREKS25/Rstr5LbkeBRlX9XuLE0vJVmgmcraHrZPGyNqWz aBLYrezuD+yyw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 5/8] iio: adc: ad7192: Convert from of specific to fwnode property handling Date: Sun, 18 Feb 2024 17:27:28 +0000 Message-ID: <20240218172731.1023367-6-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Enables use of with other firmwware types. Removes a case of device tree specific handlers that might get copied into new drivers. Cc: Alisa-Dariana Roman Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7192.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index adc3cbe92d6e..7bcc7e2aa2a2 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -17,7 +17,9 @@ #include #include #include -#include +#include +#include +#include #include #include @@ -364,19 +366,19 @@ static inline bool ad7192_valid_external_frequency(u32 freq) freq <= AD7192_EXT_FREQ_MHZ_MAX); } -static int ad7192_of_clock_select(struct ad7192_state *st) +static int ad7192_clock_select(struct ad7192_state *st) { - struct device_node *np = st->sd.spi->dev.of_node; + struct device *dev = &st->sd.spi->dev; unsigned int clock_sel; clock_sel = AD7192_CLK_INT; /* use internal clock */ if (!st->mclk) { - if (of_property_read_bool(np, "adi,int-clock-output-enable")) + if (device_property_read_bool(dev, "adi,int-clock-output-enable")) clock_sel = AD7192_CLK_INT_CO; } else { - if (of_property_read_bool(np, "adi,clock-xtal")) + if (device_property_read_bool(dev, "adi,clock-xtal")) clock_sel = AD7192_CLK_EXT_MCLK1_2; else clock_sel = AD7192_CLK_EXT_MCLK2; @@ -385,7 +387,7 @@ static int ad7192_of_clock_select(struct ad7192_state *st) return clock_sel; } -static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np) +static int ad7192_setup(struct iio_dev *indio_dev, struct device *dev) { struct ad7192_state *st = iio_priv(indio_dev); bool rej60_en, refin2_en; @@ -407,7 +409,7 @@ static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np) id = FIELD_GET(AD7192_ID_MASK, id); if (id != st->chip_info->chip_id) - dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X != 0x%X)\n", + dev_warn(dev, "device ID query failed (0x%X != 0x%X)\n", id, st->chip_info->chip_id); st->mode = FIELD_PREP(AD7192_MODE_SEL_MASK, AD7192_MODE_IDLE) | @@ -416,30 +418,30 @@ static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np) st->conf = FIELD_PREP(AD7192_CONF_GAIN_MASK, 0); - rej60_en = of_property_read_bool(np, "adi,rejection-60-Hz-enable"); + rej60_en = device_property_read_bool(dev, "adi,rejection-60-Hz-enable"); if (rej60_en) st->mode |= AD7192_MODE_REJ60; - refin2_en = of_property_read_bool(np, "adi,refin2-pins-enable"); + refin2_en = device_property_read_bool(dev, "adi,refin2-pins-enable"); if (refin2_en && st->chip_info->chip_id != CHIPID_AD7195) st->conf |= AD7192_CONF_REFSEL; st->conf &= ~AD7192_CONF_CHOP; - buf_en = of_property_read_bool(np, "adi,buffer-enable"); + buf_en = device_property_read_bool(dev, "adi,buffer-enable"); if (buf_en) st->conf |= AD7192_CONF_BUF; - bipolar = of_property_read_bool(np, "bipolar"); + bipolar = device_property_read_bool(dev, "bipolar"); if (!bipolar) st->conf |= AD7192_CONF_UNIPOLAR; - burnout_curr_en = of_property_read_bool(np, - "adi,burnout-currents-enable"); + burnout_curr_en = device_property_read_bool(dev, + "adi,burnout-currents-enable"); if (burnout_curr_en && buf_en) { st->conf |= AD7192_CONF_BURN; } else if (burnout_curr_en) { - dev_warn(&st->sd.spi->dev, + dev_warn(dev, "Can't enable burnout currents: see CHOP or buffer\n"); } @@ -1117,9 +1119,7 @@ static int ad7192_probe(struct spi_device *spi) } st->int_vref_mv = ret / 1000; - st->chip_info = of_device_get_match_data(&spi->dev); - if (!st->chip_info) - st->chip_info = (void *)spi_get_device_id(spi)->driver_data; + st->chip_info = spi_get_device_match_data(spi); indio_dev->name = st->chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; @@ -1140,7 +1140,7 @@ static int ad7192_probe(struct spi_device *spi) if (IS_ERR(st->mclk)) return PTR_ERR(st->mclk); - st->clock_sel = ad7192_of_clock_select(st); + st->clock_sel = ad7192_clock_select(st); if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || st->clock_sel == AD7192_CLK_EXT_MCLK2) { @@ -1152,7 +1152,7 @@ static int ad7192_probe(struct spi_device *spi) } } - ret = ad7192_setup(indio_dev, spi->dev.of_node); + ret = ad7192_setup(indio_dev, &spi->dev); if (ret) return ret; From patchwork Sun Feb 18 17:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561926 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B7A4C1E86B for ; Sun, 18 Feb 2024 17:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277282; cv=none; b=rK9n5nYnlmUoP70MzpWecRQSMrKYa37R7e2bMcjqspToIbxrNJtSg+GadxIV6ZYOCaV/CHiNKhzt4ePHKRB1eKMUO/mE7hZkipccpvDd6aV8w39UMz3Iv420AcT0cw093h2jyrzZp7ch8iKf5uAc5lcbPq2vbPLKY5R3sOrx4zU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277282; c=relaxed/simple; bh=kTDZTYbB2tYdmtSqhX07F928v1XXc4IfBsH4twzt8vA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fnVEtYONLnL+veCVzL9EPYckh8NROzcBX0CSqZA0fUaxAicON2VNAMZKrlwIqsALIAYTlNEXOyC5Up/l1NQV/nmBRe82D3zmFgaqlLMJzp8CQ6GsLQMi1QXwwqkG81G2aTQL9CwFcxnJhpBJi+pegAQPeXx60kAy/eJ/NvNamzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=StSEs/EP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="StSEs/EP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D84CC433F1; Sun, 18 Feb 2024 17:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277282; bh=kTDZTYbB2tYdmtSqhX07F928v1XXc4IfBsH4twzt8vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=StSEs/EPZYLNQZ+rr/mYRKxWFbFfbL+yfuxW66HDcVDaQRgl/yIaPp6lf/aX7RkGK DDt7Pioow30IzuDBxBEWyGc0sTJSIskF5k1E1QbTzoXOzhyGioIzEZIlwA5+Z6sJco a+x24ku95w6z25DAcTMzxSxHt4lxqP+uDs2ri0UfbxXdNTEu0zll1yv9N7ZqdutLM7 32eHzXQC1knXnlweO9eGfjVxLd82AeSQTuFVGNMVZsCzsDxl01um0lKt/mTHjyUc1v 31GYRmUDxIYP1f7qnRA6Y6wcGtkiah0pfGr79qEwrDtNjyPhUImW1iAS8Uxp68U7r1 V1QWJr+URnorg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 6/8] iio: accel: mma8452: Switch from of specific to fwnode property handling. Date: Sun, 18 Feb 2024 17:27:29 +0000 Message-ID: <20240218172731.1023367-7-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron In this case only use was to get an irq so easily converted. Also include linux/mod_devicetable.h for struct of_device_id definition. Using the generic firmware handling, this driver may be used with other firmware types. This also removes an example that might get copied into other drivers leaving them unable to be used with alternative firmware types. Cc: Haibo Chen Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index d3fd0318e47b..62e6369e2269 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -19,6 +19,8 @@ */ #include +#include +#include #include #include #include @@ -28,8 +30,6 @@ #include #include #include -#include -#include #include #include @@ -1642,7 +1642,7 @@ static int mma8452_probe(struct i2c_client *client) if (client->irq) { int irq2; - irq2 = of_irq_get_byname(client->dev.of_node, "INT2"); + irq2 = fwnode_irq_get_byname(dev_fwnode(&client->dev), "INT2"); if (irq2 == client->irq) { dev_dbg(&client->dev, "using interrupt line INT2\n"); From patchwork Sun Feb 18 17:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561927 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D7E171E86B for ; Sun, 18 Feb 2024 17:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277285; cv=none; b=bRnxHsH5FxVZ3wjipbPu8X9e95W3nLBys1D1j3oiimWoVFGiX6xyntNMkBLUAqmUhZqdC5u9dcGh2gYXXl5YSOYTj1sqF8jhH+lmuHBnswbpFfdReszf4OPvho8cdKViRTet4cTb3exUjDtXd5ltw5K9Daecz3mVcfpmN2/fjSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277285; c=relaxed/simple; bh=QTbpVKmFLhiEslvymQ9zKVe0DLJQybzeT09yPDdwPBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ukltTGNaYOlrWRUcBEmdcRIa8Wbb3x2G/RfcVoB7WMCE9srhFQwoPrALevKkqxKuAsmj0EdOtcBgaS6bwu+m4g2Pi2HxbnFlEndMS4sVLZhcRQpLjQoiw0bDnHeWLekKthytvhn9Skt6q4HIMv6CWOngvVuEwmzuK9zjppsFewU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kNzSlVWR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kNzSlVWR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0965EC43390; Sun, 18 Feb 2024 17:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277285; bh=QTbpVKmFLhiEslvymQ9zKVe0DLJQybzeT09yPDdwPBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNzSlVWRPe0CwPOP52Btu54tEtrn766HEtXX7tgk7Bt2EFMsVQLW7ORce+bdXEtHp mkkpiKfxpNHy1Bh72oXgBiJZd7cvXhyeCwWYXZWlaO4NS087+6A3MA4QLrjiQQ9Uq7 KCL6894MMx40oTcaPHCgyDo96XBbCrUUDFyHb8V1Ar3eK7pBCLfUZ/Ftyf+LNjNg7h ZAEqYRV5BeRw3VMdl4FN2/4GVBG2EZHunssezL3LVhBt373iET/t/TSW4Sl/IzgtTB K/LJ1sS/l6t+1QlNpZFUqJpkwcEwFEaEs7CY6dykkx4zYAHSTXTm+M1jLoeZZ4eLuF HernkD96b1ZzQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 7/8] iio: accel: fxls8962af: Switch from of specific to fwnode based properties. Date: Sun, 18 Feb 2024 17:27:30 +0000 Message-ID: <20240218172731.1023367-8-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Only the irq was retrieved using an of specific accessor. Switch to the fwnode equivalent and adjust headers. Also include missing mod_devicetable.h and irq.h. Cc: Sean Nyekjaer Signed-off-by: Jonathan Cameron --- drivers/iio/accel/fxls8962af-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c index be8a15cb945f..4fbc01bda62e 100644 --- a/drivers/iio/accel/fxls8962af-core.c +++ b/drivers/iio/accel/fxls8962af-core.c @@ -15,9 +15,11 @@ #include #include #include +#include #include -#include +#include #include +#include #include #include @@ -1062,12 +1064,12 @@ static void fxls8962af_pm_disable(void *dev_ptr) fxls8962af_standby(iio_priv(indio_dev)); } -static void fxls8962af_get_irq(struct device_node *of_node, +static void fxls8962af_get_irq(struct device *dev, enum fxls8962af_int_pin *pin) { int irq; - irq = of_irq_get_byname(of_node, "INT2"); + irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2"); if (irq > 0) { *pin = FXLS8962AF_PIN_INT2; return; @@ -1086,7 +1088,7 @@ static int fxls8962af_irq_setup(struct iio_dev *indio_dev, int irq) u8 int_pin_sel; int ret; - fxls8962af_get_irq(dev->of_node, &int_pin); + fxls8962af_get_irq(dev, &int_pin); switch (int_pin) { case FXLS8962AF_PIN_INT1: int_pin_sel = FXLS8962AF_INT_PIN_SEL_INT1; From patchwork Sun Feb 18 17:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561928 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A85876EB6E for ; Sun, 18 Feb 2024 17:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277288; cv=none; b=qba05HZGTAKqq2r7jv+WI5fow1/rJFmzh4A2UJejAn2Cv7ZsAUjV7zbb41aGv37jDo6fk7i9Rkh9lzyF0KqVF3/txGwMmCwP2wPJHDqc3ZwOgNaKQaeawdLoGZKVciZk8iZfFUY4PdbakYIW5B9HBwTA5waQx8LsRb/1snu7nuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708277288; c=relaxed/simple; bh=qMELB7PQmn3jz1qdSc2O9qlVDGZ3OQJIk3MInMF/wUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qJi6AqSlpzw+d0y5lLpP1ul6g2r0/CLlUxRD800p21G6oJS/BefSiEPwsmeL6t1sTUQrCTOOdDPLIH5u6ormNyr8XdoEv/Uwj1xjEItAEjDVJ0tAOM+gr3J6UI0s1fHaBwTwTT/2BZYHyZznyCyexaDfNDJVt3krcy2ddyUDGrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DdVyXD/s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DdVyXD/s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2DCEC433C7; Sun, 18 Feb 2024 17:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708277288; bh=qMELB7PQmn3jz1qdSc2O9qlVDGZ3OQJIk3MInMF/wUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdVyXD/sIO5uOLVAQvmOFMemF2AMXSCK8c55tS0FBtTifRZLvb47ixXPETnkaBqmR PpRgGLG2AwY9FfsLDNuP0OTtZ/yU+80hUyEIDYTEKhYFOPF98nDbF+3UTso+LEBh6c AKWVRkQC6jEmCu3lLCB8bTCQ6WC5v8GW1Ak04VJQpZoVlz77zVWAkWJpKq953mnNKt 2maZPZIpA/LSsPMsTUj6ZcRANI/uUUCm0Nk1h+ftW7VBnDla5YCUSiocS+4jeXrSR+ LKxCTZCIE+7bz2wfFLca82Y7VdiYV0Cf6VvJgy2PKlhWRcnlxYml3YSP2Ah6ApH9xy HCSfEipV++LVQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Andy Shevchenko Cc: Lars-Peter Clausen , Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , Alisa-Dariana Roman , Haibo Chen , Sean Nyekjaer , Andreas Klinger , Jonathan Cameron Subject: [PATCH 8/8] iio: adc: hx711: Switch from of specific to fwnode property handling. Date: Sun, 18 Feb 2024 17:27:31 +0000 Message-ID: <20240218172731.1023367-9-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240218172731.1023367-1-jic23@kernel.org> References: <20240218172731.1023367-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Allows driver to be used with other firmware types and removes an example that might be copied into new IIO drivers. Cc: Andreas Klinger Signed-off-by: Jonathan Cameron --- drivers/iio/adc/hx711.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index c80c55fb8c6c..fef97c1d226a 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -459,7 +459,6 @@ static const struct iio_chan_spec hx711_chan_spec[] = { static int hx711_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; struct hx711_data *hx711_data; struct iio_dev *indio_dev; int ret; @@ -533,7 +532,7 @@ static int hx711_probe(struct platform_device *pdev) hx711_data->gain_chan_a = 128; hx711_data->clock_frequency = 400000; - ret = of_property_read_u32(np, "clock-frequency", + ret = device_property_read_u32(&pdev->dev, "clock-frequency", &hx711_data->clock_frequency); /*