Commit ec8c2329 authored by Rob Herring (Arm)'s avatar Rob Herring (Arm)
Browse files

of: Constify struct device_node function arguments



Functions which don't change the refcount or otherwise modify struct
device_node can make struct device_node const.

Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20241010-dt-const-v1-3-87a51f558425@kernel.org


Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent f68303cf
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ static unsigned int of_bus_pci_get_flags(const __be32 *addr)
 * PCI bus specific translator
 */

static bool of_node_is_pcie(struct device_node *np)
static bool of_node_is_pcie(const struct device_node *np)
{
	bool is_pcie = of_node_name_eq(np, "pcie");

@@ -230,8 +230,8 @@ static int __of_address_resource_bounds(struct resource *r, u64 start, u64 size)
 * To guard against that we try to register the IO range first.
 * If that fails we know that pci_address_to_pio() will do too.
 */
int of_pci_range_to_resource(struct of_pci_range *range,
			     struct device_node *np, struct resource *res)
int of_pci_range_to_resource(const struct of_pci_range *range,
			     const struct device_node *np, struct resource *res)
{
	u64 start;
	int err;
@@ -399,7 +399,7 @@ static struct of_bus *of_match_bus(struct device_node *np)
	return NULL;
}

static int of_empty_ranges_quirk(struct device_node *np)
static int of_empty_ranges_quirk(const struct device_node *np)
{
	if (IS_ENABLED(CONFIG_PPC)) {
		/* To save cycles, we cache the result for global "Mac" setting */
@@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(of_dma_is_coherent);
 * This is currently only enabled on builds that support Apple ARM devices, as
 * an optimization.
 */
static bool of_mmio_is_nonposted(struct device_node *np)
static bool of_mmio_is_nonposted(const struct device_node *np)
{
	if (!IS_ENABLED(CONFIG_ARCH_APPLE))
		return false;
+4 −4
Original line number Diff line number Diff line
@@ -771,7 +771,7 @@ struct device_node *of_get_child_by_name(const struct device_node *node,
}
EXPORT_SYMBOL(of_get_child_by_name);

struct device_node *__of_find_node_by_path(struct device_node *parent,
struct device_node *__of_find_node_by_path(const struct device_node *parent,
						const char *path)
{
	struct device_node *child;
@@ -1840,7 +1840,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 *
 * Return: The alias id if found.
 */
int of_alias_get_id(struct device_node *np, const char *stem)
int of_alias_get_id(const struct device_node *np, const char *stem)
{
	struct alias_prop *app;
	int id = -ENODEV;
@@ -1898,7 +1898,7 @@ EXPORT_SYMBOL_GPL(of_alias_get_highest_id);
 *
 * Return: TRUE if console successfully setup. Otherwise return FALSE.
 */
bool of_console_check(struct device_node *dn, char *name, int index)
bool of_console_check(const struct device_node *dn, char *name, int index)
{
	if (!dn || dn != of_stdout || console_set_on_cmdline)
		return false;
@@ -1986,7 +1986,7 @@ int of_find_last_cache_level(unsigned int cpu)
 *
 * Return: 0 on success or a standard error code on failure.
 */
int of_map_id(struct device_node *np, u32 id,
int of_map_id(const struct device_node *np, u32 id,
	       const char *map_name, const char *map_mask_name,
	       struct device_node **target, u32 *id_out)
{
+1 −1
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ EXPORT_SYMBOL(of_cpu_node_to_id);
 * Return: An idle state node if found at @index. The refcount is incremented
 * for it, so call of_node_put() on it when done. Returns NULL if not found.
 */
struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
struct device_node *of_get_cpu_state_node(const struct device_node *cpu_node,
					  int index)
{
	struct of_phandle_args args;
+2 −2
Original line number Diff line number Diff line
@@ -720,7 +720,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id,
 * Returns: the MSI domain for this device (or NULL on failure).
 */
struct irq_domain *of_msi_get_domain(struct device *dev,
				     struct device_node *np,
				     const struct device_node *np,
				     enum irq_domain_bus_token token)
{
	struct of_phandle_iterator it;
@@ -742,7 +742,7 @@ EXPORT_SYMBOL_GPL(of_msi_get_domain);
 * @dev: device structure to associate with an MSI irq domain
 * @np: device node for that device
 */
void of_msi_configure(struct device *dev, struct device_node *np)
void of_msi_configure(struct device *dev, const struct device_node *np)
{
	dev_set_msi_domain(dev,
			   of_msi_get_domain(dev, np, DOMAIN_BUS_PLATFORM_MSI));
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ void __of_prop_free(struct property *prop);
struct device_node *__of_node_dup(const struct device_node *np,
				  const char *full_name);

struct device_node *__of_find_node_by_path(struct device_node *parent,
struct device_node *__of_find_node_by_path(const struct device_node *parent,
						const char *path);
struct device_node *__of_find_node_by_full_path(struct device_node *node,
						const char *path);
Loading