diff options
| author | Ian Lepore <ian@FreeBSD.org> | 2019-02-26 20:50:49 +0000 |
|---|---|---|
| committer | Ian Lepore <ian@FreeBSD.org> | 2019-02-26 20:50:49 +0000 |
| commit | fb01947189a2fb13c8e4b3ff14d0ebed4897cd3b (patch) | |
| tree | f77fafe4d6166dfe7735a8c9f2f7c80f3e5c1c98 /sys/dev/flash | |
| parent | e8643b01e6312a56d1e44a760fb4e95f0b10b54c (diff) | |
Notes
Diffstat (limited to 'sys/dev/flash')
| -rw-r--r-- | sys/dev/flash/at45d.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/dev/flash/at45d.c b/sys/dev/flash/at45d.c index 8a948dc4e189c..8acf2b95f95e7 100644 --- a/sys/dev/flash/at45d.c +++ b/sys/dev/flash/at45d.c @@ -119,6 +119,7 @@ static device_probe_t at45d_probe; /* disk routines */ static int at45d_close(struct disk *dp); static int at45d_open(struct disk *dp); +static int at45d_getattr(struct bio *bp); static void at45d_strategy(struct bio *bp); static void at45d_task(void *arg); @@ -338,6 +339,7 @@ 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_getattr = at45d_getattr; sc->disk->d_name = "flash/at45d"; sc->disk->d_drv1 = sc; sc->disk->d_maxsize = DFLTPHYS; @@ -368,6 +370,22 @@ at45d_close(struct disk *dp) return (0); } +static int +at45d_getattr(struct bio *bp) +{ + struct at45d_softc *sc; + + if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL) + return (ENXIO); + if (strcmp(bp->bio_attribute, "SPI::device") != 0) + return (-1); + sc = bp->bio_disk->d_drv1; + if (bp->bio_length != sizeof(sc->dev)) + return (EFAULT); + bcopy(&sc->dev, bp->bio_data, sizeof(sc->dev)); + return (0); +} + static void at45d_strategy(struct bio *bp) { |
