PERFORCE change 222836 for review
Brooks Davis
brooks at FreeBSD.org
Wed Mar 13 18:41:06 UTC 2013
http://p4web.freebsd.org/@@222836?ac=10
Change 222836 by brooks at brooks_zenith on 2013/03/13 18:40:14
Add support for partitioning CFI disks from FDT using geom_flashmap.
In geom_flashmap, don't partition anything other that disks.
With out this, the layering violation required to retrieve FDT
entries caused not only the disk, but all non-flashmap
partitions of the disk to have *s.<partition> entries created.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_disk.c#4 edit
.. //depot/projects/ctsrd/beribsd/src/sys/geom/geom_flashmap.c#3 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_disk.c#4 (text+ko) ====
@@ -44,6 +44,7 @@
#include <dev/cfi/cfi_var.h>
+#include <geom/geom.h>
#include <geom/geom_disk.h>
struct cfi_disk_softc {
@@ -64,9 +65,11 @@
static int cfi_disk_open(struct disk *);
static int cfi_disk_close(struct disk *);
static void cfi_io_proc(void *, int);
+static int cfi_disk_getattr(struct bio *);
static void cfi_disk_strategy(struct bio *);
static int cfi_disk_ioctl(struct disk *, u_long, void *, int, struct thread *);
+
static int
cfi_disk_probe(device_t dev)
{
@@ -95,6 +98,7 @@
sc->disk->d_strategy = cfi_disk_strategy;
sc->disk->d_ioctl = cfi_disk_ioctl;
sc->disk->d_dump = NULL; /* NB: no dumps */
+ sc->disk->d_getattr = cfi_disk_getattr;
sc->disk->d_sectorsize = CFI_DISK_SECSIZE;
sc->disk->d_mediasize = sc->parent->sc_size;
sc->disk->d_maxsize = CFI_DISK_MAXIOSIZE;
@@ -275,6 +279,31 @@
}
}
+static int
+cfi_disk_getattr(struct bio *bp)
+{
+ struct cfi_disk_softc *dsc;
+ struct cfi_softc *sc;
+ device_t dev;
+
+ if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
+ return (ENXIO);
+
+ dsc = bp->bio_disk->d_drv1;
+ sc = dsc->parent;
+ dev = sc->sc_dev;
+
+ do {
+ if (g_handleattr(bp, "CFI::device", &dev, sizeof(device_t)))
+ break;
+
+ return (ERESTART);
+ } while(0);
+
+ return (EJUSTRETURN);
+}
+
+
static void
cfi_disk_strategy(struct bio *bp)
{
==== //depot/projects/ctsrd/beribsd/src/sys/geom/geom_flashmap.c#3 (text+ko) ====
@@ -174,7 +174,7 @@
g_topology_assert();
if (flags == G_TF_NORMAL &&
- !strcmp(pp->geom->class->name, FLASHMAP_CLASS_NAME))
+ strcmp(pp->geom->class->name, "DISK") != 0)
return (NULL);
gp = g_slice_new(mp, FLASH_SLICES_MAX_NUM, pp, &cp, NULL, 0,
@@ -186,8 +186,11 @@
do {
size = sizeof(device_t);
- if (g_io_getattr("NAND::device", cp, &size, &dev))
- break;
+ if (g_io_getattr("NAND::device", cp, &size, &dev)) {
+ size = sizeof(device_t);
+ if (g_io_getattr("CFI::device", cp, &size, &dev))
+ break;
+ }
nslices = g_flashmap_load(dev, &head);
if (nslices == 0)
More information about the p4-projects
mailing list