[PATCH] pcmcia: Use resource_size function on resource object

Jules Irenge posted 1 patch 1 year, 7 months ago
drivers/pcmcia/yenta_socket.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] pcmcia: Use resource_size function on resource object
Posted by Jules Irenge 1 year, 7 months ago
Cocinnele reports a warning

WARNING: Suspicious code. resource_size is maybe missing with root

The root cause is the function resource_size is not used when needed

Use resource_size() on variable "root" of type resource

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 drivers/pcmcia/yenta_socket.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 1365eaa20ff4..ff169124929c 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -638,11 +638,11 @@ static int yenta_search_one_res(struct resource *root, struct resource *res,
 		start = PCIBIOS_MIN_CARDBUS_IO;
 		end = ~0U;
 	} else {
-		unsigned long avail = root->end - root->start;
+		unsigned long avail = resource_size(root);
 		int i;
 		size = BRIDGE_MEM_MAX;
-		if (size > avail/8) {
-			size = (avail+1)/8;
+		if (size > (avail - 1) / 8) {
+			size = avail / 8;
 			/* round size down to next power of 2 */
 			i = 0;
 			while ((size /= 2) != 0)
-- 
2.43.2
Re: [PATCH] pcmcia: Use resource_size function on resource object
Posted by Dominik Brodowski 1 year, 5 months ago
Am Sun, May 12, 2024 at 11:31:21PM +0100 schrieb Jules Irenge:
> Cocinnele reports a warning
> 
> WARNING: Suspicious code. resource_size is maybe missing with root
> 
> The root cause is the function resource_size is not used when needed
> 
> Use resource_size() on variable "root" of type resource
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied to pcmcia-next. Thanks!

Best,
	Dominik