hwrng: pasemi_rng.c: Migrate to managed API
Subsystems (3)
PATCH 1/1 hwrng: pasemi_rng.c: Migrate to managed API
Use devm_ioremap and devm_hwrng_register instead of ioremap and hwrng_register. This removes unregistering and error handling code.
This patch is not tested with hardware as I don't have access to it.
--- drivers/char/hw_random/pasemi-rng.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/char/hw_random/pasemi-rng.c +3 -23
@@ -100,37 +100,18 @@ static int rng_probe(struct platform_device *ofdev)void __iomem *rng_regs;struct device_node *rng_np = ofdev->dev.of_node;struct resource res; -int err =0 ; - err =of_address_to_resource (rng_np,0 , &res); -if (err) +if (of_address_to_resource (rng_np,0 , &res))return -ENODEV ; - rng_regs =ioremap (res.start,0x100 ); - + rng_regs =devm_ioremap (&ofdev->dev, res.start,0x100 );if (!rng_regs)return -ENOMEM ; pasemi_rng.priv = (unsigned long )rng_regs;pr_info ("Registering PA Semi RNG\n" ); - - err =hwrng_register (&pasemi_rng); - -if (err) -iounmap (rng_regs); - -return err; -} - -static int rng_remove (struct platform_device *dev) -{ -void __iomem *rng_regs = (void __iomem *)pasemi_rng.priv; - -hwrng_unregister (&pasemi_rng); -iounmap (rng_regs); - -return 0 ; +return devm_hwrng_register (&ofdev->dev, &pasemi_rng); }static const struct of_device_id rng_match[] = {
@@ -146,7 +127,6 @@ static struct platform_driver rng_driver = { .of_match_table = rng_match, }, .probe = rng_probe, - .remove = rng_remove, };module_platform_driver (rng_driver);
Signature · 1 line
2.5.0
Quoted 21 lines · PrasannaKumar Muralidharan
Use
devm_ioremapanddevm_hwrng_registerinstead of ioremap andhwrng_register. This removes unregistering and error handling code.This patch is not tested with hardware as I don't have access to it.
Signed-off-by PrasannaKumar Muralidharan <[email protected]>--- drivers/char/hw_random/pasemi-rng.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)drivers/char/hw_random/pasemi-rng.c +0
-2@@ -100,37 +100,18 @@ static int rng_probe(struct platform_device *ofdev)void __iomem *rng_regs;struct device_node *rng_np = ofdev->dev.of_node;struct resource res; -int err =0 ; - err =of_address_to_resource (rng_np,0 , &res);
drivers/char/hw_random/pasemi-rng.c static int rng_probe(struct platform_device *ofdev) · line 110
Quoted 10 lines
drivers/char/hw_random/pasemi-rng.c +2
-3-if (err) +if (of_address_to_resource (rng_np,0 , &res))return -ENODEV ; - rng_regs =ioremap (res.start,0x100 ); - + rng_regs =devm_ioremap (&ofdev->dev, res.start,0x100 );if (!rng_regs)return -ENOMEM ;
I will propose to use devm_ioremap_resource() instead for removing this hardcoded 0x100, but i cannot find any user of this driver in any dts. (And so cannot check that this 0x100 is given in any DT resource node)
Is this normal ?
Regard
Quoted 3 lines
I will propose to use
devm_ioremap_resource()instead for removing this hardcoded0x100, but i cannot find any user of this driver in any dts. (And so cannot check that this0x100is given in any DT resource node)Is this normal ?
I wanted to use devm_ioremap_resource but could not find DT entry required for this driver in any of the .dts files. So did not change that. I could not find any dts/dtsi for this platform. So I assume that the dtb is not present in the kernel, dtb is supplied by the bootloader. I may be wrong in this. Can anyone confirm this?
Regards,
PrasannaKumar
Hello PrasannaKumar
Quoted 11 lines · PrasannaKumar Muralidharan
Quoted 5 lines
I will propose to use
devm_ioremap_resource()instead for removing this hardcoded0x100, but i cannot find any user of this driver in any dts. (And so cannot check that this0x100is given in any DT resource node)Is this normal ?
I wanted to use
devm_ioremap_resourcebut could not find DT entry required for this driver in any of the .dts files. So did not change that. I could not find any dts/dtsi for this platform. So I assume that the dtb is not present in the kernel, dtb is supplied by the bootloader. I may be wrong in this. Can anyone confirm this?
On mine (Amigaone X1000) that is correct, we boot linux with a vmlinux file, and the bootloader (CFE) passes a fixed dtb. I think it is possible to dump the tree from inside CFE, if it would help I can invetigate?
Regards
Darren
Hi Darren,
Quoted 9 lines
Quoted 5 lines
I wanted to use
devm_ioremap_resourcebut could not find DT entry required for this driver in any of the .dts files. So did not change that. I could not find any dts/dtsi for this platform. So I assume that the dtb is not present in the kernel, dtb is supplied by the bootloader. I may be wrong in this. Can anyone confirm this?On mine (Amigaone X1000) that is correct, we boot linux with a vmlinux file, and the bootloader (CFE) passes a fixed dtb. I think it is possible to dump the tree from inside CFE, if it would help I can invetigate?
I don't know if it is possible to get dts from dtb even if you manage to extract devicetree blob from your system.
Labbe, Do you know anyway to get dts from dtb? Is this step really required to remove 0x100 value for this patch given that the value was present here for years? If extracting dtb and converting dtb to dts is easy and not time consuming, I am in favour of finding a way to remove hard coded value.
Hello PrasannaKumar
Quoted 8 lines · PrasannaKumar Muralidharan
Hi Darren,
Quoted 4 lines
On mine (Amigaone X1000) that is correct, we boot linux with a vmlinux file, and the bootloader (CFE) passes a fixed dtb. I think it is possible to dump the tree from inside CFE, if it would help I can invetigate?
I don't know if it is possible to get dts from dtb even if you manage to extract devicetree blob from your system.
I didn't explain well, There is a CFE command 'show devtree' here's the relevant bits (I Hope)
[CFE ]CFE> show devtree
[/]
| #interrupt-cells val 0x00000002 | #address-cells val 0x00000002 | #size-cells val 0x00000002
...[snip]...
[sdc@fc000000]
| name str 'sdc'
| device_type str 'sdc'
| #address-cells val 0x00000001
| #size-cells val 0x00000001
| compatible str '1682m-sdc' 'pasemi,pwrficient-sdc'
'pasemi,sdc'
| reg cell 00000000 FC000000 00000000 00800000 ...[snip]...
[rng@fc105000]
| name str 'rng'
| device_type str 'rng'
| compatible str '1682m-rng' 'pasemi,pwrficient-rng'
'pasemi,rng'
| reg cell FC105000 00001000
Regards
Quoted 2 lines
I didn't explain well, There is a CFE command 'show devtree' here's the relevant bits (I Hope)
This is much simple than I expected.
Quoted 17 lines
[CFE ]CFE> show devtree
[/]| #interrupt-cells val 0x00000002 | #address-cells val 0x00000002 | #size-cells val 0x00000002...[snip]...
[sdc@fc000000]
| name str 'sdc' | device_type str 'sdc' | #address-cells val 0x00000001 | #size-cells val 0x00000001 | compatible str '1682m-sdc' 'pasemi,pwrficient-sdc' 'pasemi,sdc' | reg cell 00000000 FC000000 00000000 00800000
Quoted 9 lines
...[snip]...
[rng@fc105000]
| name str 'rng'
|device_typestr 'rng'
| compatible str '1682m-rng' 'pasemi,pwrficient-rng'
'pasemi,rng'| reg cell FC105000 00001000
Device tree provided by CFE has the size. I will send another patch which uses devm_ioremap_resource().
Appreciate your help. Thank you :).