mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add support for geom_flashmap by providing a getattr() for "SPI:device".
This commit is contained in:
parent
e8643b01e6
commit
fb01947189
1 changed files with 18 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue