Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hp300 Cleanup duplicated CS/80 indentify structures...



details:   https://anonhg.NetBSD.org/src/rev/4e40c139b813
branches:  trunk
changeset: 984372:4e40c139b813
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Mon Jul 05 14:51:23 2021 +0000

description:
Cleanup duplicated CS/80 indentify structures.  From OpenBSD.

https://marc.info/?l=openbsd-cvs&m=113227249626888&w=2
> Define the CS/80 identify structure only once and correctly, instead of
> duplicating it in every CS/80 driver and using an hardcoded number for
> its size.
> No functional change.

https://marc.info/?l=openbsd-cvs&m=113273001020159&w=2
> Pick HP-IB describe structures changes from main kernel code here as well.

diffstat:

 sys/arch/hp300/dev/ct.c               |  11 ++++++-----
 sys/arch/hp300/dev/ctreg.h            |  26 +-------------------------
 sys/arch/hp300/dev/hpibvar.h          |  35 +++++++++++++++++++++++++++++++----
 sys/arch/hp300/dev/rd.c               |  28 ++++++++++++++--------------
 sys/arch/hp300/dev/rdreg.h            |  26 +-------------------------
 sys/arch/hp300/dev/rdvar.h            |   3 +--
 sys/arch/hp300/stand/common/ct.c      |   6 +++---
 sys/arch/hp300/stand/common/hpibvar.h |  18 ++----------------
 sys/arch/hp300/stand/common/rd.c      |   6 +++---
 9 files changed, 62 insertions(+), 97 deletions(-)

diffs (truncated from 366 to 300 lines):

diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/ct.c
--- a/sys/arch/hp300/dev/ct.c   Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/ct.c   Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ct.c,v 1.62 2021/07/05 14:03:46 tsutsui Exp $  */
+/*     $NetBSD: ct.c,v 1.63 2021/07/05 14:51:23 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.62 2021/07/05 14:03:46 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.63 2021/07/05 14:51:23 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -257,7 +257,7 @@
 static int
 ctident(device_t parent, struct ct_softc *sc, struct hpibbus_attach_args *ha)
 {
-       struct ct_describe desc;
+       struct cs80_describe desc;
        u_char stat, cmd[3];
        char name[7];
        int i, id, n, type, canstream;
@@ -284,9 +284,10 @@
        cmd[1] = C_SVOL(0);
        cmd[2] = C_DESC;
        hpibsend(device_unit(parent), ha->ha_slave, C_CMD, cmd, sizeof(cmd));
-       hpibrecv(device_unit(parent), ha->ha_slave, C_EXEC, &desc, 37);
+       hpibrecv(device_unit(parent), ha->ha_slave, C_EXEC, &desc,
+           sizeof(desc));
        hpibrecv(device_unit(parent), ha->ha_slave, C_QSTAT, &stat,
-                sizeof(stat));
+           sizeof(stat));
 
        memset(name, 0, sizeof(name));
        if (stat == 0) {
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/ctreg.h
--- a/sys/arch/hp300/dev/ctreg.h        Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/ctreg.h        Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ctreg.h,v 1.10 2005/12/11 12:17:13 christos Exp $      */
+/*     $NetBSD: ctreg.h,v 1.11 2021/07/05 14:51:23 tsutsui Exp $       */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -98,30 +98,6 @@
        char    cmd;
 };
 
-struct ct_describe {
-       u_int   d_iuw:16,       /* controller: installed unit word */
-               d_cmaxxfr:16,   /* controller: max transfer rate (Kb) */
-               d_ctype:8,      /* controller: controller type */
-               d_utype:8,      /* unit: unit type */
-               d_name:24,      /* unit: name (6 BCD digits) */
-               d_sectsize:16,  /* unit: # of bytes per block (sector) */
-               d_blkbuf:8,     /* unit: # of blocks which can be buffered */
-               d_burstsize:8,  /* unit: recommended burst size */
-               d_blocktime:16, /* unit: block time (u-sec) */
-               d_uavexfr:16,   /* unit: average transfer rate (Kb) */
-               d_retry:16,     /* unit: optimal retry time (1/100-sec) */
-               d_access:16,    /* unit: access time param (1/100-sec) */
-               d_maxint:8,     /* unit: maximum interleave */
-               d_fvbyte:8,     /* unit: fixed volume byte */
-               d_rvbyte:8,     /* unit: removable volume byte */
-               d_maxcyl:24,    /* volume: maximum cylinder */
-               d_maxhead:8,    /* volume: maximum head */
-               d_maxsect:16,   /* volume: maximum sector on track */
-               d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */
-               d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */
-               d_interleave:8; /* volume: current interleave */
- };
-
 #define        CT7946ID        0x220
 #define CT9145ID       0x268
 #define        CT9144ID        0x260
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/hpibvar.h
--- a/sys/arch/hp300/dev/hpibvar.h      Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/hpibvar.h      Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpibvar.h,v 1.22 2021/07/05 14:03:46 tsutsui Exp $     */
+/*     $NetBSD: hpibvar.h,v 1.23 2021/07/05 14:51:23 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -60,8 +60,6 @@
  *     @(#)hpibvar.h   8.1 (Berkeley) 6/10/93
  */
 
