ref: eacf9fbbee70d9effcc5b049f3c9e437979f50d5
parent: 5692962407eb0bfdae8e91255e3f53c3fb6a7468
author: cinap_lenrek <[email protected]>
date: Sat Oct 14 15:13:42 EDT 2023
devsd, sd*: use seprint() style start/end pointer for rctl() function This makes it consistent also with rtopctl() and simpliefies the code.
--- a/sys/src/9/pc/mkfile
+++ b/sys/src/9/pc/mkfile
@@ -118,7 +118,7 @@
squidboy.$O: mp.h
$SDEV: ../port/sd.h
sd53c8xx.$O: sd53c8xx.i
-sdiahci.$O: ahci.h
+sdiahci.$O: ahci.h ../port/led.h
devaoe.$O sdaoe.$O: ../port/aoe.h
main.$O: rebootcode.i
wavelan.$O: wavelan.c ../pc/wavelan.c ../pc/wavelan.h
--- a/sys/src/9/pc/sdiahci.c
+++ b/sys/src/9/pc/sdiahci.c
@@ -2285,21 +2285,19 @@
return p;
}
-static int
-iarctl(SDunit *u, char *p, int l)
+static char*
+iarctl(SDunit *u, char *p, char *e)
{
- char buf[32], *e, *op;
+ char buf[32];
Aport *o;
Ctlr *c;
Drive *d;
if((c = u->dev->ctlr) == nil)
- return 0;
+ return p;
d = c->drive[u->subno];
o = d->port;
- e = p+l;
- op = p;
if(d->state == Dready){
p = seprint(p, e, "model\t%s\n", d->model);
p = seprint(p, e, "serial\t%s\n", d->serial);
@@ -2323,7 +2321,7 @@
p = seprint(p, e, "alignment %d %d\n",
d->secsize<<d->portm.physshift, d->portm.physalign);
p = seprint(p, e, "missirq\t%ud\n", c->missirq);
- return p - op;
+ return p;
}
static void
--- a/sys/src/9/pc/sdide.c
+++ b/sys/src/9/pc/sdide.c
@@ -2322,19 +2322,16 @@
return ret;
}
-static int
-atarctl(SDunit* unit, char* p, int l)
+static char*
+atarctl(SDunit* unit, char *p, char *e)
{
Ctlr *ctlr;
Drive *drive;
- char *e, *op;
if((ctlr = unit->dev->ctlr) == nil || ctlr->drive[unit->subno] == nil)
- return 0;
+ return p;
drive = ctlr->drive[unit->subno];
- e = p+l;
- op = p;
qlock(drive);
p = seprint(p, e, "config %4.4uX capabilities %4.4uX", drive->info[Iconfig], drive->info[Icapabilities]);
if(drive->dma)
@@ -2364,7 +2361,7 @@
p = seprint(p, e, "nildrive %ud\n", ctlr->nildrive);
qunlock(drive);
- return p - op;
+ return p;
}
static int
--- a/sys/src/9/pc/sdodin.c
+++ b/sys/src/9/pc/sdodin.c
@@ -2741,18 +2741,15 @@
return p;
}
-static int
-msrctl(SDunit *u, char *p, int l)
+static char*
+msrctl(SDunit *u, char *p, char *e)
{
- char *e, *op;
Ctlr *c;
Drive *d;
if((c = u->dev->ctlr) == nil)
- return 0;
+ return p;
d = c->drive + u->subno;
- e = p + l;
- op = p;
p = seprint(p, e, "state\t%s\n", dstate(d->state));
p = seprint(p, e, "type\t%s", type[d->type]);
if(d->type == Sata)
@@ -2767,7 +2764,7 @@
}
p = rctldebug(p, e, c, d);
p = seprint(p, e, "geometry %llud %lud\n", d->sectors, u->secsize);
- return p - op;
+ return p;
}
static void
--- a/sys/src/9/port/devsd.c
+++ b/sys/src/9/port/devsd.c
@@ -1272,7 +1272,7 @@
* and the garscadden trains.
*/
if(unit->dev->ifc->rctl != nil)
- p += (*unit->dev->ifc->rctl)(unit, p, e - p);
+ p = (*unit->dev->ifc->rctl)(unit, p, e);
if(unit->sectors == 0)
sdinitpart(unit);
if(unit->sectors){
--- a/sys/src/9/port/portmkfile
+++ b/sys/src/9/port/portmkfile
@@ -73,12 +73,16 @@
proc.$O proc.acid: errstr.h
devroot.$O: errstr.h
devaudio.$O: ../port/audioif.h
-devaoe.$O: ../port/sd.h /$objtype/include/ureg.h
+devaoe.$O: ../port/sd.h ../port/netif.h ../port/aoe.h /sys/include/fis.h
devfs.$O: ../port/sd.h /$objtype/include/ureg.h
devsd.$O: ../port/sd.h /$objtype/include/ureg.h
sdscsi.$O: ../port/sd.h /$objtype/include/ureg.h
sdaoe.$O: ../port/sd.h /$objtype/include/ureg.h
-sdmmc.$O: ../port/sd.h /$objtype/include/ureg.h
+sdloop.$O: ../port/sd.h ../port/netif.h
+sdmmc.$O: ../port/sd.h
+sdnvme.$O: ../port/sd.h ../port/pci.h /$objtype/include/ureg.h
+sdram.$O: ../port/sd.h
+sdvirtio10.$O: ../port/sd.h ../port/pci.h /$objtype/include/ureg.h
trap.$O: /$objtype/include/ureg.h
proc.$O: /$objtype/include/ureg.h
devproc.$O: /$objtype/include/ureg.h
--- a/sys/src/9/port/sd.h
+++ b/sys/src/9/port/sd.h
@@ -88,7 +88,7 @@
int (*verify)(SDunit*);
int (*online)(SDunit*);
int (*rio)(SDreq*);
- int (*rctl)(SDunit*, char*, int);
+ char* (*rctl)(SDunit*, char*, char*);
int (*wctl)(SDunit*, Cmdbuf*);
long (*bio)(SDunit*, int, int, void*, long, uvlong);
--- a/sys/src/9/port/sdaoe.c
+++ b/sys/src/9/port/sdaoe.c
@@ -453,16 +453,13 @@
return r->status = SDok;
}
-static int
-aoerctl(SDunit *u, char *p, int l)
+static char*
+aoerctl(SDunit *u, char *p, char *e)
{
Ctlr *c;
- char *e, *op;
if((c = u->dev->ctlr) == nil)
- return 0;
- e = p+l;
- op = p;
+ return p;
p = seprint(p, e, "model\t%s\n", c->model);
p = seprint(p, e, "serial\t%s\n", c->serial);
@@ -470,7 +467,7 @@
p = seprint(p, e, "flag ");
p = pflag(p, e, c);
p = seprint(p, e, "geometry %llud %d\n", c->sectors, Aoesectsz);
- return p-op;
+ return p;
}
static int
--- a/sys/src/9/port/sdloop.c
+++ b/sys/src/9/port/sdloop.c
@@ -321,20 +321,16 @@
return r->status = SDok;
}
-static int
-looprctl(SDunit *u, char *p, int l)
+static char*
+looprctl(SDunit *u, char *p, char *e)
{
Ctlr *c;
- char *e, *op;
if((c = u->dev->ctlr) == nil)
- return 0;
- e = p+l;
- op = p;
-
+ return p;
p = seprint(p, e, "path\t%s\n", c->path);
p = seprint(p, e, "geometry %llud %d\n", c->sectors, c->sectsize);
- return p - op;
+ return p;
}
static int
--- a/sys/src/9/port/sdmmc.c
+++ b/sys/src/9/port/sdmmc.c
@@ -597,17 +597,16 @@
return 1;
}
-static int
-mmcrctl(SDunit *unit, char *p, int l)
+static char*
+mmcrctl(SDunit *unit, char *p, char *e)
{
Card *card = unit->dev->ctlr;
- char *s = p, *e = s + l;
int i;
if(card->sectors[0] == 0)
mmconline(unit);
if(unit->sectors == 0)
- return 0;
+ return p;
p = seprint(p, e, "version %s %d.%2.2d\n", card->ismmc? "MMC": "SD",
card->specver/100, card->specver%100);
@@ -629,7 +628,7 @@
p = seprint(p, e, "\ngeometry %llud %ld\n",
unit->sectors, unit->secsize);
- return p - s;
+ return p;
}
static long
--- a/sys/src/9/port/sdnvme.c
+++ b/sys/src/9/port/sdnvme.c
@@ -433,24 +433,20 @@
return 2;
}
-static int
-nvmerctl(SDunit *u, char *p, int l)
+static char*
+nvmerctl(SDunit *u, char *p, char *e)
{
Ctlr *ctlr;
- char *e, *s;
if((ctlr = u->dev->ctlr) == nil || ctlr->ident == nil)
- return 0;
+ return p;
- e = p+l;
- s = p;
-
p = seprint(p, e, "model\t%.40s\n", (char*)ctlr->ident+24);
p = seprint(p, e, "serial\t%.20s\n", (char*)ctlr->ident+4);
p = seprint(p, e, "firm\t%.8s\n", (char*)ctlr->ident+64);
p = seprint(p, e, "geometry %llud %lud\n", u->sectors, u->secsize);
- return p-s;
+ return p;
}
static void*
--- a/sys/src/9/port/sdram.c
+++ b/sys/src/9/port/sdram.c
@@ -214,12 +214,12 @@
return 2;
}
-static int
-ramrctl(SDunit *unit, char *p, int l)
+static char*
+ramrctl(SDunit *unit, char *p, char *e)
{
Ramdisk *rd = &rds[unit->subno];
- return snprint(p, l, "geometry %llud %ld\nalignment %lud %lud\n",
+ return seprint(p, e, "geometry %llud %ld\nalignment %lud %lud\n",
unit->sectors, unit->secsize,
(ulong)BY2PG, rd->off / unit->secsize);
}