Module Name:    src
Committed By:   msaitoh
Date:           Thu Jul 14 04:15:27 UTC 2016

Modified Files:
        src/sys/dev/pci: if_ti.c

Log Message:
- Use aprint_normal_dev() instead of aprint_error_dev() when printing
  Ethernet address.
- Use aprint() more.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/pci/if_ti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_ti.c
diff -u src/sys/dev/pci/if_ti.c:1.98 src/sys/dev/pci/if_ti.c:1.99
--- src/sys/dev/pci/if_ti.c:1.98	Thu Jul  7 06:55:41 2016
+++ src/sys/dev/pci/if_ti.c	Thu Jul 14 04:15:27 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.98 2016/07/07 06:55:41 msaitoh Exp $ */
+/* $NetBSD: if_ti.c,v 1.99 2016/07/14 04:15:27 msaitoh Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.98 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.99 2016/07/14 04:15:27 msaitoh Exp $");
 
 #include "opt_inet.h"
 
@@ -569,16 +569,16 @@ ti_alloc_jumbo_mem(struct ti_softc *sc)
 	if ((error = bus_dmamem_alloc(sc->sc_dmat,
 	    TI_JMEM, PAGE_SIZE, 0, &dmaseg, 1, &dmanseg,
 	    BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "can't allocate jumbo buffer, error = %d\n",
-		       error);
+		aprint_error_dev(sc->sc_dev,
+		    "can't allocate jumbo buffer, error = %d\n", error);
 		return (error);
 	}
 
 	if ((error = bus_dmamem_map(sc->sc_dmat, &dmaseg, dmanseg,
 	    TI_JMEM, (void **)&sc->ti_cdata.ti_jumbo_buf,
 	    BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "can't map jumbo buffer, error = %d\n",
-		       error);
+		aprint_error_dev(sc->sc_dev,
+		    "can't map jumbo buffer, error = %d\n", error);
 		return (error);
 	}
 
@@ -586,16 +586,16 @@ ti_alloc_jumbo_mem(struct ti_softc *sc)
 	    TI_JMEM, 1,
 	    TI_JMEM, 0, BUS_DMA_NOWAIT,
 	    &sc->jumbo_dmamap)) != 0) {
-		aprint_error_dev(sc->sc_dev, "can't create jumbo buffer DMA map, error = %d\n",
-		       error);
+		aprint_error_dev(sc->sc_dev,
+		    "can't create jumbo buffer DMA map, error = %d\n", error);
 		return (error);
 	}
 
 	if ((error = bus_dmamap_load(sc->sc_dmat, sc->jumbo_dmamap,
 	    sc->ti_cdata.ti_jumbo_buf, TI_JMEM, NULL,
 	    BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "can't load jumbo buffer DMA map, error = %d\n",
-		       error);
+		aprint_error_dev(sc->sc_dev,
+		    "can't load jumbo buffer DMA map, error = %d\n", error);
 		return (error);
 	}
 	sc->jumbo_dmaaddr = sc->jumbo_dmamap->dm_segs[0].ds_addr;
@@ -703,8 +703,8 @@ ti_newbuf_std(struct ti_softc *sc, int i
 		if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
 					       MCLBYTES, 0, BUS_DMA_NOWAIT,
 					       &dmamap)) != 0) {
-			aprint_error_dev(sc->sc_dev, "can't create recv map, error = %d\n",
-			       error);
+			aprint_error_dev(sc->sc_dev,
+			    "can't create recv map, error = %d\n", error);
 			return (ENOMEM);
 		}
 	}
@@ -713,15 +713,15 @@ ti_newbuf_std(struct ti_softc *sc, int i
 	if (m == NULL) {
 		MGETHDR(m_new, M_DONTWAIT, MT_DATA);
 		if (m_new == NULL) {
-			aprint_error_dev(sc->sc_dev, "mbuf allocation failed "
-			    "-- packet dropped!\n");
+			aprint_error_dev(sc->sc_dev,
+			    "mbuf allocation failed -- packet dropped!\n");
 			return (ENOBUFS);
 		}
 
 		MCLGET(m_new, M_DONTWAIT);
 		if (!(m_new->m_flags & M_EXT)) {
-			aprint_error_dev(sc->sc_dev, "cluster allocation failed "
-			    "-- packet dropped!\n");
+			aprint_error_dev(sc->sc_dev,
+			    "cluster allocation failed -- packet dropped!\n");
 			m_freem(m_new);
 			return (ENOBUFS);
 		}
@@ -731,8 +731,8 @@ ti_newbuf_std(struct ti_softc *sc, int i
 		if ((error = bus_dmamap_load(sc->sc_dmat, dmamap,
 				mtod(m_new, void *), m_new->m_len, NULL,
 				BUS_DMA_READ|BUS_DMA_NOWAIT)) != 0) {
-			aprint_error_dev(sc->sc_dev, "can't load recv map, error = %d\n",
-			       error);
+			aprint_error_dev(sc->sc_dev,
+			    "can't load recv map, error = %d\n", error);
 			m_freem(m_new);
 			return (ENOMEM);
 		}
@@ -778,8 +778,8 @@ ti_newbuf_mini(struct ti_softc *sc, int 
 		if ((error = bus_dmamap_create(sc->sc_dmat, MHLEN, 1,
 					       MHLEN, 0, BUS_DMA_NOWAIT,
 					       &dmamap)) != 0) {
-			aprint_error_dev(sc->sc_dev, "can't create recv map, error = %d\n",
-			       error);
+			aprint_error_dev(sc->sc_dev,
+			    "can't create recv map, error = %d\n", error);
 			return (ENOMEM);
 		}
 	}
@@ -788,8 +788,8 @@ ti_newbuf_mini(struct ti_softc *sc, int 
 	if (m == NULL) {
 		MGETHDR(m_new, M_DONTWAIT, MT_DATA);
 		if (m_new == NULL) {
-			aprint_error_dev(sc->sc_dev, "mbuf allocation failed "
-			    "-- packet dropped!\n");
+			aprint_error_dev(sc->sc_dev,
+			    "mbuf allocation failed -- packet dropped!\n");
 			return (ENOBUFS);
 		}
 		m_new->m_len = m_new->m_pkthdr.len = MHLEN;
@@ -798,8 +798,8 @@ ti_newbuf_mini(struct ti_softc *sc, int 
 		if ((error = bus_dmamap_load(sc->sc_dmat, dmamap,
 				mtod(m_new, void *), m_new->m_len, NULL,
 				BUS_DMA_READ|BUS_DMA_NOWAIT)) != 0) {
-			aprint_error_dev(sc->sc_dev, "can't load recv map, error = %d\n",
-			       error);
+			aprint_error_dev(sc->sc_dev,
+			    "can't load recv map, error = %d\n", error);
 			m_freem(m_new);
 			return (ENOMEM);
 		}
@@ -844,8 +844,8 @@ ti_newbuf_jumbo(struct ti_softc *sc, int
 		/* Allocate the mbuf. */
 		MGETHDR(m_new, M_DONTWAIT, MT_DATA);
 		if (m_new == NULL) {
-			aprint_error_dev(sc->sc_dev, "mbuf allocation failed "
-			    "-- packet dropped!\n");
+			aprint_error_dev(sc->sc_dev,
+			    "mbuf allocation failed -- packet dropped!\n");
 			return (ENOBUFS);
 		}
 
