diff options
| author | Adrian Chadd <adrian@FreeBSD.org> | 2016-01-22 03:15:53 +0000 |
|---|---|---|
| committer | Adrian Chadd <adrian@FreeBSD.org> | 2016-01-22 03:15:53 +0000 |
| commit | 1b4680383338679104b565789768b1251e0f7c4f (patch) | |
| tree | 4bbc3358a645e2362e680d5ec8a09239050e7885 /sys/dev/flash | |
| parent | db891e2149ca3fd06924447609926d6815174da3 (diff) | |
Notes
Diffstat (limited to 'sys/dev/flash')
| -rw-r--r-- | sys/dev/flash/mx25l.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/dev/flash/mx25l.c b/sys/dev/flash/mx25l.c index d9aaa1c249357..c4dad4b287755 100644 --- a/sys/dev/flash/mx25l.c +++ b/sys/dev/flash/mx25l.c @@ -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) { |
