Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1470083 > unrolled thread
| Started by | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
|---|---|
| First post | 2016-08-25 13:40 +0200 |
| Last post | 2016-09-01 09:10 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] hwrng: pasemi_rng.c: Migrate to managed API PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> - 2016-08-25 13:40 +0200
Re: [PATCH] hwrng: pasemi_rng.c: Migrate to managed API LABBE Corentin <clabbe.montjoie@gmail.com> - 2016-08-25 14:20 +0200
Re: [PATCH] hwrng: pasemi_rng.c: Migrate to managed API PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> - 2016-08-25 15:30 +0200
Re: hwrng: pasemi_rng.c: Migrate to managed API Darren Stevens <darren@stevens-zone.net> - 2016-08-29 21:00 +0200
Re: hwrng: pasemi_rng.c: Migrate to managed API PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> - 2016-08-30 09:20 +0200
Re: hwrng: pasemi_rng.c: Migrate to managed API Darren Stevens <darren@stevens-zone.net> - 2016-08-31 16:10 +0200
Re: hwrng: pasemi_rng.c: Migrate to managed API PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> - 2016-09-01 09:10 +0200
| From | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
|---|---|
| Date | 2016-08-25 13:40 +0200 |
| Subject | [PATCH] hwrng: pasemi_rng.c: Migrate to managed API |
| Message-ID | <sa1aN-nw-15@gated-at.bofh.it> |
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.
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
---
drivers/char/hw_random/pasemi-rng.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c
index 699b725..0f03397 100644
--- a/drivers/char/hw_random/pasemi-rng.c
+++ b/drivers/char/hw_random/pasemi-rng.c
@@ -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);
--
2.5.0
[toc] | [next] | [standalone]
| From | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2016-08-25 14:20 +0200 |
| Message-ID | <sa1Nv-PS-1@gated-at.bofh.it> |
| In reply to | #1470083 |
On Thu, Aug 25, 2016 at 05:04:16PM +0530, PrasannaKumar Muralidharan wrote: > 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. > > Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> > --- > drivers/char/hw_random/pasemi-rng.c | 26 +++----------------------- > 1 file changed, 3 insertions(+), 23 deletions(-) > > diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c > index 699b725..0f03397 100644 > --- a/drivers/char/hw_random/pasemi-rng.c > +++ b/drivers/char/hw_random/pasemi-rng.c > @@ -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; > 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
[toc] | [prev] | [next] | [standalone]
| From | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
|---|---|
| Date | 2016-08-25 15:30 +0200 |
| Message-ID | <sa2Tf-1tU-1@gated-at.bofh.it> |
| In reply to | #1470101 |
> 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 ? 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
[toc] | [prev] | [next] | [standalone]
| From | Darren Stevens <darren@stevens-zone.net> |
|---|---|
| Date | 2016-08-29 21:00 +0200 |
| Subject | Re: hwrng: pasemi_rng.c: Migrate to managed API |
| Message-ID | <sbzWN-2uN-21@gated-at.bofh.it> |
| In reply to | #1470138 |
Hello PrasannaKumar On 25/08/2016, PrasannaKumar Muralidharan wrote: >> 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 ? > > 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? 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
[toc] | [prev] | [next] | [standalone]
| From | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
|---|---|
| Date | 2016-08-30 09:20 +0200 |
| Subject | Re: hwrng: pasemi_rng.c: Migrate to managed API |
| Message-ID | <sbLuV-1Hg-3@gated-at.bofh.it> |
| In reply to | #1472055 |
Hi Darren, >> 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? > > 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.
[toc] | [prev] | [next] | [standalone]
| From | Darren Stevens <darren@stevens-zone.net> |
|---|---|
| Date | 2016-08-31 16:10 +0200 |
| Subject | Re: hwrng: pasemi_rng.c: Migrate to managed API |
| Message-ID | <sceng-3nc-23@gated-at.bofh.it> |
| In reply to | #1472267 |
Hello PrasannaKumar
On 30/08/2016, PrasannaKumar Muralidharan wrote:
> Hi Darren,
>> 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
[toc] | [prev] | [next] | [standalone]
| From | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> |
|---|---|
| Date | 2016-09-01 09:10 +0200 |
| Subject | Re: hwrng: pasemi_rng.c: Migrate to managed API |
| Message-ID | <scuim-5Pb-43@gated-at.bofh.it> |
| In reply to | #1473514 |
> 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. > [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 > Device tree provided by CFE has the size. I will send another patch which uses devm_ioremap_resource(). Appreciate your help. Thank you :).
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web