Skip to content

Commit ec8c232

Browse files
committed
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: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent f68303c commit ec8c232

File tree

10 files changed

+33
-33
lines changed

10 files changed

+33
-33
lines changed

drivers/of/address.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static unsigned int of_bus_pci_get_flags(const __be32 *addr)
147147
* PCI bus specific translator
148148
*/
149149

150-
static bool of_node_is_pcie(struct device_node *np)
150+
static bool of_node_is_pcie(const struct device_node *np)
151151
{
152152
bool is_pcie = of_node_name_eq(np, "pcie");
153153

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

402-
static int of_empty_ranges_quirk(struct device_node *np)
402+
static int of_empty_ranges_quirk(const struct device_node *np)
403403
{
404404
if (IS_ENABLED(CONFIG_PPC)) {
405405
/* To save cycles, we cache the result for global "Mac" setting */
@@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(of_dma_is_coherent);
10301030
* This is currently only enabled on builds that support Apple ARM devices, as
10311031
* an optimization.
10321032
*/
1033-
static bool of_mmio_is_nonposted(struct device_node *np)
1033+
static bool of_mmio_is_nonposted(const struct device_node *np)
10341034
{
10351035
if (!IS_ENABLED(CONFIG_ARCH_APPLE))
10361036
return false;

drivers/of/base.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ struct device_node *of_get_child_by_name(const struct device_node *node,
771771
}
772772
EXPORT_SYMBOL(of_get_child_by_name);
773773

774-
struct device_node *__of_find_node_by_path(struct device_node *parent,
774+
struct device_node *__of_find_node_by_path(const struct device_node *parent,
775775
const char *path)
776776
{
777777
struct device_node *child;
@@ -1840,7 +1840,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
18401840
*
18411841
* Return: The alias id if found.
18421842
*/
1843-
int of_alias_get_id(struct device_node *np, const char *stem)
1843+
int of_alias_get_id(const struct device_node *np, const char *stem)
18441844
{
18451845
struct alias_prop *app;
18461846
int id = -ENODEV;
@@ -1898,7 +1898,7 @@ EXPORT_SYMBOL_GPL(of_alias_get_highest_id);
18981898
*
18991899
* Return: TRUE if console successfully setup. Otherwise return FALSE.
19001900
*/
1901-
bool of_console_check(struct device_node *dn, char *name, int index)
1901+
bool of_console_check(const struct device_node *dn, char *name, int index)
19021902
{
19031903
if (!dn || dn != of_stdout || console_set_on_cmdline)
19041904
return false;
@@ -1986,7 +1986,7 @@ int of_find_last_cache_level(unsigned int cpu)
19861986
*
19871987
* Return: 0 on success or a standard error code on failure.
19881988
*/
1989-
int of_map_id(struct device_node *np, u32 id,
1989+
int of_map_id(const struct device_node *np, u32 id,
19901990
const char *map_name, const char *map_mask_name,
19911991
struct device_node **target, u32 *id_out)
19921992
{

drivers/of/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ EXPORT_SYMBOL(of_cpu_node_to_id);
188188
* Return: An idle state node if found at @index. The refcount is incremented
189189
* for it, so call of_node_put() on it when done. Returns NULL if not found.
190190
*/
191-
struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
191+
struct device_node *of_get_cpu_state_node(const struct device_node *cpu_node,
192192
int index)
193193
{
194194
struct of_phandle_args args;

drivers/of/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 id,
720720
* Returns: the MSI domain for this device (or NULL on failure).
721721
*/
722722
struct irq_domain *of_msi_get_domain(struct device *dev,
723-
struct device_node *np,
723+
const struct device_node *np,
724724
enum irq_domain_bus_token token)
725725
{
726726
struct of_phandle_iterator it;
@@ -742,7 +742,7 @@ EXPORT_SYMBOL_GPL(of_msi_get_domain);
742742
* @dev: device structure to associate with an MSI irq domain
743743
* @np: device node for that device
744744
*/
745-
void of_msi_configure(struct device *dev, struct device_node *np)
745+
void of_msi_configure(struct device *dev, const struct device_node *np)
746746
{
747747
dev_set_msi_domain(dev,
748748
of_msi_get_domain(dev, np, DOMAIN_BUS_PLATFORM_MSI));

drivers/of/of_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void __of_prop_free(struct property *prop);
127127
struct device_node *__of_node_dup(const struct device_node *np,
128128
const char *full_name);
129129

130-
struct device_node *__of_find_node_by_path(struct device_node *parent,
130+
struct device_node *__of_find_node_by_path(const struct device_node *parent,
131131
const char *path);
132132
struct device_node *__of_find_node_by_full_path(struct device_node *node,
133133
const char *path);

drivers/of/overlay.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
398398
* invalid @overlay.
399399
*/
400400
static int add_changeset_node(struct overlay_changeset *ovcs,
401-
struct target *target, struct device_node *node)
401+
struct target *target, const struct device_node *node)
402402
{
403403
const char *node_kbasename;
404404
const __be32 *phandle;
@@ -675,8 +675,8 @@ static int build_changeset(struct overlay_changeset *ovcs)
675675
* 1) "target" property containing the phandle of the target
676676
* 2) "target-path" property containing the path of the target
677677
*/
678-
static struct device_node *find_target(struct device_node *info_node,
679-
struct device_node *target_base)
678+
static struct device_node *find_target(const struct device_node *info_node,
679+
const struct device_node *target_base)
680680
{
681681
struct device_node *node;
682682
char *target_path;
@@ -735,7 +735,7 @@ static struct device_node *find_target(struct device_node *info_node,
735735
* init_overlay_changeset() must call free_overlay_changeset().
736736
*/
737737
static int init_overlay_changeset(struct overlay_changeset *ovcs,
738-
struct device_node *target_base)
738+
const struct device_node *target_base)
739739
{
740740
struct device_node *node, *overlay_node;
741741
struct fragment *fragment;
@@ -910,7 +910,7 @@ static void free_overlay_changeset(struct overlay_changeset *ovcs)
910910
*/
911911

912912
static int of_overlay_apply(struct overlay_changeset *ovcs,
913-
struct device_node *base)
913+
const struct device_node *base)
914914
{
915915
int ret = 0, ret_revert, ret_tmp;
916916

@@ -978,7 +978,7 @@ static int of_overlay_apply(struct overlay_changeset *ovcs,
978978
*/
979979

980980
int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
981-
int *ret_ovcs_id, struct device_node *base)
981+
int *ret_ovcs_id, const struct device_node *base)
982982
{
983983
void *new_fdt;
984984
void *new_fdt_align;
@@ -1074,7 +1074,7 @@ EXPORT_SYMBOL_GPL(of_overlay_fdt_apply);
10741074
*
10751075
* Returns 1 if @np is @tree or is contained in @tree, else 0
10761076
*/
1077-
static int find_node(struct device_node *tree, struct device_node *np)
1077+
static int find_node(const struct device_node *tree, struct device_node *np)
10781078
{
10791079
if (tree == np)
10801080
return 1;

drivers/of/resolver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ static int node_name_cmp(const struct device_node *dn1,
147147
* of offsets of the phandle reference(s) within the respective property
148148
* value(s). The values at these offsets will be fixed up.
149149
*/
150-
static int adjust_local_phandle_references(struct device_node *local_fixups,
151-
struct device_node *overlay, int phandle_delta)
150+
static int adjust_local_phandle_references(const struct device_node *local_fixups,
151+
const struct device_node *overlay, int phandle_delta)
152152
{
153153
struct device_node *overlay_child;
154154
struct property *prop_fix, *prop;

include/linux/of.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
357357
extern struct device_node *of_cpu_device_node_get(int cpu);
358358
extern int of_cpu_node_to_id(struct device_node *np);
359359
extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
360-
extern struct device_node *of_get_cpu_state_node(struct device_node *cpu_node,
360+
extern struct device_node *of_get_cpu_state_node(const struct device_node *cpu_node,
361361
int index);
362362
extern u64 of_get_cpu_hwid(struct device_node *cpun, unsigned int thread);
363363

@@ -395,7 +395,7 @@ extern int of_phandle_iterator_args(struct of_phandle_iterator *it,
395395
int size);
396396

397397
extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
398-
extern int of_alias_get_id(struct device_node *np, const char *stem);
398+
extern int of_alias_get_id(const struct device_node *np, const char *stem);
399399
extern int of_alias_get_highest_id(const char *stem);
400400

401401
bool of_machine_compatible_match(const char *const *compats);
@@ -446,9 +446,9 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
446446
*/
447447
const char *of_prop_next_string(struct property *prop, const char *cur);
448448

449-
bool of_console_check(struct device_node *dn, char *name, int index);
449+
bool of_console_check(const struct device_node *dn, char *name, int index);
450450

451-
int of_map_id(struct device_node *np, u32 id,
451+
int of_map_id(const struct device_node *np, u32 id,
452452
const char *map_name, const char *map_mask_name,
453453
struct device_node **target, u32 *id_out);
454454

@@ -871,7 +871,7 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
871871
{
872872
}
873873

874-
static inline int of_map_id(struct device_node *np, u32 id,
874+
static inline int of_map_id(const struct device_node *np, u32 id,
875875
const char *map_name, const char *map_mask_name,
876876
struct device_node **target, u32 *id_out)
877877
{
@@ -1734,7 +1734,7 @@ struct of_overlay_notify_data {
17341734
#ifdef CONFIG_OF_OVERLAY
17351735

17361736
int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
1737-
int *ovcs_id, struct device_node *target_base);
1737+
int *ovcs_id, const struct device_node *target_base);
17381738
int of_overlay_remove(int *ovcs_id);
17391739
int of_overlay_remove_all(void);
17401740

@@ -1744,7 +1744,7 @@ int of_overlay_notifier_unregister(struct notifier_block *nb);
17441744
#else
17451745

17461746
static inline int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
1747-
int *ovcs_id, struct device_node *target_base)
1747+
int *ovcs_id, const struct device_node *target_base)
17481748
{
17491749
return -ENOTSUPP;
17501750
}

include/linux/of_address.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ extern struct of_pci_range *of_pci_range_parser_one(
8383
struct of_pci_range *range);
8484
extern int of_pci_address_to_resource(struct device_node *dev, int bar,
8585
struct resource *r);
86-
extern int of_pci_range_to_resource(struct of_pci_range *range,
87-
struct device_node *np,
86+
extern int of_pci_range_to_resource(const struct of_pci_range *range,
87+
const struct device_node *np,
8888
struct resource *res);
8989
extern int of_range_to_resource(struct device_node *np, int index,
9090
struct resource *res);

include/linux/of_irq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ extern int of_irq_to_resource_table(struct device_node *dev,
4848
struct resource *res, int nr_irqs);
4949
extern struct device_node *of_irq_find_parent(struct device_node *child);
5050
extern struct irq_domain *of_msi_get_domain(struct device *dev,
51-
struct device_node *np,
51+
const struct device_node *np,
5252
enum irq_domain_bus_token token);
5353
extern struct irq_domain *of_msi_map_get_device_domain(struct device *dev,
5454
u32 id,
5555
u32 bus_token);
56-
extern void of_msi_configure(struct device *dev, struct device_node *np);
56+
extern void of_msi_configure(struct device *dev, const struct device_node *np);
5757
u32 of_msi_map_id(struct device *dev, struct device_node *msi_np, u32 id_in);
5858
#else
5959
static inline void of_irq_init(const struct of_device_id *matches)

0 commit comments

Comments
 (0)