Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Feb 2019 17:30:01 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344526 - head/sys/dev/flash
Message-ID:  <201902251730.x1PHU1a2087318@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Mon Feb 25 17:30:01 2019
New Revision: 344526
URL: https://svnweb.freebsd.org/changeset/base/344526

Log:
  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).

Modified:
  head/sys/dev/flash/at45d.c
  head/sys/dev/flash/mx25l.c

Modified: head/sys/dev/flash/at45d.c
==============================================================================
--- head/sys/dev/flash/at45d.c	Mon Feb 25 16:40:10 2019	(r344525)
+++ head/sys/dev/flash/at45d.c	Mon Feb 25 17:30:01 2019	(r344526)
@@ -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;

Modified: head/sys/dev/flash/mx25l.c
==============================================================================
--- head/sys/dev/flash/mx25l.c	Mon Feb 25 16:40:10 2019	(r344525)
+++ head/sys/dev/flash/mx25l.c	Mon Feb 25 17:30:01 2019	(r344526)
@@ -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");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902251730.x1PHU1a2087318>