* [PATCH v1 0/2] spi: Unify and simplify fwnode related checks
@ 2024-12-08 16:03 Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 1/2] spi: Unify firmware node type checks Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-12-08 16:03 UTC (permalink / raw)
To: Mark Brown, linux-spi, linux-kernel; +Cc: Andy Shevchenko
A couple of cleanups on top of recently added change.
Andy Shevchenko (2):
spi: Unify firmware node type checks
spi: Deduplicate deferred probe checks in spi_probe()
drivers/spi/spi.c | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/2] spi: Unify firmware node type checks
2024-12-08 16:03 [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Andy Shevchenko
@ 2024-12-08 16:03 ` Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 2/2] spi: Deduplicate deferred probe checks in spi_probe() Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-12-08 16:03 UTC (permalink / raw)
To: Mark Brown, linux-spi, linux-kernel; +Cc: Andy Shevchenko
The few functions are using different approaches on how to check for
the type of firmware node. Unify them to use a modern way of it.
With that in place it becomes obvious that no need to have independent
conditionals when they are dependent and hence the code generation can
be improved a little bit (clang-18, x86_64):
add/remove: 0/0 grow/shrink: 2/2 up/down: 16/-46 (-30)
Total: Before=49801, After=49771, chg -0.06%
Meanwhile no functional changes intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/spi/spi.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ff1add2ecb91..88f785b9e6ec 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -410,24 +410,21 @@ static int spi_probe(struct device *dev)
{
const struct spi_driver *sdrv = to_spi_driver(dev->driver);
struct spi_device *spi = to_spi_device(dev);
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
int ret;
ret = of_clk_set_defaults(dev->of_node, false);
if (ret)
return ret;
- if (dev->of_node) {
+ if (is_of_node(fwnode)) {
spi->irq = of_irq_get(dev->of_node, 0);
if (spi->irq == -EPROBE_DEFER)
return dev_err_probe(dev, -EPROBE_DEFER, "Failed to get irq\n");
if (spi->irq < 0)
spi->irq = 0;
- }
-
- if (has_acpi_companion(dev) && spi->irq < 0) {
- struct acpi_device *adev = to_acpi_device_node(dev->fwnode);
-
- spi->irq = acpi_dev_gpio_irq_get(adev, 0);
+ } else if (is_acpi_device_node(fwnode) && spi->irq < 0) {
+ spi->irq = acpi_dev_gpio_irq_get(to_acpi_device_node(fwnode), 0);
if (spi->irq == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (spi->irq < 0)
@@ -874,15 +871,18 @@ EXPORT_SYMBOL_GPL(spi_new_device);
*/
void spi_unregister_device(struct spi_device *spi)
{
+ struct fwnode_handle *fwnode;
+
if (!spi)
return;
- if (spi->dev.of_node) {
- of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
- of_node_put(spi->dev.of_node);
+ fwnode = dev_fwnode(&spi->dev);
+ if (is_of_node(fwnode)) {
+ of_node_clear_flag(to_of_node(fwnode), OF_POPULATED);
+ of_node_put(to_of_node(fwnode));
+ } else if (is_acpi_device_node(fwnode)) {
+ acpi_device_clear_enumerated(to_acpi_device_node(fwnode));
}
- if (ACPI_COMPANION(&spi->dev))
- acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
device_remove_software_node(&spi->dev);
device_del(&spi->dev);
spi_cleanup(spi);
@@ -1059,7 +1059,7 @@ static void spi_toggle_csgpiod(struct spi_device *spi, u8 idx, bool enable, bool
* ambiguity. That's why we use enable, that takes SPI_CS_HIGH
* into account.
*/
- if (has_acpi_companion(&spi->dev))
+ if (is_acpi_device_node(dev_fwnode(&spi->dev)))
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx), !enable);
else
/* Polarity handled by GPIO library */
@@ -4841,7 +4841,7 @@ extern struct notifier_block spi_of_notifier;
#if IS_ENABLED(CONFIG_ACPI)
static int spi_acpi_controller_match(struct device *dev, const void *data)
{
- return ACPI_COMPANION(dev->parent) == data;
+ return device_match_acpi_dev(dev->parent, data);
}
struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] spi: Deduplicate deferred probe checks in spi_probe()
2024-12-08 16:03 [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 1/2] spi: Unify firmware node type checks Andy Shevchenko
@ 2024-12-08 16:03 ` Andy Shevchenko
2024-12-10 18:05 ` [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Mark Brown
2024-12-11 4:12 ` Mukesh Kumar Savaliya
3 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-12-08 16:03 UTC (permalink / raw)
To: Mark Brown, linux-spi, linux-kernel; +Cc: Andy Shevchenko
Deduplicate deferred probe checks in spi_probe() and enable
the error message for ACPI case as well.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/spi/spi.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 88f785b9e6ec..e0f79773be70 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -417,19 +417,14 @@ static int spi_probe(struct device *dev)
if (ret)
return ret;
- if (is_of_node(fwnode)) {
+ if (is_of_node(fwnode))
spi->irq = of_irq_get(dev->of_node, 0);
- if (spi->irq == -EPROBE_DEFER)
- return dev_err_probe(dev, -EPROBE_DEFER, "Failed to get irq\n");
- if (spi->irq < 0)
- spi->irq = 0;
- } else if (is_acpi_device_node(fwnode) && spi->irq < 0) {
+ else if (is_acpi_device_node(fwnode) && spi->irq < 0)
spi->irq = acpi_dev_gpio_irq_get(to_acpi_device_node(fwnode), 0);
- if (spi->irq == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- if (spi->irq < 0)
- spi->irq = 0;
- }
+ if (spi->irq == -EPROBE_DEFER)
+ return dev_err_probe(dev, spi->irq, "Failed to get irq\n");
+ if (spi->irq < 0)
+ spi->irq = 0;
ret = dev_pm_domain_attach(dev, true);
if (ret)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] spi: Unify and simplify fwnode related checks
2024-12-08 16:03 [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 1/2] spi: Unify firmware node type checks Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 2/2] spi: Deduplicate deferred probe checks in spi_probe() Andy Shevchenko
@ 2024-12-10 18:05 ` Mark Brown
2024-12-11 4:12 ` Mukesh Kumar Savaliya
3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2024-12-10 18:05 UTC (permalink / raw)
To: linux-spi, linux-kernel, Andy Shevchenko
On Sun, 08 Dec 2024 18:03:15 +0200, Andy Shevchenko wrote:
> A couple of cleanups on top of recently added change.
>
> Andy Shevchenko (2):
> spi: Unify firmware node type checks
> spi: Deduplicate deferred probe checks in spi_probe()
>
> drivers/spi/spi.c | 41 ++++++++++++++++++-----------------------
> 1 file changed, 18 insertions(+), 23 deletions(-)
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/2] spi: Unify firmware node type checks
commit: b6ffe0e6147915fe3d31705e14dfbbecb724fb81
[2/2] spi: Deduplicate deferred probe checks in spi_probe()
commit: 0020c9d2d572b49c55b2e1fabe6f6687e11a3ced
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] spi: Unify and simplify fwnode related checks
2024-12-08 16:03 [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Andy Shevchenko
` (2 preceding siblings ...)
2024-12-10 18:05 ` [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Mark Brown
@ 2024-12-11 4:12 ` Mukesh Kumar Savaliya
2024-12-11 10:59 ` Andy Shevchenko
3 siblings, 1 reply; 7+ messages in thread
From: Mukesh Kumar Savaliya @ 2024-12-11 4:12 UTC (permalink / raw)
To: Andy Shevchenko, Mark Brown, linux-spi, linux-kernel
On 12/8/2024 9:33 PM, Andy Shevchenko wrote:
> couple of cleanups on top of recently added change.
please add what exactly cleanups done ? Recently added change is not
that something someone would check as part of this patch.
Description would be helpful.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] spi: Unify and simplify fwnode related checks
2024-12-11 4:12 ` Mukesh Kumar Savaliya
@ 2024-12-11 10:59 ` Andy Shevchenko
2024-12-11 11:33 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-12-11 10:59 UTC (permalink / raw)
To: Mukesh Kumar Savaliya; +Cc: Mark Brown, linux-spi, linux-kernel
On Wed, Dec 11, 2024 at 09:42:33AM +0530, Mukesh Kumar Savaliya wrote:
> On 12/8/2024 9:33 PM, Andy Shevchenko wrote:
> > couple of cleanups on top of recently added change.
> please add what exactly cleanups done ? Recently added change is not that
> something someone would check as part of this patch.
> Description would be helpful.
But each patch has its description. Or I didn't get the request, sorry.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 0/2] spi: Unify and simplify fwnode related checks
2024-12-11 10:59 ` Andy Shevchenko
@ 2024-12-11 11:33 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-12-11 11:33 UTC (permalink / raw)
To: Mukesh Kumar Savaliya; +Cc: Mark Brown, linux-spi, linux-kernel
On Wed, Dec 11, 2024 at 12:59:42PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 11, 2024 at 09:42:33AM +0530, Mukesh Kumar Savaliya wrote:
> > On 12/8/2024 9:33 PM, Andy Shevchenko wrote:
> > > couple of cleanups on top of recently added change.
> > please add what exactly cleanups done ? Recently added change is not that
> > something someone would check as part of this patch.
> > Description would be helpful.
>
> But each patch has its description. Or I didn't get the request, sorry.
FWIW, the change induced this mini-series is this one: d24cfee7f63d ("spi: Fix
acpi deferred irq probe").
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-12-11 11:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-08 16:03 [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 1/2] spi: Unify firmware node type checks Andy Shevchenko
2024-12-08 16:03 ` [PATCH v1 2/2] spi: Deduplicate deferred probe checks in spi_probe() Andy Shevchenko
2024-12-10 18:05 ` [PATCH v1 0/2] spi: Unify and simplify fwnode related checks Mark Brown
2024-12-11 4:12 ` Mukesh Kumar Savaliya
2024-12-11 10:59 ` Andy Shevchenko
2024-12-11 11:33 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).