Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/emips/ebus - misc KNF and style fixes



details:   https://anonhg.NetBSD.org/src/rev/a4f8c0ffefe4
branches:  trunk
changeset: 766195:a4f8c0ffefe4
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 18 17:47:20 2011 +0000

description:
- misc KNF and style fixes
- use device_t and cfdata_t
No binary change.

diffstat:

 sys/arch/emips/ebus/ace_ebus.c |  2019 +++++++++++++++++++++------------------
 1 files changed, 1090 insertions(+), 929 deletions(-)

diffs (truncated from 2646 to 300 lines):

diff -r 312215cf51a3 -r a4f8c0ffefe4 sys/arch/emips/ebus/ace_ebus.c
--- a/sys/arch/emips/ebus/ace_ebus.c    Sat Jun 18 17:06:52 2011 +0000
+++ b/sys/arch/emips/ebus/ace_ebus.c    Sat Jun 18 17:47:20 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ace_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $       */
+/*     $NetBSD: ace_ebus.c,v 1.2 2011/06/18 17:47:20 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.1 2011/01/26 01:18:50 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.2 2011/06/18 17:47:20 tsutsui Exp $");
 
 #include "rnd.h"
 
@@ -75,49 +75,49 @@
  * NB: Beware of mis-alignment for all 32bit things
  */
 typedef struct _CFLASH_IDENTIFY {
-    uint16_t Signature;                              /* Word 0 */
+       uint16_t Signature;                             /* Word 0 */
 #define CFLASH_SIGNATURE 0x848a
-    uint16_t DefaultNumberOfCylinders;               /* Word 1 */
-    uint16_t Reserved1;                              /* Word 2 */
-    uint16_t DefaultNumberOfHeads;                   /* Word 3 */
-    uint16_t Obsolete1[2];                           /* Word 4 */
-    uint16_t DefaultSectorsPerTrack;                 /* Word 6 */
-    uint16_t SectorsPerCard[2];                      /* Word 7 */
-    uint16_t Obsolete2;                              /* Word 9 */
-    uint8_t  SerialNumber[20]; /* padded, right-justified Word 10 */
-    uint16_t Obsolete3[2];                           /* Word 20 */
-    uint16_t EccBytesInRWLong;                       /* Word 22 */
-    uint8_t  FirmwareRevision[8];                    /* Word 23 */
-    uint8_t  ModelNumber[40];                        /* Word 27 */
-    uint16_t SectorsInRWMultiple;                    /* Word 47 */
-    uint16_t Reserved2;                              /* Word 48 */
-    uint16_t Capabilities;                           /* Word 49 */
-    uint16_t Reserved3;                              /* Word 50 */
-    uint16_t PioMode;                                /* Word 51 */
-    uint16_t Obsolete4;                              /* Word 52 */
-    uint16_t FieldValidity;                          /* Word 53 */
-    uint16_t CurrentNumberOfCylinders;               /* Word 54 */
-    uint16_t CurrentNumberOfHeads;                   /* Word 55 */
-    uint16_t CurrentSectorsPerTrack;                 /* Word 56 */
-    uint16_t CurrentCapacity[2];                     /* Word 57 */
-    uint16_t MultiSectorSettings;                    /* Word 59 */
-    uint16_t NumberOfAddressableSectors[2];          /* Word 60 */
-    uint16_t Reserved4;                              /* Word 62 */
-    uint16_t MultiWordDmaTransfer;                   /* Word 63 */
-    uint16_t AdvancedPioModes;                       /* Word 64 */
-    uint16_t MinimumMultiWordDmaTiming;              /* Word 65 */
-    uint16_t RecommendedMultiWordDmaTiming;          /* Word 66 */
-    uint16_t PioTimingNoFlowControl;                 /* Word 67 */
-    uint16_t PioTimingWithFlowControl;               /* Word 68 */
-    uint16_t Reserved5[13];                          /* Word 69 */
-    uint16_t FeaturesSupported[3];                   /* Word 82 */
-    uint16_t FeaturesEnabled[3];                     /* Word 85 */
-    uint16_t UdmaMode;                               /* Word 88 */
-    uint16_t SecurityEraseTime;                      /* Word 89 */
-    uint16_t EnhancedSecurityEraseTime;              /* Word 90 */
-    uint16_t CurrentPowerManagementValue;            /* Word 91 */
-    uint8_t  Reserved6[72];                          /* Word 92-127 */
-    uint8_t  SecondHalf[256];                        /* Word 128-255 */
+       uint16_t DefaultNumberOfCylinders;              /* Word 1 */
+       uint16_t Reserved1;                             /* Word 2 */
+       uint16_t DefaultNumberOfHeads;                  /* Word 3 */
+       uint16_t Obsolete1[2];                          /* Word 4 */
+       uint16_t DefaultSectorsPerTrack;                /* Word 6 */
+       uint16_t SectorsPerCard[2];                     /* Word 7 */
+       uint16_t Obsolete2;                             /* Word 9 */
+       uint8_t  SerialNumber[20]; /* padded, right-justified Word 10 */
+       uint16_t Obsolete3[2];                          /* Word 20 */
+       uint16_t EccBytesInRWLong;                      /* Word 22 */
+       uint8_t  FirmwareRevision[8];                   /* Word 23 */
+       uint8_t  ModelNumber[40];                       /* Word 27 */
+       uint16_t SectorsInRWMultiple;                   /* Word 47 */
+       uint16_t Reserved2;                             /* Word 48 */
+       uint16_t Capabilities;                          /* Word 49 */
+       uint16_t Reserved3;                             /* Word 50 */
+       uint16_t PioMode;                               /* Word 51 */
+       uint16_t Obsolete4;                             /* Word 52 */
+       uint16_t FieldValidity;                         /* Word 53 */
+       uint16_t CurrentNumberOfCylinders;              /* Word 54 */
+       uint16_t CurrentNumberOfHeads;                  /* Word 55 */
+       uint16_t CurrentSectorsPerTrack;                /* Word 56 */
+       uint16_t CurrentCapacity[2];                    /* Word 57 */
+       uint16_t MultiSectorSettings;                   /* Word 59 */
+       uint16_t NumberOfAddressableSectors[2];         /* Word 60 */
+       uint16_t Reserved4;                             /* Word 62 */
+       uint16_t MultiWordDmaTransfer;                  /* Word 63 */
+       uint16_t AdvancedPioModes;                      /* Word 64 */
+       uint16_t MinimumMultiWordDmaTiming;             /* Word 65 */
+       uint16_t RecommendedMultiWordDmaTiming;         /* Word 66 */
+       uint16_t PioTimingNoFlowControl;                /* Word 67 */
+       uint16_t PioTimingWithFlowControl;              /* Word 68 */
+       uint16_t Reserved5[13];                         /* Word 69 */
+       uint16_t FeaturesSupported[3];                  /* Word 82 */
+       uint16_t FeaturesEnabled[3];                    /* Word 85 */
+       uint16_t UdmaMode;                              /* Word 88 */
+       uint16_t SecurityEraseTime;                     /* Word 89 */
+       uint16_t EnhancedSecurityEraseTime;             /* Word 90 */
+       uint16_t CurrentPowerManagementValue;           /* Word 91 */
+       uint8_t  Reserved6[72];                         /* Word 92-127 */
+       uint8_t  SecondHalf[256];                       /* Word 128-255 */
 } CFLASH_IDENTIFY, *PCFLASH_IDENTIFY;
 
 #define SIZEOF_IDENTIFY CF_SECTOR_SIZE /* must be a sector multiple */
