Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev refactor wd and ataraid drivers to use common disk s...
details: https://anonhg.NetBSD.org/src/rev/6b00d6e6122f
branches: trunk
changeset: 357239:6b00d6e6122f
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Wed Nov 01 19:34:45 2017 +0000
description:
refactor wd and ataraid drivers to use common disk subroutines.
diffstat:
sys/dev/ata/ata_raid_adaptec.c | 21 +-
sys/dev/ata/ata_raid_intel.c | 21 +-
sys/dev/ata/ata_raid_jmicron.c | 23 +-
sys/dev/ata/ata_raid_nvidia.c | 19 +-
sys/dev/ata/ata_raid_promise.c | 21 +-
sys/dev/ata/ata_raid_via.c | 23 +-
sys/dev/ata/wd.c | 961 ++++++++++++++--------------------------
sys/dev/ata/wdvar.h | 12 +-
sys/dev/files.dev | 4 +-
9 files changed, 408 insertions(+), 697 deletions(-)
diffs (truncated from 2197 to 300 lines):
diff -r 419db54b05bd -r 6b00d6e6122f sys/dev/ata/ata_raid_adaptec.c
--- a/sys/dev/ata/ata_raid_adaptec.c Wed Nov 01 19:15:31 2017 +0000
+++ b/sys/dev/ata/ata_raid_adaptec.c Wed Nov 01 19:34:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_adaptec.c,v 1.9 2008/09/15 11:44:50 tron Exp $ */
+/* $NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.9 2008/09/15 11:44:50 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -67,6 +67,7 @@
int
ata_raid_read_config_adaptec(struct wd_softc *sc)
{
+ struct dk_softc *dksc = &sc->sc_dksc;
struct adaptec_raid_conf *info;
struct atabus_softc *atabus;
struct vnode *vp;
@@ -78,10 +79,10 @@
info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK);
- bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0);
+ bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
/* Get a vnode for the raw partition of this disk. */
- dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART);
+ dev = MAKEDISKDEV(bmajor, device_unit(dksc->sc_dev), RAW_PART);
error = bdevvp(dev, &vp);
if (error)
goto out;
@@ -97,7 +98,7 @@
VOP_CLOSE(vp, FREAD, NOCRED);
vput(vp);
if (error) {
- aprint_error_dev(sc->sc_dev,
+ aprint_error_dev(dksc->sc_dev,
"error %d reading Adaptec config block\n", error);
goto out;
}
@@ -110,7 +111,7 @@
/* Check the signature. */
if (info->magic_0 != ADP_MAGIC_0 || info->magic_3 != ADP_MAGIC_3) {
DPRINTF(("%s: Adaptec signature check failed\n",
- device_xname(sc->sc_dev)));
+ dksc->sc_xname));
error = ESRCH;
goto out;
}
@@ -145,7 +146,7 @@
break;
default:
- aprint_error_dev(sc->sc_dev,
+ aprint_error_dev(dksc->sc_dev,
"unknown Adaptec RAID type 0x%02x\n",
info->configs[0].type);
error = EINVAL;
@@ -169,10 +170,10 @@
aai->aai_interleave = aai->aai_capacity;
}
- atabus = device_private(device_parent(sc->sc_dev));
+ atabus = device_private(device_parent(dksc->sc_dev));
drive = atabus->sc_chan->ch_channel;
if (drive >= aai->aai_ndisks) {
- aprint_error_dev(sc->sc_dev,
+ aprint_error_dev(dksc->sc_dev,
"drive number %d doesn't make sense within %d-disk "
"array\n", drive, aai->aai_ndisks);
error = EINVAL;
@@ -180,7 +181,7 @@
}
adi = &aai->aai_disks[drive];
- adi->adi_dev = sc->sc_dev;
+ adi->adi_dev = dksc->sc_dev;
adi->adi_status = ADI_S_ONLINE | ADI_S_ASSIGNED;
adi->adi_sectors = aai->aai_capacity;
adi->adi_compsize = be32toh(info->configs[drive+1].sectors);
diff -r 419db54b05bd -r 6b00d6e6122f sys/dev/ata/ata_raid_intel.c
--- a/sys/dev/ata/ata_raid_intel.c Wed Nov 01 19:15:31 2017 +0000
+++ b/sys/dev/ata/ata_raid_intel.c Wed Nov 01 19:34:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $ */
+/* $NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -136,6 +136,7 @@
int
ata_raid_read_config_intel(struct wd_softc *sc)
{
+ struct dk_softc *dksc = &sc->sc_dksc;
struct intel_raid_conf *info;
struct intel_raid_mapping *map;
struct ataraid_array_info *aai;
@@ -149,10 +150,10 @@
info = malloc(1536, M_DEVBUF, M_WAITOK|M_ZERO);
- bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0);
+ bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
/* Get a vnode for the raw partition of this disk. */
- dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART);
+ dev = MAKEDISKDEV(bmajor, device_unit(dksc->sc_dev), RAW_PART);
error = bdevvp(dev, &vp);
if (error)
goto out;
@@ -169,7 +170,7 @@
vput(vp);
if (error) {
DPRINTF(("%s: error %d reading Intel MatrixRAID config block\n",
- device_xname(sc->sc_dev), error));
+ dksc->sc_xname, error));
goto out;
}
@@ -181,7 +182,7 @@
/* Check if this is a Intel RAID struct */
if (strncmp(info->intel_id, INTEL_MAGIC, strlen(INTEL_MAGIC))) {
DPRINTF(("%s: Intel MatrixRAID signature check failed\n",
- device_xname(sc->sc_dev)));
+ dksc->sc_xname));
error = ESRCH;
goto out;
}
@@ -194,7 +195,7 @@
checksum -= info->checksum;
if (checksum != info->checksum) {
DPRINTF(("%s: Intel MatrixRAID checksum failed 0x%x != 0x%x\n",
- device_xname(sc->sc_dev), checksum, info->checksum));
+ dksc->sc_xname, checksum, info->checksum));
error = ESRCH;
goto out;
}
@@ -208,7 +209,7 @@
volumeid = find_volume_id(info);
if (volumeid < 0) {
- aprint_error_dev(sc->sc_dev,
+ aprint_error_dev(dksc->sc_dev,
"too many RAID arrays\n");
error = ENOMEM;
goto out;
@@ -235,7 +236,7 @@
break;
default:
DPRINTF(("%s: unknown Intel MatrixRAID type 0x%02x\n",
- device_xname(sc->sc_dev), map->type));
+ dksc->sc_xname, map->type));
error = EINVAL;
goto out;
}
@@ -280,7 +281,7 @@
adi->adi_status &= ~ADI_S_ONLINE;
if (adi->adi_status) {
- adi->adi_dev = sc->sc_dev;
+ adi->adi_dev = dksc->sc_dev;
adi->adi_sectors = info->disk[diskidx].sectors;
adi->adi_compsize = adi->adi_sectors - aai->aai_reserved;
diff -r 419db54b05bd -r 6b00d6e6122f sys/dev/ata/ata_raid_jmicron.c
--- a/sys/dev/ata/ata_raid_jmicron.c Wed Nov 01 19:15:31 2017 +0000
+++ b/sys/dev/ata/ata_raid_jmicron.c Wed Nov 01 19:34:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $ */
+/* $NetBSD: ata_raid_jmicron.c,v 1.6 2017/11/01 19:34:46 mlelstv Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.6 2017/11/01 19:34:46 mlelstv Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -118,6 +118,7 @@
int
ata_raid_read_config_jmicron(struct wd_softc *sc)
{
+ struct dk_softc *dksc = &sc->sc_dksc;
struct atabus_softc *atabus;
struct jmicron_raid_conf *info;
struct vnode *vp;
@@ -131,10 +132,10 @@
info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK|M_ZERO);
- bmajor = devsw_name2blk(device_xname(sc->sc_dev), NULL, 0);
+ bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
/* Get a vnode for the raw partition of this disk. */
- dev = MAKEDISKDEV(bmajor, device_unit(sc->sc_dev), RAW_PART);
+ dev = MAKEDISKDEV(bmajor, device_unit(dksc->sc_dev), RAW_PART);
error = bdevvp(dev, &vp);
if (error)
goto out;
@@ -151,14 +152,14 @@
vput(vp);
if (error) {
DPRINTF(("%s: error %d reading JMicron config block\n",
- device_xname(sc->sc_dev), error));
+ dksc->sc_xname, error));
goto out;
}
/* Check for JMicron signature. */
if (strncmp(info->signature, JMICRON_MAGIC, 2)) {
DPRINTF(("%s: JMicron RAID signature check failed\n",
- device_xname(sc->sc_dev)));
+ dksc->sc_xname));
error = ESRCH;
goto out;
}
@@ -169,7 +170,7 @@
checksum += *ptr++;
if (checksum) {
DPRINTF(("%s: JMicron checksum failed\n",
- device_xname(sc->sc_dev)));
+ dksc->sc_xname));
error = ESRCH;
goto out;
}
@@ -223,7 +224,7 @@
break;
default:
DPRINTF(("%s: unknown JMicron RAID type 0x%02x\n",
- device_xname(sc->sc_dev), info->type));
+ dksc->sc_xname, info->type));
error = EINVAL;
goto out;
}
@@ -243,11 +244,11 @@
if (info->name)
strlcpy(aai->aai_name, info->name, sizeof(aai->aai_name));
- atabus = device_private(device_parent(sc->sc_dev));
+ atabus = device_private(device_parent(dksc->sc_dev));
drive = atabus->sc_chan->ch_channel;
if (drive >= aai->aai_ndisks) {
DPRINTF(("%s: drive number %d doesn't make sense within "
- "%d-disk array\n", device_xname(sc->sc_dev),
+ "%d-disk array\n", dksc->sc_xname,
drive, aai->aai_ndisks));
error = EINVAL;
goto out;
@@ -255,7 +256,7 @@
if (info->disks[drive] == info->disk_id) {
adi = &aai->aai_disks[drive];
- adi->adi_dev = sc->sc_dev;
+ adi->adi_dev = dksc->sc_dev;
adi->adi_status = ADI_S_ONLINE | ADI_S_ASSIGNED;
adi->adi_sectors = aai->aai_capacity;
adi->adi_compsize = disk_size - aai->aai_reserved;
diff -r 419db54b05bd -r 6b00d6e6122f sys/dev/ata/ata_raid_nvidia.c
--- a/sys/dev/ata/ata_raid_nvidia.c Wed Nov 01 19:15:31 2017 +0000
+++ b/sys/dev/ata/ata_raid_nvidia.c Wed Nov 01 19:34:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $ */
+/* $NetBSD: ata_raid_nvidia.c,v 1.3 2017/11/01 19:34:46 mlelstv Exp $ */
/*-
* Copyright (c) 2000 - 2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.3 2017/11/01 19:34:46 mlelstv Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -122,6 +122,7 @@
int
ata_raid_read_config_nvidia(struct wd_softc *sc)
{
Home |
Main Index |
Thread Index |
Old Index