Skip to content

Improve gen_partitions script#70

Merged
lumag merged 3 commits intoqualcomm-linux:mainfrom
ndechesne:code-improvements
Feb 13, 2026
Merged

Improve gen_partitions script#70
lumag merged 3 commits intoqualcomm-linux:mainfrom
ndechesne:code-improvements

Conversation

@ndechesne
Copy link
Contributor

I am always bothered with the implementation of gen_partitions.py each time I need to have a look at it.

This PR brings some (hopefully) nice readability improvements.

  • parse the config file earlier in the process, and convert its content into proper data structure, instead of mixing the parsing of text file in the main generation loop
  • that allows me to remove the hardcoded loop that did for lun=0 -> 5
  • remove "del part_entry["physical_partition"]" line which was an artifact of not having a proper data structure, and i always fail to remember why we had it.

I've tested that all existing conf file in the tree still generate the exact same output

partition_entries_dict was set as a dict, but it is really just a
list. the 'key' is set to an index which is never used. Let's convert
to a proper list to make the code more readable.

There is no functional change.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
The disk and partitions data is first read from the partition conf
file into an intermediate list, and it is parsed into actual/usable
data later, inside generate_partition_xml() which is slightly
convoluted. Instead, let's parse all input files in a first step
before we start the actual generation of partition xml file.

In this commit, move the parsing of disk_options first. Use that as an
opportunity to remove the global/static disk_params, and make a copy
from disk_options().

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
The parsing of the partition entries is embedded deep into
generate_multi_lun_xml() which makes the code difficult to
parse/understand. Instead let's first parse the partition conf file
and create a proper data structure for it. Then adjust the
generate_multi_lun_xml() to use the new data struct.

The config file contains the list of all partitions that are needed,
on all the physical partitions (aks LUN in UFS). The data structure to
store all information is a dict where the key is the phys_part, and
the value is the list of all partitions on this specific physical
part.

The new implementation is much more flexible, in particular, we no
longer hardcode the max phys_part to 5, and make no assumption on how
many phys_part there (it's 1 or more).

There is no functional change and the generated XML files are the same.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
@lumag lumag merged commit e69b98a into qualcomm-linux:main Feb 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants