Date: Tue, 26 Feb 2019 20:50:50 +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: r344606 - head/sys/dev/flash Message-ID: <201902262050.x1QKooKQ055878@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Tue Feb 26 20:50:49 2019 New Revision: 344606 URL: https://svnweb.freebsd.org/changeset/base/344606 Log: Add support for geom_flashmap by providing a getattr() for "SPI:device". Modified: head/sys/dev/flash/at45d.c Modified: head/sys/dev/flash/at45d.c ============================================================================== --- head/sys/dev/flash/at45d.c Tue Feb 26 19:55:03 2019 (r344605) +++ head/sys/dev/flash/at45d.c Tue Feb 26 20:50:49 2019 (r344606) @@ -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; @@ -365,6 +367,22 @@ static int 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902262050.x1QKooKQ055878>