-#include <sys/queue.h>
-
 #define        HPIB_IPL(x)     ((((x) >> 4) & 0x3) + 3)
 
 #define        HPIBA           32
@@ -93,6 +91,36 @@
 #define        C_UNT_P         0xdf    /*  with odd parity */
 #define        C_SCG           0x60    /* Secondary group commands */
 
+/*
+ * Description structure for CS/80 devices.
+ */
+struct cs80_describe {
+       u_int   d_iuw:16,       /* controller: installed unit word */
+               d_cmaxxfr:16,   /* controller: max transfer rate (Kb) */
+               d_ctype:8,      /* controller: controller type */
+               d_utype:8,      /* unit: unit type */
+               d_name:24,      /* unit: name (6 BCD digits) */
+               d_sectsize:16,  /* unit: # of bytes per block (sector) */
+               d_blkbuf:8,     /* unit: # of blocks which can be buffered */
+               d_burstsize:8,  /* unit: recommended burst size */
+               d_blocktime:16, /* unit: block time (u-sec) */
+               d_uavexfr:16,   /* unit: average transfer rate (Kb) */
+               d_retry:16,     /* unit: optimal retry time (1/100-sec) */
+               d_access:16,    /* unit: access time param (1/100-sec) */
+               d_maxint:8,     /* unit: maximum interleave */
+               d_fvbyte:8,     /* unit: fixed volume byte */
+               d_rvbyte:8,     /* unit: removable volume byte */
+               d_maxcyl:24,    /* volume: maximum cylinder */
+               d_maxhead:8,    /* volume: maximum head */
+               d_maxsect:16,   /* volume: maximum sector on track */
+               d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */
+               d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */
+               d_interleave:8; /* volume: current interleave */
+} __attribute__((__packed__));
+
+#ifdef _KERNEL
+#include <sys/queue.h>
+
 struct hpibbus_softc;
 
 /*
@@ -184,7 +212,6 @@
 #define        HPIBF_TIMO      0x10
 #define        HPIBF_DMA16     0x8000
 
-#ifdef _KERNEL
 extern void *internalhpib;
 extern int hpibtimeout;
 extern int hpibdmathresh;
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/rd.c
--- a/sys/arch/hp300/dev/rd.c   Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/rd.c   Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rd.c,v 1.106 2021/07/05 14:15:16 tsutsui Exp $ */
+/*     $NetBSD: rd.c,v 1.107 2021/07/05 14:51:23 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.106 2021/07/05 14:15:16 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.107 2021/07/05 14:51:23 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -178,7 +178,7 @@
 #define RDB_IO         0x08
 #define RDB_ASYNC      0x10
 #define RDB_ERROR      0x80
-int    rddebug = HDB_ERROR | HDB_IDENT;
+int    rddebug = RDB_ERROR | RDB_IDENT;
 #endif
 
 /*
@@ -381,7 +381,7 @@
 static int
 rdident(device_t parent, struct rd_softc *sc, struct hpibbus_attach_args *ha)
 {
-       struct rd_describe *desc = sc != NULL ? &sc->sc_rddesc : NULL;
+       struct cs80_describe desc;
        u_char stat, cmd[3];
        char name[7];
        int i, id, n, ctlr, slave;
@@ -416,11 +416,11 @@
        cmd[1] = C_SVOL(0);
        cmd[2] = C_DESC;
        hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd));
-       hpibrecv(ctlr, slave, C_EXEC, desc, 37);
+       hpibrecv(ctlr, slave, C_EXEC, &desc, sizeof(desc));
        hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
        memset(name, 0, sizeof(name));
        if (stat == 0) {
-               n = desc->d_name;
+               n = desc.d_name;
                for (i = 5; i >= 0; i--) {
                        name[i] = (n & 0xf) + '0';
                        n >>= 4;
@@ -431,21 +431,21 @@
        if (rddebug & RDB_IDENT) {
                aprint_normal("\n");
                aprint_normal_dev(sc->sc_dev, "id: 0x%04x, name: %x ('%s')\n",
-                   ha->ha_id, desc->d_name, name);
+                   ha->ha_id, desc.d_name, name);
                aprint_normal("  iuw %x, maxxfr %d, ctype %d\n",
-                   desc->d_iuw, desc->d_cmaxxfr, desc->d_ctype);
+                   desc.d_iuw, desc.d_cmaxxfr, desc.d_ctype);
                aprint_normal("  utype %d, bps %d, blkbuf %d, burst %d,"
                    " blktime %d\n",
-                   desc->d_utype, desc->d_sectsize,
-                   desc->d_blkbuf, desc->d_burstsize, desc->d_blocktime);
+                   desc.d_utype, desc.d_sectsize,
+                   desc.d_blkbuf, desc.d_burstsize, desc.d_blocktime);
                aprint_normal("  avxfr %d, ort %d, atp %d, maxint %d, fv %x"
                    ", rv %x\n",
-                   desc->d_uavexfr, desc->d_retry, desc->d_access,
-                   desc->d_maxint, desc->d_fvbyte, desc->d_rvbyte);
+                   desc.d_uavexfr, desc.d_retry, desc.d_access,
+                   desc.d_maxint, desc.d_fvbyte, desc.d_rvbyte);
                aprint_normal("  maxcyl/head/sect %d/%d/%d, maxvsect %d,"
                    " inter %d\n",
-                   desc->d_maxcyl, desc->d_maxhead, desc->d_maxsect,
-                   desc->d_maxvsectl, desc->d_interleave);
+                   desc.d_maxcyl, desc.d_maxhead, desc.d_maxsect,
+                   desc.d_maxvsectl, desc.d_interleave);
                aprint_normal("%s", device_xname(sc->sc_dev));
        }
 #endif
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/rdreg.h
--- a/sys/arch/hp300/dev/rdreg.h        Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/rdreg.h        Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rdreg.h,v 1.14 2021/05/18 15:21:41 tsutsui Exp $       */
+/*     $NetBSD: rdreg.h,v 1.15 2021/07/05 14:51:23 tsutsui Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -103,30 +103,6 @@
        char    c_cmd;
 } __attribute__((__packed__));
 
-struct rd_describe {
-       u_int   d_iuw:16,       /* controller: installed unit word */
-               d_cmaxxfr:16,   /* controller: max transfer rate (Kb) */
-               d_ctype:8,      /* controller: controller type */
-               d_utype:8,      /* unit: unit type */
-               d_name:24,      /* unit: name (6 BCD digits) */
-               d_sectsize:16,  /* unit: # of bytes per block (sector) */
-               d_blkbuf:8,     /* unit: # of blocks which can be buffered */
-               d_burstsize:8,  /* unit: recommended burst size */
-               d_blocktime:16, /* unit: block time (u-sec) */
-               d_uavexfr:16,   /* unit: average transfer rate (Kb) */
-               d_retry:16,     /* unit: optimal retry time (1/100-sec) */
-               d_access:16,    /* unit: access time param (1/100-sec) */
-               d_maxint:8,     /* unit: maximum interleave */
-               d_fvbyte:8,     /* unit: fixed volume byte */
-               d_rvbyte:8,     /* unit: removable volume byte */
-               d_maxcyl:24,    /* volume: maximum cylinder */
-               d_maxhead:8,    /* volume: maximum head */
-               d_maxsect:16,   /* volume: maximum sector on track */
-               d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */
-               d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */
-               d_interleave:8; /* volume: current interleave */
-} __attribute__((__packed__));
-
 /* HW ids */
 #define        RD7946AID       0x220   /* also 7945A */
 #define        RD9134DID       0x221   /* also 9122S */
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/dev/rdvar.h
--- a/sys/arch/hp300/dev/rdvar.h        Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/dev/rdvar.h        Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rdvar.h,v 1.24 2021/06/04 17:12:08 tsutsui Exp $       */
+/*     $NetBSD: rdvar.h,v 1.25 2021/07/05 14:51:23 tsutsui Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -69,7 +69,6 @@
        short   sc_type;
        char    *sc_addr;
        int     sc_resid;
-       struct  rd_describe sc_rddesc;
        struct  hpibqueue sc_hq;        /* hpib job queue entry */
        struct  rd_iocmd sc_ioc;
        struct  rd_rscmd sc_rsc;
diff -r 8c7f509865a0 -r 4e40c139b813 sys/arch/hp300/stand/common/ct.c
--- a/sys/arch/hp300/stand/common/ct.c  Mon Jul 05 14:15:16 2021 +0000
+++ b/sys/arch/hp300/stand/common/ct.c  Mon Jul 05 14:51:23 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ct.c,v 1.7 2011/07/17 20:54:40 joerg Exp $     */
+/*     $NetBSD: ct.c,v 1.8 2021/07/05 14:51:23 tsutsui Exp $   */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -106,7 +106,7 @@
 int
 ctident(int ctlr, int unit)
 {
-       struct ct_describe desc;
+       struct cs80_describe desc;
        uint8_t stat, cmd[3];
        char name[7];
        int id, i;
@@ -131,7 +131,7 @@
        cmd[1] = C_SVOL(0);



Home | Main Index | Thread Index | Old Index