Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fsi: Use of_property_read_reg() to parse "reg"

Use the recently added of_property_read_reg() helper to get the
untranslated "reg" address value.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230609183056.1765183-1-robh@kernel.org
Signed-off-by: Joel Stanley <joel@jms.id.au>

authored by

Rob Herring and committed by
Joel Stanley
23ad7ec1 288f1acf

+9 -30
+9 -30
drivers/fsi/fsi-core.c
··· 16 16 #include <linux/idr.h> 17 17 #include <linux/module.h> 18 18 #include <linux/of.h> 19 + #include <linux/of_address.h> 19 20 #include <linux/slab.h> 20 21 #include <linux/bitops.h> 21 22 #include <linux/cdev.h> ··· 416 415 static bool fsi_device_node_matches(struct device *dev, struct device_node *np, 417 416 uint32_t addr, uint32_t size) 418 417 { 419 - unsigned int len, na, ns; 420 - const __be32 *prop; 421 - uint32_t psize; 418 + u64 paddr, psize; 422 419 423 - na = of_n_addr_cells(np); 424 - ns = of_n_size_cells(np); 425 - 426 - if (na != 1 || ns != 1) 420 + if (of_property_read_reg(np, 0, &paddr, &psize)) 427 421 return false; 428 422 429 - prop = of_get_property(np, "reg", &len); 430 - if (!prop || len != 8) 423 + if (paddr != addr) 431 424 return false; 432 425 433 - if (of_read_number(prop, 1) != addr) 434 - return false; 435 - 436 - psize = of_read_number(prop + 1, 1); 437 426 if (psize != size) { 438 427 dev_warn(dev, 439 - "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", 440 - of_node_full_name(np), psize, size); 428 + "node %pOF matches probed address, but not size (got 0x%llx, expected 0x%x)", 429 + np, psize, size); 441 430 } 442 431 443 432 return true; ··· 644 653 static bool fsi_slave_node_matches(struct device_node *np, 645 654 int link, uint8_t id) 646 655 { 647 - unsigned int len, na, ns; 648 - const __be32 *prop; 656 + u64 addr; 649 657 650 - na = of_n_addr_cells(np); 651 - ns = of_n_size_cells(np); 652 - 653 - /* Ensure we have the correct format for addresses and sizes in 654 - * reg properties 655 - */ 656 - if (na != 2 || ns != 0) 658 + if (of_property_read_reg(np, 0, &addr, NULL)) 657 659 return false; 658 660 659 - prop = of_get_property(np, "reg", &len); 660 - if (!prop || len != 8) 661 - return false; 662 - 663 - return (of_read_number(prop, 1) == link) && 664 - (of_read_number(prop + 1, 1) == id); 661 + return addr == (((u64)link << 32) | id); 665 662 } 666 663 667 664 /* Find a matching node for the slave at (link, id). Returns NULL if none