Skip to contentSkip to conversation

i2c: Add generic support passing secondary devices addresses

PATCH John de la Garza 1 participant 1 message Oct 22, 2014 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

instead of:

+ np = client->dev.of_node;
+
+ if (np) {
+ i = of_property_match_string(np, "reg-names", name);
+ if (i >= 0)
+ of_property_read_u32_index(np, "reg", i, &addr);
+ else if (default_addr != 0)
+ addr = default_addr;
+ else
+ addr = NULL;
+ } else {
+ addr = default_addr;
+ }

how about making the middle part like this to remove the repeated code

	np = client->dev.of_node;
	addr = default_addr;

	if (np) {
		i = of_property_match_string(np, "reg-names", name);
		if (i >= 0)
			of_property_read_u32_index(np, "reg", i, &addr);
		else if (default_addr == 0)
			addr = NULL;
	}