@@ -135,14 +135,15 @@
        daddr_t         blkno;  /* block addr */
        daddr_t         blkdone;/* number of blks transferred */
        size_t          nblks;  /* number of blocks currently transferring */
-       size_t      nbytes;     /* number of bytes currently transferring */
+       size_t          nbytes; /* number of bytes currently transferring */
        char            *databuf;/* data buffer address */
        volatile int    error;
-#define        NOERROR         0       /* There was no error (r_error invalid), else see acedone()*/
+#define        NOERROR         0       /* There was no error (r_error invalid),
+                                  else see acedone()*/
 #define FAILED(er) (er != 0)
 #define EDOOFUS EIO
 
-       u_int32_t       r_error;/* copy of status register */
+       uint32_t        r_error;/* copy of status register */
 #ifdef HAS_BAD144_HANDLING
        daddr_t         badsect[127];/* 126 plus trailing -1 marker */
 #endif
@@ -160,11 +161,11 @@
        /* IDE disk soft states */
        struct buf *sc_bp; /* buf being transfered */
        struct buf *active_xfer; /* buf handoff to thread  */
-    /* current transfer data */
+       /* current transfer data */
        struct ace_bio sc_bio; /* current transfer */
 
-    struct proc *ch_thread;
-    int ch_flags;
+       struct proc *ch_thread;
+       int ch_flags;
 #define ATACH_SHUTDOWN 0x02        /* thread is shutting down */
 #define ATACH_IRQ_WAIT 0x10        /* thread is waiting for irq */
 #define ATACH_DISABLED 0x80        /* channel is disabled */
