Bjorn, On Wed, 1 Aug 2018 10:49:57 +0200, Thomas Petazzoni wrote: > > I wonder if there's a way to use a common helper function to do this. > > Yes, this small bit of logic is duplicated all over the place. I'll see > if I can come up with some reasonable helpers for that. Here is an attempt at doing this: - Introduce some helpers https://github.com/MISL-EBU-System-SW/mainline-public/commit/55543d2050d9aa3abe297569be830bde8680e1e9 - Use them in drivers/pci/access.c https://github.com/MISL-EBU-System-SW/mainline-public/commit/ce6158d5c6a039e0cddf5ee6840dadeb46c5fc4b - Use them in PCI host controller drivers https://github.com/MISL-EBU-System-SW/mainline-public/commit/df4d0b5272ea3b4c3226c96466e5360c5a89253f I'm not a big fan of the naming though. Let me know what you think, if you think it's worth it, I'll submit the patches. Note: the whole thing is compile-tested only for now. Best regards, Thomas -- Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com