You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+157-6Lines changed: 157 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,18 +218,169 @@ stop_bits = 1
218
218
4.**Driver Initialization**: The entire INI context is passed to the driver's `dmdrvi_create()` function
219
219
5.**Device Mapping**: The driver is registered and becomes accessible through the filesystem
220
220
221
-
### Configuration File Naming
221
+
### Driver Name Resolution
222
222
223
-
The filename (without `.ini` extension) can serve as a fallback driver name if `driver_name` is not specified in the file:
223
+
DMDEVFS determines which driver module to load using a priority-based resolution mechanism. The driver name can be specified in three ways, checked in the following order:
224
+
225
+
#### 1. From INI File Content (Highest Priority)
226
+
227
+
The `driver_name` field in the `[main]` section explicitly specifies which driver to load:
224
228
225
229
```ini
226
-
# File: my_custom_driver.ini
230
+
# File: /etc/dmdevfs/storage.ini
227
231
[main]
228
-
# driver_name is optional if filename matches the module name
229
-
parameter1 = value1
232
+
driver_name = dmspiflash
233
+
# ... other parameters
234
+
```
235
+
236
+
This loads the `dmspiflash` driver module, regardless of the filename or directory.
237
+
238
+
#### 2. From Configuration Filename (Fallback)
239
+
240
+
If `driver_name` is not specified in the INI file, the basename of the configuration file (without `.ini` extension) is used:
241
+
242
+
```ini
243
+
# File: /etc/dmdevfs/dmi2ceeprom.ini
244
+
[main]
245
+
# No driver_name specified
246
+
i2c_bus = 0
247
+
device_address = 0x50
248
+
```
249
+
250
+
This loads the `dmi2ceeprom` driver module based on the filename.
251
+
252
+
#### 3. From Directory Name (Hierarchical Configuration)
253
+
254
+
When configuration files are organized in subdirectories, the directory name can be passed to nested configurations:
255
+
256
+
```
257
+
/etc/dmdevfs/
258
+
└── dmspiflash/
259
+
├── device0.ini # Uses "dmspiflash" from directory name
260
+
└── device1.ini # Uses "dmspiflash" from directory name
261
+
```
262
+
263
+
Each `.ini` file in the `dmspiflash/` directory will use `dmspiflash` as the default driver name unless overridden by the `driver_name` field in the file itself.
264
+
265
+
**Example of Combined Usage:**
266
+
267
+
```
268
+
/etc/dmdevfs/
269
+
├── flash.ini # Uses filename: "flash" driver
270
+
├── spi/
271
+
│ ├── device0.ini # Uses directory: "spi" driver
272
+
│ └── device1.ini # Uses directory: "spi" driver
273
+
└── custom.ini # Contains driver_name=dmi2ceeprom in file
274
+
```
275
+
276
+
### Device Numbering and Path Generation
277
+
278
+
When a driver is initialized through its `dmdrvi_create()` function, it returns a device number structure (`dev_num`) that controls how the driver appears in the filesystem. This mechanism allows multiple instances of the same driver with different configurations.
279
+
280
+
#### Device Number Structure
281
+
282
+
The device number consists of:
283
+
-**major**: Primary device identifier (typically for device type or bus)
284
+
-**minor**: Secondary device identifier (typically for device instance)
285
+
-**flags**: Indicates which numbers are provided (`DMDRVI_NUM_MAJOR`, `DMDRVI_NUM_MINOR`)
286
+
287
+
#### Path Generation Rules
288
+
289
+
The resulting filesystem path depends on which device numbers the driver provides:
When only a minor number is provided (major not set), the path uses `x` as a placeholder. This is useful when the driver doesn't use a major/minor hierarchy but still wants to enumerate devices:
367
+
368
+
```
369
+
/mnt/dmspiflashx/0
370
+
/mnt/dmspiflashx/1
371
+
/mnt/dmspiflashx/2
372
+
```
373
+
374
+
This convention keeps paths consistent and prevents naming collisions.
375
+
376
+
#### Driver Implementation Notes
377
+
378
+
The device numbers are determined by the driver itself based on the configuration parameters. For example:
379
+
- An SPI flash driver might use `spi_bus` as the major number and `chip_select` as the minor number
380
+
- An I2C driver might use only the `device_address` as the minor number
381
+
- A generic driver might not use device numbers at all
382
+
383
+
Consult your specific driver's documentation to understand how it uses configuration parameters to set device numbers.
0 commit comments