@@ -853,8 +853,8 @@ ti_newbuf_jumbo(struct ti_softc *sc, int
 		tbuf = ti_jalloc(sc);
 		if (tbuf == NULL) {
 			m_freem(m_new);
-			aprint_error_dev(sc->sc_dev, "jumbo allocation failed "
-			    "-- packet dropped!\n");
+			aprint_error_dev(sc->sc_dev,
+			    "jumbo allocation failed -- packet dropped!\n");
 			return (ENOBUFS);
 		}
 
@@ -1046,16 +1046,17 @@ ti_init_tx_ring(struct ti_softc *sc)
 	SIMPLEQ_INIT(&sc->txdma_list);
 	for (i = 0; i < TI_RSLOTS; i++) {
 		/* I've seen mbufs with 30 fragments. */
-		if ((error = bus_dmamap_create(sc->sc_dmat, ETHER_MAX_LEN_JUMBO,
-					       40, ETHER_MAX_LEN_JUMBO, 0,
-					       BUS_DMA_NOWAIT, &dmamap)) != 0) {
-			aprint_error_dev(sc->sc_dev, "can't create tx map, error = %d\n",
-			       error);
+		if ((error = bus_dmamap_create(sc->sc_dmat,
+			    ETHER_MAX_LEN_JUMBO, 40, ETHER_MAX_LEN_JUMBO, 0,
+			    BUS_DMA_NOWAIT, &dmamap)) != 0) {
+			aprint_error_dev(sc->sc_dev,
+			    "can't create tx map, error = %d\n", error);
 			return (ENOMEM);
 		}
 		dma = malloc(sizeof(*dma), M_DEVBUF, M_NOWAIT);
 		if (!dma) {
-			aprint_error_dev(sc->sc_dev, "can't alloc txdmamap_pool_entry\n");
+			aprint_error_dev(sc->sc_dev,
+			    "can't alloc txdmamap_pool_entry\n");
 			bus_dmamap_destroy(sc->sc_dmat, dmamap);
 			return (ENOMEM);
 		}
@@ -1622,11 +1623,12 @@ ti_attach(device_t parent, device_t self
 
 	t = ti_type_match(pa);
 	if (t == NULL) {
-		printf("ti_attach: were did the card go ?\n");
+		aprint_error("ti_attach: were did the card go ?\n");
 		return;
 	}
 
-	printf(": %s (rev. 0x%02x)\n", t->ti_name, PCI_REVISION(pa->pa_class));
+	aprint_normal(": %s (rev. 0x%02x)\n", t->ti_name,
+	    PCI_REVISION(pa->pa_class));
 
 	sc = device_private(self);
 	sc->sc_dev = self;
@@ -1643,7 +1645,7 @@ ti_attach(device_t parent, device_t self
 		if (pci_mapreg_map(pa, 0x10,
 		    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
 		    0 , &sc->ti_btag, &sc->ti_bhandle, NULL, NULL)) {
-			printf(": can't map memory space\n");
+			aprint_error_dev(self, "can't map memory space\n");
 			return;
 		}
 	}
@@ -1695,7 +1697,7 @@ ti_attach(device_t parent, device_t self
 		break;
 
 	default:
-		printf("%s: Unknown chip version: %d\n", device_xname(self),
+		aprint_error_dev(self, "Unknown chip version: %d\n",
 		    sc->ti_hwrev);
 		goto fail2;
 	}
@@ -1725,8 +1727,7 @@ ti_attach(device_t parent, device_t self
 	/*
 	 * A Tigon chip was detected. Inform the world.
 	 */
-	aprint_error_dev(self, "Ethernet address: %s\n",
-				ether_sprintf(eaddr));
+	aprint_normal_dev(self, "Ethernet address: %s\n",ether_sprintf(eaddr));
 
 	sc->sc_dmat = pa->pa_dmat;
 
@@ -1734,7 +1735,7 @@ ti_attach(device_t parent, device_t self
 	if ((error = bus_dmamem_alloc(sc->sc_dmat,
 	    sizeof(struct ti_ring_data), PAGE_SIZE, 0, &dmaseg, 1, &dmanseg,
 	    BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_error_dev(self,
 		    "can't allocate ring buffer, error = %d\n", error);
 		goto fail2;
 	}
@@ -1742,7 +1743,7 @@ ti_attach(device_t parent, device_t self
 	if ((error = bus_dmamem_map(sc->sc_dmat, &dmaseg, dmanseg,
 	    sizeof(struct ti_ring_data), (void **)&sc->ti_rdata,
 	    BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_error_dev(self,
 		    "can't map ring buffer, error = %d\n", error);
 		goto fail2;
 	}
@@ -1751,7 +1752,7 @@ ti_attach(device_t parent, device_t self
 	    sizeof(struct ti_ring_data), 1,
 	    sizeof(struct ti_ring_data), 0, BUS_DMA_NOWAIT,
 	    &sc->info_dmamap)) != 0) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_error_dev(self,
 		    "can't create ring buffer DMA map, error = %d\n", error);
 		goto fail2;
 	}
@@ -1759,7 +1760,7 @@ ti_attach(device_t parent, device_t self
 	if ((error = bus_dmamap_load(sc->sc_dmat, sc->info_dmamap,
 	    sc->ti_rdata, sizeof(struct ti_ring_data), NULL,
 	    BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev,
+		aprint_error_dev(self,
 		    "can't load ring buffer DMA map, error = %d\n", error);
 		goto fail2;
 	}

Reply via email to