svn commit: r294544 - head/sys/dev/flash
Adrian Chadd
adrian at FreeBSD.org
Fri Jan 22 03:15:54 UTC 2016
Author: adrian
Date: Fri Jan 22 03:15:53 2016
New Revision: 294544
URL: https://svnweb.freebsd.org/changeset/base/294544
Log:
[flash] Teach mx25l SPI flash driver to interact with fdt_slicer and geom_flashmap
This teaches the mx25l driver (sys/dev/flash/mx25l.c) to interact with
sys/dev/fdt/fdt_slicer.c and sys/geom/geom_flashmap.c.
This allows systems with SPI flash to benefit from the possibility to define
flash 'slices' via FDT, just the same way that it's currently possible for
CFI and NAND flashes.
Tested:
* Carambola 2, AR9331 + SPI NOR flash
PR: kern/206227
Submitted by: Stanislav Galabov <sgalabov at gmail.com>
Modified:
head/sys/dev/flash/mx25l.c
Modified: head/sys/dev/flash/mx25l.c
==============================================================================
--- head/sys/dev/flash/mx25l.c Fri Jan 22 03:02:38 2016 (r294543)
+++ head/sys/dev/flash/mx25l.c Fri Jan 22 03:15:53 2016 (r294544)
@@ -93,6 +93,7 @@ static int mx25l_open(struct disk *dp);
static int mx25l_close(struct disk *dp);
static int mx25l_ioctl(struct disk *, u_long, void *, int, struct thread *);
static void mx25l_strategy(struct bio *bp);
+static int mx25l_getattr(struct bio *bp);
static void mx25l_task(void *arg);
struct mx25l_flash_ident flash_devices[] = {
@@ -383,6 +384,7 @@ mx25l_attach(device_t dev)
sc->sc_disk->d_open = mx25l_open;
sc->sc_disk->d_close = mx25l_close;
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_drv1 = sc;
@@ -448,6 +450,27 @@ mx25l_strategy(struct bio *bp)
M25PXX_UNLOCK(sc);
}
+static int
+mx25l_getattr(struct bio *bp)
+{
+ struct mx25l_softc *sc;
+ device_t dev;
+
+ if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
+ return (ENXIO);
+
+ sc = bp->bio_disk->d_drv1;
+ dev = sc->sc_dev;
+
+ if (strcmp(bp->bio_attribute, "SPI::device") == 0) {
+ if (bp->bio_length != sizeof(dev))
+ return (EFAULT);
+ bcopy(&dev, bp->bio_data, sizeof(dev));
+ } else
+ return (-1);
+ return (0);
+}
+
static void
mx25l_task(void *arg)
{
More information about the svn-src-head
mailing list