Am 07.03.2013 17:01, schrieb Matthijs Kooijman: > Hi Alexander, > >>>> static void __init board_generic_setup(struct gpio_led *leds_gpio, size_t >>>> leds_gpio_size, struct gpio_keys_button *gpio_keys, size_t gpio_keys_size, >>>> struct mdio_board_info *mdio0_info, size_t mdio0_info_size) >>>> >>>> board_generic_setup(board_leds_gpio,ARRAY_SIZE(board_leds_gpio),board_gpio_keys,ARRAY_SIZE(board_gpio_keys),board_mdio0_info,ARRAY_SIZE(board_mdio0_info)); >> >> And no const(s)? I'm a bit confused because mdio_board_info seems to >> use const struct but ath79_register_leds_gpio does not. > I guess it's a good idea to use const when possible, but it's probably > not used everywhere since it doesn't break without const. So you would > e.g., use: > > static void __init board_generic_setup(const struct gpio_led > *leds_gpio, size_t leds_gpio_size, etc.. > > to let callers (and the compiler) know that you wont be changing > anything in the struct(s) leds_gpio points to.
I've ended up with using static void __init board_generic_setup(struct gpio_led *const leds_gpio, size_t leds_gpio_size, etc.. as in the original code you would be able to change values in the struct, even it's not done for those. But you definitely don't want to point to another struct with it. > >> The functions use unsigned for the size parameter, not size_t. But I >> think "my" ARRAY_SIZE will return size_t and so this will be the >> better approach? > > size_t and unsigned are similar (and for small arrays, any unsigned type > will usually suffice). However, size_t is a type that is guaranteed to > hold the size of any object, so it seems more appropriate here. > > Gr. > > Matthijs Thanks for your fast response, so I can commit the patch today :-). Alex _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel