Re: [PATCH v4 3/7] can: bittiming: move bittiming calculation functions to calc_bittiming.c

From: Vincent MAILHOL
Date: Sat Jun 04 2022 - 08:21:33 EST


On Sat. 4 June 2022 at 20:25, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
> On 03.06.2022 19:28:44, Vincent Mailhol wrote:
> > The canonical way to select or deselect an object during compilation
> > is to use this pattern in the relevant Makefile:
> >
> > bar-$(CONFIG_FOO) := foo.o
> >
> > bittiming.c instead uses some #ifdef CONFIG_CAN_CALC_BITTIMG.
> >
> > Create a new file named calc_bittiming.c with all the functions which
> > are conditionally compiled with CONFIG_CAN_CALC_BITTIMG and modify the
> > Makefile according to above pattern.
> >
> > Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
> > ---
> > drivers/net/can/Kconfig | 4 +
> > drivers/net/can/dev/Makefile | 2 +
> > drivers/net/can/dev/bittiming.c | 197 --------------------------
> > drivers/net/can/dev/calc_bittiming.c | 202 +++++++++++++++++++++++++++
> > 4 files changed, 208 insertions(+), 197 deletions(-)
> > create mode 100644 drivers/net/can/dev/calc_bittiming.c
> >
> > diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
> > index b1e47f6c5586..8f3b97aea638 100644
> > --- a/drivers/net/can/Kconfig
> > +++ b/drivers/net/can/Kconfig
> > @@ -96,6 +96,10 @@ config CAN_CALC_BITTIMING
> > source clock frequencies. Disabling saves some space, but then the
> > bit-timing parameters must be specified directly using the Netlink
> > arguments "tq", "prop_seg", "phase_seg1", "phase_seg2" and "sjw".
> > +
> > + The additional features selected by this option will be added to the
> > + can-dev module.
> > +
> > If unsure, say Y.
> >
> > config CAN_AT91
> > diff --git a/drivers/net/can/dev/Makefile b/drivers/net/can/dev/Makefile
> > index 919f87e36eed..b8a55b1d90cd 100644
> > --- a/drivers/net/can/dev/Makefile
> > +++ b/drivers/net/can/dev/Makefile
> > @@ -9,3 +9,5 @@ can-dev-$(CONFIG_CAN_NETLINK) += dev.o
> > can-dev-$(CONFIG_CAN_NETLINK) += length.o
> > can-dev-$(CONFIG_CAN_NETLINK) += netlink.o
> > can-dev-$(CONFIG_CAN_NETLINK) += rx-offload.o
> > +
> > +can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o
>
> Nitpick:
> Can we keep this list sorted?

My idea was first to group per CONFIG symbol according to the
different levels: CAN_DEV first, then CAN_NETLINK and finally
CAN_CALC_BITTIMING and CAN_RX_OFFLOAD. And then only sort by
alphabetical order within each group.

By sorting the list, do literally mean to sort each line like this:

obj-$(CONFIG_CAN_DEV) += can-dev.o
can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o
can-dev-$(CONFIG_CAN_DEV) += skb.o
can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o
can-dev-$(CONFIG_CAN_NETLINK) += dev.o
can-dev-$(CONFIG_CAN_NETLINK) += length.o
can-dev-$(CONFIG_CAN_NETLINK) += netlink.o
can-dev-$(CONFIG_CAN_RX_OFFLOAD) += rx-offload.o

or do you mean to sort by object name (ignoring the config symbol) like that:

obj-$(CONFIG_CAN_DEV) += can-dev.o
can-dev-$(CONFIG_CAN_NETLINK) += bittiming.o
can-dev-$(CONFIG_CAN_CALC_BITTIMING) += calc_bittiming.o
can-dev-$(CONFIG_CAN_NETLINK) += dev.o
can-dev-$(CONFIG_CAN_NETLINK) += length.o
can-dev-$(CONFIG_CAN_NETLINK) += netlink.o
can-dev-$(CONFIG_CAN_RX_OFFLOAD) += rx-offload.o
can-dev-$(CONFIG_CAN_DEV) += skb.o

?

(I honestly do not care so much how we sort the lines. My logic of
grouping first by CONFIG symbols seems more natural, but I am fine to
go with any other suggestion).