more janitor work: simplifying Kconfig files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  if people are still looking for straightforward janitorial work,
here's something i worked on many years ago and for which there is
*always* some cleanup work. consider this Kconfig file:

https://github.com/torvalds/linux/blob/master/drivers/ata/pata_parport/Kconfig

notice the relentless duplication in each of those config stanzas, as
many of them contain the dependency directive:

  depends on PATA_PARPORT

in cases where there is this much duplication of the same Kconfig
dependency, you can frequently simplify this by wrapping all of those
stanzas in the common test:

  if PATA_PARPORT

  ... the same stanzas with "depends on PATA_PARPORT" removed

  endif

if there are only a couple duplicate dependencies, it's probably not
worth simplifying. on the other hand, there could be *numerous*
duplicate dependencies, and if they're not consecutive, you might have
to move them around to group them -- in cases like that, moving them
around might actually make the Kconfig easier to read since you've
collected some of the entries by commonality. (you would have to run
that sort of change by the subsystem maintainer, who might be grateful
that you're willing to clean up his or her Kconfig).

  note there's no automated way to identify this sort of thing, it
takes manual poking around as you're examining the kernel source to
additionally check Kconfig files to see if there's something worth
cleaning up. but there's a higher-level cleanup that is sometimes
possible.

  note that in the Kconfig example example, every single stanza in
that Kconfig file depends on PATA_PARPORT. in cases like that, it
makes more sense to put the conditional check in the higher-level
Kconfig file to not source that lower-level file *at all*. notice:

https://github.com/torvalds/linux/blob/master/drivers/acpi/Kconfig#L546

that test will determine if there is even any point in sourcing that
lower-level Kconfig file -- that appears to be the kind of
simplification that can be done for the PATA_PARPORT example.

  so there is clearly some cleanup that can be done along these lines.

  thoughts?

rday





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux