mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Resolve a name conflict when both SpiFlash and DataFlash devices are present.
Both SpiFlash (mx25l) and DataFlash (at45d) drivers create a disk device with a name of /dev/flash/spiN where N is the driver's unit number. If both types of devices are present in the same system, this creates a fatal conflict that prevents attachment of whichever device attaches second (because mx25l0 and at45d0 both try to create a spi0). This gives each type of device a unique name (mx25lN or at45dN respectively) and also adds an alias of spiN for compatibility. When both device types appear in the same system, only the first to attach gets the spiN alias. When the second device attaches there is a non-fatal warning that the alias can't be created, but both devices are still accessible via their primary names (and there is no need for the spiN name to work for backwards compatibility on such a system, because it has never been possible to use the spiN names when both devices exist).
This commit is contained in:
parent
56e07c3e97
commit
d3248c4170
2 changed files with 4 additions and 2 deletions
|
|
@ -338,13 +338,14 @@ at45d_delayed_attach(void *xsc)
|
|||
sc->disk->d_open = at45d_open;
|
||||
sc->disk->d_close = at45d_close;
|
||||
sc->disk->d_strategy = at45d_strategy;
|
||||
sc->disk->d_name = "flash/spi";
|
||||
sc->disk->d_name = "flash/at45d";
|
||||
sc->disk->d_drv1 = sc;
|
||||
sc->disk->d_maxsize = DFLTPHYS;
|
||||
sc->disk->d_sectorsize = pagesize;
|
||||
sc->disk->d_mediasize = pagesize * ident->pagecount;
|
||||
sc->disk->d_unit = device_get_unit(sc->dev);
|
||||
disk_create(sc->disk, DISK_VERSION);
|
||||
disk_add_alias(sc->sc_disk, "flash/spi");
|
||||
bioq_init(&sc->bio_queue);
|
||||
kproc_create(&at45d_task, sc, &sc->p, 0, 0, "task: at45d flash");
|
||||
sc->taskstate = TSTATE_RUNNING;
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ mx25l_attach(device_t dev)
|
|||
sc->sc_disk->d_strategy = mx25l_strategy;
|
||||
sc->sc_disk->d_getattr = mx25l_getattr;
|
||||
sc->sc_disk->d_ioctl = mx25l_ioctl;
|
||||
sc->sc_disk->d_name = "flash/spi";
|
||||
sc->sc_disk->d_name = "flash/mx25l";
|
||||
sc->sc_disk->d_drv1 = sc;
|
||||
sc->sc_disk->d_maxsize = DFLTPHYS;
|
||||
sc->sc_disk->d_sectorsize = MX25L_SECTORSIZE;
|
||||
|
|
@ -522,6 +522,7 @@ mx25l_attach(device_t dev)
|
|||
sizeof(sc->sc_disk->d_descr));
|
||||
|
||||
disk_create(sc->sc_disk, DISK_VERSION);
|
||||
disk_add_alias(sc->sc_disk, "flash/spi");
|
||||
bioq_init(&sc->sc_bio_queue);
|
||||
|
||||
kproc_create(&mx25l_task, sc, &sc->sc_p, 0, 0, "task: mx25l flash");
|
||||
|
|
|
|||
Loading…
Reference in a new issue