Skip to content

Transfer device numbering control from filesystem to driver#5

Merged
JohnAmadis merged 3 commits intomainfrom
copilot/update-driver-namespace-management
Dec 19, 2025
Merged

Transfer device numbering control from filesystem to driver#5
JohnAmadis merged 3 commits intomainfrom
copilot/update-driver-namespace-management

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 19, 2025

Drivers now manage their own device number namespace instead of receiving numbers from the filesystem layer. Each driver controls its numbering scheme and device file naming convention.

API Changes

dmdrvi_dev_num_t structure:

  • Added flags field indicating numbering scheme
  • Changed from input to output parameter in dmdrvi_create()

Flag constants:

#define DMDRVI_NUM_NONE   0x00  // No numbering: /dev/dmclk
#define DMDRVI_NUM_MAJOR  0x01  // Major only: /dev/dmuart0
#define DMDRVI_NUM_MINOR  0x02  // Combined with MAJOR: /dev/dmspi0/0

Function signature:

// Before: filesystem provides numbers
dmdrvi_context_t dmdrvi_create(dmini_context_t config, const dmdrvi_dev_num_t* dev_num);

// After: driver assigns numbers
dmdrvi_context_t dmdrvi_create(dmini_context_t config, dmdrvi_dev_num_t* dev_num);

Device Naming

Driver determines device file structure via flags:

  • No numbering (DMDRVI_NUM_NONE): Single file with driver name → /dev/dmclk
  • Major only (DMDRVI_NUM_MAJOR): Files with major suffix → /dev/dmuart0, /dev/dmuart1
  • Major + Minor (DMDRVI_NUM_MAJOR | DMDRVI_NUM_MINOR): Directory/file hierarchy → /dev/dmspi0/0, /dev/dmspi0/1

Usage Pattern

// Driver assigns numbering on create
dmdrvi_dev_num_t dev_num;
dmdrvi_context_t ctx = dmdrvi_create(config, &dev_num);

// Check assigned scheme
if (dev_num.flags & DMDRVI_NUM_MINOR) {
    // Device path: /dev/driver{major}/{minor}
} else if (dev_num.flags & DMDRVI_NUM_MAJOR) {
    // Device path: /dev/driver{major}
} else {
    // Device path: /dev/driver
}

Each driver maintains independent namespace - major/minor numbers don't conflict across different driver types.

Original prompt

This section details on the original issue you should resolve

<issue_title>Major i Minor będzie teraz pod kontrolą drivera</issue_title>
<issue_description>Z założenia to system plików używający dany driver miał zarządzać numeracją minor I major - zmieniamy jednak koncepcje i teraz to sterownik będzie tym zarządzał, a każdy z nich po prostu dostanie osobny "namespace". Czyli w create parametr będzie po prostu output - i sterownik sobie wybierze jaki numer dla danej konfiguracji chce stworzyć. Ponadto może tam być jeszcze pole flag, w którym można zaznaczyc czy minor I major są używane. jeśli sterownik nie używa wsparcia dla numeracji konfiguracji - wtedy po prostu jego plik będzie trzymał nazwę sterownika bez żadnego suffixu.

Czyli np:
/dev/dmclk

Inny przykład (z użyciem numerów):

/dev/dmuart0

Lub
/dev/dmspi0/0
/dev/dmspi0/1

Jeśli urządzenie wspiera minor, to oznacza że tworzymy dla niego katalog i pliki dla każdej konfiguracji.

Trzeba to wszystko opisać w readme</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 19, 2025 17:02
- Change dev_num parameter in dmdrvi_create from input to output
- Add flags field to dmdrvi_dev_num_t structure
- Add DMDRVI_NUM_* flags for numbering schemes (NONE, MAJOR, MINOR)
- Update all documentation with new paradigm and device naming conventions
- Document examples: /dev/dmclk, /dev/dmuart0, /dev/dmspi0/0

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
- Clarify that dev_num must not be NULL in dmdrvi_create()
- Use bitwise flag checking (& operator) for more robust flag detection
- Clarify that DMDRVI_NUM_MINOR must be combined with MAJOR
- Reorder flag checks to test MINOR before MAJOR (since MINOR implies MAJOR)
- Add explanatory comments to flag checking examples

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Update driver control for major and minor numbering Transfer device numbering control from filesystem to driver Dec 19, 2025
Copilot AI requested a review from JohnAmadis December 19, 2025 17:06
@JohnAmadis JohnAmadis marked this pull request as ready for review December 19, 2025 17:18
@JohnAmadis JohnAmadis merged commit a8a2891 into main Dec 19, 2025
1 check 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.

Major i Minor będzie teraz pod kontrolą drivera

2 participants