@@ -172,7 +173,7 @@
 #define ATACH_TH_RESET 0x200       /* someone ask the thread to reset */
 
        int openings;
-    int media_has_changed;
+       int media_has_changed;
 #define    ACECE_MC    0x20    /* media changed */
 #define    ACECE_MCR   0x08    /* media change requested */
        struct _CFLASH_IDENTIFY sc_params;/* drive characteristics found */
@@ -184,11 +185,11 @@
 #define ACEF_WAIT      0x020 /* waiting for resources */
 #define ACEF_KLABEL    0x080 /* retain label after 'full' close */
 
-       u_int64_t sc_capacity;
+       uint64_t sc_capacity;
        uint32_t sc_multi; /* max sectors per xfer */
 
        struct  _Sac   *sc_dr;          /* reg pointers */
-    int hw_busy;
+       int hw_busy;
        int retries; /* number of xfer retry */
 
 #if NRND > 0
@@ -196,11 +197,11 @@
 #endif
 };
 
-int  ace_ebus_match(struct device *, struct cfdata *, void *);
-void ace_ebus_attach(struct device *, struct device *, void *);
+int  ace_ebus_match(device_t, cfdata_t, void *);
+void ace_ebus_attach(device_t, device_t, void *);
 void aceattach(struct ace_softc *);
-int     acedetach(struct device *, int);
-int     aceactivate(struct device *, enum devact);
+int     acedetach(device_t, int);
+int     aceactivate(device_t, enum devact);
 
 void  acedone(struct ace_softc *);
 static void ace_params_to_properties(struct ace_softc *ace);
@@ -213,21 +214,21 @@
 static void sysace_thread(void *arg);
 
 int
-ace_ebus_match(struct device *parent, struct cfdata *match, void *aux)
+ace_ebus_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct ebus_attach_args *d = aux;
-    struct _Sac *sac = (struct _Sac *)d->ia_vaddr;
+       struct _Sac *sac = (struct _Sac *)d->ia_vaddr;
 
-    if (strcmp("ace", d->ia_name) != 0)
-               return (0);
-    if ((sac == NULL) ||
-        ((sac->Tag & SAC_TAG) != PMTTAG_SYSTEM_ACE))
-        return 0;
-       return (1);
+       if (strcmp("ace", d->ia_name) != 0)
+               return 0;
+       if ((sac == NULL) ||
+           ((sac->Tag & SAC_TAG) != PMTTAG_SYSTEM_ACE))
+               return 0;
+       return 1;
 }
 
 void
-ace_ebus_attach(struct device *parent, struct device *self, void *aux)
+ace_ebus_attach(device_t parent, device_t self, void *aux)
 {
        struct ace_softc *ace = device_private(self);
        struct ebus_attach_args *ia = aux;
@@ -255,7 +256,8 @@
                    "thread: error %d\n", error);
 }
 
