Skip to contentSkip to conversation

spi: tegra: don't treat NULL clk as an error

PATCH New Jamie Iles 3 participants 7 messages Jan 10, 2011

Subsystems (2)
lore
Share & tools
lore

Jamie Iles

author
#0 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Some platforms have been known to return NULL from clk_get() if they support only a single struct clk. Whilst tegra doesn't do this, make the drivers consistent with others.

---

 drivers/spi/spi_tegra.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/spi/spi_tegra.c +1 -1
index bb7df02..891e590 100644
@@ -513,7 +513,7 @@ static int __init spi_tegra_probe(struct platform_device *pdev)
 	}
 
 	tspi->clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR_OR_NULL(tspi->clk)) {
+	if (IS_ERR(tspi->clk)) {
 		dev_err(&pdev->dev, "can not get clock\n");
 		ret = PTR_ERR(tspi->clk);
 		goto err2;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 6 lines · Jamie Iles

Some platforms have been known to return NULL from clk_get() if they support only a single struct clk. ?Whilst tegra doesn't do this, make the drivers consistent with others.

Hi James,

If NULL does get returned, say due to a future change to the clock code, then this change causes the driver to oops. I'm not going to apply this patch.

g.

Quoted 27 lines

---

?drivers/spi/spi_tegra.c | ? ?2 +-
?1 files changed, 1 insertions(+), 1 deletions(-)

drivers/spi/spi_tegra.c +1 -2
index bb7df02..891e590 100644
@@ -513,7 +513,7 @@ static int __init spi_tegra_probe(struct platform_device *pdev)
 ? ? ? ?}
 
 ? ? ? ?tspi->clk = clk_get(&pdev->dev, NULL);
- ? ? ? if (IS_ERR_OR_NULL(tspi->clk)) {
+ ? ? ? if (IS_ERR(tspi->clk)) {
 ? ? ? ? ? ? ? ?dev_err(&pdev->dev, "can not get clock\n");
 ? ? ? ? ? ? ? ?ret = PTR_ERR(tspi->clk);
 ? ? ? ? ? ? ? ?goto err2;
--

1.7.3.4

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#2 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 5 lines · Grant Likely
Quoted 4 lines · Jamie Iles

Some platforms have been known to return NULL from clk_get() if they support only a single struct clk. ?Whilst tegra doesn't do this, make the drivers consistent with others.

Quoted 8 lines
Quoted 2 lines

Hi James,

If NULL does get returned, say due to a future change to the clock code, then this change causes the driver to oops. I'm not going to apply this patch.

Please apply it - the clock API just defines struct clk as a cookie where errors are IS_ERR/PTR_ERR. Other values must be considered by drivers as perfectly valid, including NULL.

#3 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Grant Likely
Quoted 6 lines · Jamie Iles

Some platforms have been known to return NULL from clk_get() if they support only a single struct clk. ?Whilst tegra doesn't do this, make the drivers consistent with others.

Hi James,

Quoted 7 lines
Quoted 3 lines

If NULL does get returned, say due to a future change to the clock code, then this change causes the driver to oops. I'm not going to apply this patch.

Please apply it - the clock API just defines struct clk as a cookie where errors are IS_ERR/PTR_ERR. Other values must be considered by drivers as perfectly valid, including NULL.

Also note that drivers have no business ever dereferencing struct clks. So if they oops, that's their own fault for dereferencing something that they shouldn't.

#4 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Russell King - ARM Linux
Quoted 13 lines · Grant Likely
Quoted 6 lines · Jamie Iles

Some platforms have been known to return NULL from clk_get() if they support only a single struct clk. ?Whilst tegra doesn't do this, make the drivers consistent with others.

Hi James,

If NULL does get returned, say due to a future change to the clock code, then this change causes the driver to oops. ?I'm not going to apply this patch.

Quoted 7 lines
Quoted 3 lines

Please apply it - the clock API just defines struct clk as a cookie where errors are IS_ERR/PTR_ERR. ?Other values must be considered by drivers as perfectly valid, including NULL.

Also note that drivers have no business ever dereferencing struct clks. So if they oops, that's their own fault for dereferencing something that they shouldn't.

I was actually looking at the implementation of clk_enable() which is called by the driver and doesn't do any NULL checking. But I suppose that it then becomes the clock-code's own fault if it returns NULL and then oopses on a NULL being passed to it. Okay, I'll apply it.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#5 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 4 lines · Grant Likely

I was actually looking at the implementation of clk_enable() which is called by the driver and doesn't do any NULL checking. But I suppose that it then becomes the clock-code's own fault if it returns NULL and then oopses on a NULL being passed to it. Okay, I'll apply it.

Yes absolutely. The clk API must eat whatever cookies it produces, even if they contain dead flies rather than currants. ;)

#6 lore raw

PATCH 1/1 spi: tegra: don't treat NULL clk as an error

Quoted 8 lines · Russell King - ARM Linux
Quoted 4 lines · Grant Likely

I was actually looking at the implementation of clk_enable() which is called by the driver and doesn't do any NULL checking. But I suppose that it then becomes the clock-code's own fault if it returns NULL and then oopses on a NULL being passed to it. Okay, I'll apply it.

Yes absolutely. The clk API must eat whatever cookies it produces, even if they contain dead flies rather than currants. ;)

nice analogy. :-)

g.