Hi Geert > > I think this still can be improved upon... > > > > ideally you just need log2(32) defines. > (snip) > > #define PORT_GP_CFG_1(bank, fn, sfx, cfg) _PORT_GP_CFG_1(bank, 0, fn, sfx, cfg) > > #define PORT_GP_CFG_2(bank, fn, sfx, cfg) _PORT_GP_CFG_2(bank, 0, fn, sfx, cfg) > > #define PORT_GP_CFG_4(bank, pin, fn, sfx, cfg) _PORT_GP_CFG_4(bank, > > 0, fn, sfx, cfg) > > ... > > #define PORT_GP_CFG_32(bank, fn, sfx, cfg) _PORT_GP_CFG_32(bank, 0, > > fn, sfx, cfg) > > > > and > > > > #define PORT_GP_1(bank, fn, sfx) _PORT_GP_CFG_1(bank, 0, fn, sfx, 0) > > #define PORT_GP_2(bank, fn, sfx) _PORT_GP_CFG_2(bank, 0, fn, sfx, 0) > > #define PORT_GP_4(bank, fn, sfx) _PORT_GP_CFG_4(bank, 0, fn, sfx, 0) > > ... > > #define PORT_GP_32(bank, fn, sfx) _PORT_GP_CFG_32(bank, 0, fn, sfx, 0) > > > > and for the special (non-power-of-two) numbers e.g. > > > > #define PORT_GP_12(bank, fn, sfx) \ > > _PORT_GP_CFG_8(bank, 0, fn, sfx, 0) _PORT_GP_CFG_4(bank, 8, fn, sfx, 0) > > Ahh indeed, make sense ! > I will use this idea. Thanks ! Hmm... I'm tring this, but... Can I confirm ? Your idea was this #define _PORT_GP_CFG_2(bank, pin, fn, sfx, cfg) \ _PORT_GP_CFG_1(bank, 0, fn, sfx, cfg) _PORT_GP_CFG_1(bank, 1, fn, sfx, cfg) But I think you want this ? #define _PORT_GP_CFG_2(bank, pin, fn, sfx, cfg) \ - _PORT_GP_CFG_1(bank, 0, fn, sfx, cfg) _PORT_GP_CFG_1(bank, 1, fn, sfx, cfg) + _PORT_GP_CFG_1(bank, pin, fn, sfx, cfg) _PORT_GP_CFG_1(bank, pin + 1, fn, sfx, cfg) I noticed it seems difficult, because it is based on #define PORT_GP_CFG_1(bank, pin, fn, sfx, cfg) fn(bank, pin, GP_##bank##_##pin, sfx, cfg) ~~~ ~~~ we can't use (pin + x) style. It seems we need all 0 - 32 definition anyway... -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html