-/* Sysace driver I(af) wrote for FreeBsd.
+/*
+ * Sysace driver I(af) wrote for FreeBsd.
  */
 #define CF_SECBITS     9
 #define CF_SECTOR_SIZE (1 << CF_SECBITS)
@@ -265,12 +267,13 @@
 static int sysace_identify(struct ace_softc *sc);
 static int sysace_lock_registers(struct ace_softc *sc);
 static int sysace_unlock_registers(struct ace_softc *sc);
-static int sysace_start(struct ace_softc *sc, uint32_t Command, uint32_t Lba, uint32_t nSectors);
+static int sysace_start(struct ace_softc *sc, uint32_t Command, uint32_t Lba,
+                       uint32_t nSectors);
 static int sysace_validate(struct ace_softc *sc, daddr_t start, size_t *pSize);
-static int sysace_read_at (struct ace_softc *sc, daddr_t start_sector, char *buffer,
-                           size_t nblocks, size_t * pSizeRead);
-static int sysace_write_at(struct ace_softc *sc, daddr_t start_sector, char *buffer,
-                           size_t nblocks, size_t * pSizeWritten);
+static int sysace_read_at (struct ace_softc *sc, daddr_t start_sector,
+                          char *buffer, size_t nblocks, size_t * pSizeRead);
+static int sysace_write_at(struct ace_softc *sc, daddr_t start_sector,
+                          char *buffer, size_t nblocks, size_t * pSizeWritten);
 #ifdef USE_ACE_FOR_RECONFIG /* Old code, despised and replaced by ICAP */
 static int sysace_send_config(struct ace_softc *sc,
                               uint32_t *Data, unsigned int nBytes);
@@ -285,7 +288,7 @@
 #define DEBUG_READS  0x40
 #define DEBUG_ERRORS 0x80
 #ifdef DEBUG
-int ace_debug = DEBUG_ERRORS;//|DEBUG_WRITES;
+int ace_debug = DEBUG_ERRORS /*|DEBUG_WRITES*/;
 #define ACE_DEBUG(x) (ace_debug & (x))
 #define DBGME(_lev_,_x_) if ((_lev_) & ace_debug) _x_
 #else
@@ -297,49 +300,54 @@
 static int
 sysace_attach(struct ace_softc *sc)
 {
-    int error;
-       
-    DBGME(DEBUG_FUNCS,printf("Sysace::delayed_attach %p\n", sc));
+       int error;
+
+       DBGME(DEBUG_FUNCS, printf("Sysace::delayed_attach %p\n", sc));
+
+       sc->media_has_changed = TRUE;
+       sc->sc_capacity = 0;
 
-    sc->media_has_changed = TRUE;
-    sc->sc_capacity = 0;
-
-    error = sysace_reset(sc);
-    if (error) {
-        device_printf(sc->sc_dev,"failed to reset, errno=%d\n", error);
-        goto Out;
-    }
+       error = sysace_reset(sc);
+       if (error) {
+               device_printf(sc->sc_dev,
+                   "failed to reset, errno=%d\n", error);
+               goto Out;
+       }
 
-    error = sysace_identify(sc);
-    if (error) {
-        device_printf(sc->sc_dev,"failed to identify card, errno=%d.\n", error);
-        goto Out;
-    }
+       error = sysace_identify(sc);
+       if (error) {
+               device_printf(sc->sc_dev,
+                   "failed to identify card, errno=%d.\n", error);
+               goto Out;
+       }
 
-    DBGME(DEBUG_PROBE,device_printf(sc->sc_dev,"Card has %qx sectors.\n", sc->sc_capacity));
+       DBGME(DEBUG_PROBE, device_printf(sc->sc_dev,
+           "Card has %qx sectors.\n", sc->sc_capacity));
        if (sc->sc_capacity == 0) {
-        device_printf(sc->sc_dev,"size 0, no card? Wont work.\n");
-        error = EDOOFUS;
-       goto Out;



Home | Main Index | Thread Index | Old Index