Another cleanup run.

Another cleanup run.

--- dev/ic/bwi.c
+++ dev/ic/bwi.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: bwi.c,v 1.10 2007/09/13 20:37:19 mglocker Exp $	*/
+/*	$OpenBSD: bwi.c,v 1.11 2007/09/14 09:29:00 mglocker Exp $	*/

 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
@@ -526,7 +526,7 @@

 void
 bwi_memobj_write_2(struct bwi_mac *mac, uint16_t obj_id, uint16_t ofs0,
-		   uint16_t v)
+    uint16_t v)
 {
 	struct bwi_softc *sc = mac->mac_sc;
 	uint32_t data_reg;
@@ -867,7 +867,6 @@

 #define TEST_VAL1	0xaa5555aa
 #define TEST_VAL2	0x55aaaa55
-
 	/* Save it for later restoring */
 	orig_val = MOBJ_READ_4(mac, BWI_COMM_MOBJ, 0);

@@ -903,7 +902,6 @@
 		    sc->sc_dev.dv_xname, __func__, val);
 		return (ENXIO);
 	}
-
 #undef TEST_VAL2
 #undef TEST_VAL1

@@ -1014,16 +1012,16 @@
 bwi_mac_dummy_xmit(struct bwi_mac *mac)
 {
 #define PACKET_LEN	5
-	static const uint32_t	packet_11a[PACKET_LEN] =
-	{ 0x000201cc, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };
-	static const uint32_t	packet_11bg[PACKET_LEN] =
-	{ 0x000b846e, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };
-
 	struct bwi_softc *sc = mac->mac_sc;
 	struct bwi_rf *rf = &mac->mac_rf;
 	const uint32_t *packet;
 	uint16_t val_50c;
 	int wait_max, i;
+
+	static const uint32_t	packet_11a[PACKET_LEN] =
+	    { 0x000201cc, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };
+	static const uint32_t	packet_11bg[PACKET_LEN] =
+	    { 0x000b846e, 0x00d40000, 0x00000000, 0x01000000, 0x00000000 };

 	if (mac->mac_phy.phy_mode == IEEE80211_MODE_11A) {
 		wait_max = 30;
@@ -1152,7 +1150,7 @@
 bwi_fwimage_is_valid(struct bwi_softc *sc, const struct fw_image *fw,
     uint8_t fw_type)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	const struct bwi_fwhdr *hdr;
 	struct ifnet *ifp = &sc->sc_ic.ic_if;
@@ -1205,7 +1203,7 @@
 int
 bwi_mac_fw_alloc(struct bwi_mac *mac)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_softc *sc = mac->mac_sc;
 	struct ifnet *ifp = &sc->sc_ic.ic_if;
@@ -1296,7 +1294,7 @@
 			return EINVAL;
 	}
 back:
-	return 0;
+	return (0);
 #endif
 	return (0);
 }
@@ -1331,7 +1329,7 @@
 int
 bwi_mac_fw_load(struct bwi_mac *mac)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #ifdef notyet
 	struct bwi_softc *sc = mac->mac_sc;
 	struct ifnet *ifp = &sc->sc_ic.ic_if;
@@ -1466,7 +1464,7 @@
 int
 bwi_mac_fw_load_iv(struct bwi_mac *mac, const struct fw_image *fw)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_softc *sc = mac->mac_sc;
 	struct ifnet *ifp = &sc->sc_ic.ic_if;
@@ -1636,9 +1634,8 @@
 			pre_tbtt = 100;
 		else
 			pre_tbtt = 50;
-	} else {
+	} else
 		pre_tbtt = 2;
-	}
 	CSR_WRITE_2(sc, BWI_MAC_PRE_TBTT, pre_tbtt);
 }

@@ -1740,7 +1737,7 @@
 void
 bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rateset *rs)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0

 	int i;
@@ -1938,7 +1935,7 @@
 void
 bwi_mac_updateslot(struct bwi_mac *mac, int shslot)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	uint16_t slot_time;

@@ -2638,9 +2635,8 @@
 		PHY_WRITE(mac, 0x22, 0x1bc3);
 		PHY_WRITE(mac, 0x23, 0x6f9);
 		PHY_WRITE(mac, 0x24, 0x37e);
-	} else {
+	} else
 		PHY_WRITE(mac, 0x26, 0xcc00);
-	}
 	PHY_WRITE(mac, 0x30, 0xc6);

 	CSR_WRITE_2(sc, BWI_BPHY_CTRL, BWI_BPHY_CTRL_INIT);
@@ -2821,9 +2817,8 @@
 			bwi_rf_set_nrssi_thr(mac);
 		}
 		bwi_mac_init_tpctl_11bg(mac);
-	} else {
+	} else
 		CSR_WRITE_2(sc, BWI_BBP_ATTEN, 0);
-	}
 }

 #define N(arr)	(int)(sizeof(arr) / sizeof(arr[0]))
@@ -3306,16 +3301,6 @@
 {
 #define SAVE_PHY_MAX	15
 #define SAVE_RF_MAX	3
-
-	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
-	{ 0x52, 0x43, 0x7a };
-	static const uint16_t save_phy_regs[SAVE_PHY_MAX] = {
-		0x0429, 0x0001, 0x0811, 0x0812,
-		0x0814, 0x0815, 0x005a, 0x0059,
-		0x0058, 0x000a, 0x0003, 0x080f,
-		0x0810, 0x002b, 0x0015
-	};
-
 	struct bwi_softc *sc;
 	struct bwi_phy *phy = &mac->mac_phy;
 	struct bwi_rf *rf = &mac->mac_rf;
@@ -3323,6 +3308,15 @@
 	uint16_t save_rf[SAVE_RF_MAX];
 	uint16_t trsw;
 	int i, j, loop1_max, loop1, loop2;
+
+	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
+	    { 0x52, 0x43, 0x7a };
+	static const uint16_t save_phy_regs[SAVE_PHY_MAX] = {
+	    0x0429, 0x0001, 0x0811, 0x0812,
+	    0x0814, 0x0815, 0x005a, 0x0059,
+	    0x0058, 0x000a, 0x0003, 0x080f,
+	    0x0810, 0x002b, 0x0015
+	};

 	sc = mac->mac_sc;

@@ -3687,14 +3681,6 @@
 #define SAVE_RF_MAX		3
 #define SAVE_PHY_COMM_MAX	4
 #define SAVE_PHY_11G_MAX	6
-
-	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
-	{ 0x0043, 0x0051, 0x0052 };
-	static const uint16_t save_phy_regs_comm[SAVE_PHY_COMM_MAX] =
-	{ 0x0015, 0x005a, 0x0059, 0x0058 };
-	static const uint16_t save_phy_regs_11g[SAVE_PHY_11G_MAX] =
-	{ 0x0811, 0x0812, 0x0814, 0x0815, 0x0429, 0x0802 };
-
 	uint16_t save_rf[SAVE_RF_MAX];
 	uint16_t save_phy_comm[SAVE_PHY_COMM_MAX];
 	uint16_t save_phy_11g[SAVE_PHY_11G_MAX];
@@ -3708,6 +3694,13 @@
 	struct bwi_rf *rf = &mac->mac_rf;
 	int i;

+	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
+	    { 0x0043, 0x0051, 0x0052 };
+	static const uint16_t save_phy_regs_comm[SAVE_PHY_COMM_MAX] =
+	    { 0x0015, 0x005a, 0x0059, 0x0058 };
+	static const uint16_t save_phy_regs_11g[SAVE_PHY_11G_MAX] =
+	    { 0x0811, 0x0812, 0x0814, 0x0815, 0x0429, 0x0802 };
+
 	/*
 	 * Save registers for later restoring
 	 */
@@ -3725,7 +3718,7 @@
 	} else if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) {
 		for (i = 0; i < SAVE_PHY_11G_MAX; ++i) {
 			save_phy_11g[i] =
-				PHY_READ(mac, save_phy_regs_11g[i]);
+			    PHY_READ(mac, save_phy_regs_11g[i]);
 		}

 		PHY_SETBITS(mac, 0x814, 0x3);
@@ -3787,9 +3780,9 @@
 	PHY_WRITE(mac, 0x15, 0xbfa0);

 	RF_SETBITS(mac, 0x51, 0x4);
-	if (rf->rf_rev == 8) {
+	if (rf->rf_rev == 8)
 		RF_WRITE(mac, 0x43, 0x1f);
-	} else {
+	else {
 		RF_WRITE(mac, 0x52, 0);
 		RF_FILT_SETBITS(mac, 0x43, 0xfff0, 0x9);
 	}
@@ -3946,13 +3939,14 @@
 uint16_t
 bwi_rf_calibval(struct bwi_mac *mac)
 {
+	uint16_t val, calib;
+	int idx;
+
 	/* http://bcm-specs.sipsolutions.net/RCCTable */
 	static const uint16_t rf_calibvals[] = {
 		0x2, 0x3, 0x1, 0xf, 0x6, 0x7, 0x5, 0xf,
 		0xa, 0xb, 0x9, 0xf, 0xe, 0xf, 0xd, 0xf
 	};
-	uint16_t val, calib;
-	int idx;

 	val = RF_READ(mac, BWI_RFR_BBP_ATTEN);
 	idx = __SHIFTOUT(val, BWI_RFR_BBP_ATTEN_CALIB_IDX);
@@ -3994,7 +3988,7 @@
 		int32_t q, d;

 		q = _bwi_adjust_devide(
-			f * 4096 - _bwi_adjust_devide(m2 * f, 16) * f, 2048);
+		    f * 4096 - _bwi_adjust_devide(m2 * f, 16) * f, 2048);
 		d = abs(q - f);
 		f = q;

@@ -4032,10 +4026,10 @@
 	val = bwi_read_sprom(sc, BWI_SPROM_MAX_TXPWR);
 	if (phy->phy_mode == IEEE80211_MODE_11A) {
 		rf->rf_txpower_max = __SHIFTOUT(val,
-				     BWI_SPROM_MAX_TXPWR_MASK_11A);
+		    BWI_SPROM_MAX_TXPWR_MASK_11A);
 	} else {
 		rf->rf_txpower_max = __SHIFTOUT(val,
-				     BWI_SPROM_MAX_TXPWR_MASK_11BG);
+		    BWI_SPROM_MAX_TXPWR_MASK_11BG);

 		if ((sc->sc_card_flags & BWI_CARD_F_PA_GPIO9) &&
 		    phy->phy_mode == IEEE80211_MODE_11G)
@@ -4093,7 +4087,6 @@

 #define IS_VALID_PA_PARAM(p)	((p) != 0 && (p) != -1)
 #define N(arr)	(int)(sizeof(arr) / sizeof(arr[0]))
-
 	/*
 	 * Extract PA parameters
 	 */
@@ -4132,7 +4125,6 @@
 			goto back;
 		}
 	}
-
 #undef N

 	/*
@@ -4272,9 +4264,8 @@
 		PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa2);
 		DELAY(2);
 		PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa3);
-	} else {
+	} else
 		PHY_WRITE(mac, 0x15, devi_ctrl | 0xefa0);
-	}

 	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		tpctl = NULL;
@@ -4380,18 +4371,17 @@
 {
 #define RF_ATTEN_LISTSZ	14
 #define BBP_ATTEN_MAX	4	/* half */
-
-	static const int rf_atten_list[RF_ATTEN_LISTSZ] =
-	{ 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 1, 2, 3, 4 };
-	static const int rf_atten_init_list[RF_ATTEN_LISTSZ] =
-        { 0, 3, 1, 5, 7, 3, 2, 0, 4, 6, -1, -1, -1, -1 };
-	static const int rf_lo_measure_order[RF_ATTEN_LISTSZ] =
-	{ 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 10, 11, 12, 13 };
-
 	struct ifnet *ifp = &mac->mac_sc->sc_ic.ic_if;
 	struct bwi_rf_lo lo_save, *lo;
 	uint8_t devi_ctrl = 0;
 	int idx, adj_rf7a = 0;
+
+	static const int rf_atten_list[RF_ATTEN_LISTSZ] =
+	    { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 1, 2, 3, 4 };
+	static const int rf_atten_init_list[RF_ATTEN_LISTSZ] =
+            { 0, 3, 1, 5, 7, 3, 2, 0, 4, 6, -1, -1, -1, -1 };
+	static const int rf_lo_measure_order[RF_ATTEN_LISTSZ] =
+	    { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 10, 11, 12, 13 };

 	bzero(&lo_save, sizeof(lo_save));
 	for (idx = 0; idx < RF_ATTEN_LISTSZ; ++idx) {
@@ -4475,7 +4465,7 @@

 void
 bwi_rf_lo_measure(struct bwi_mac *mac, const struct bwi_rf_lo *src_lo,
-	struct bwi_rf_lo *dst_lo, uint8_t devi_ctrl)
+    struct bwi_rf_lo *dst_lo, uint8_t devi_ctrl)
 {
 #define LO_ADJUST_MIN	1
 #define LO_ADJUST_MAX	8
@@ -4567,12 +4557,6 @@
 {
 #define SAVE_RF_MAX	3
 #define SAVE_PHY_MAX	8
-
-	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
-	{ 0x7a, 0x52, 0x43 };
-	static const uint16_t save_phy_regs[SAVE_PHY_MAX] =
-	{ 0x30, 0x26, 0x15, 0x2a, 0x20, 0x5a, 0x59, 0x58 };
-
 	struct bwi_softc *sc = mac->mac_sc;
 	struct bwi_rf *rf = &mac->mac_rf;
 	struct bwi_phy *phy = &mac->mac_phy;
@@ -4582,6 +4566,11 @@
 	int16_t nrssi[2];
 	int i;

+	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
+	    { 0x7a, 0x52, 0x43 };
+	static const uint16_t save_phy_regs[SAVE_PHY_MAX] =
+	    { 0x30, 0x26, 0x15, 0x2a, 0x20, 0x5a, 0x59, 0x58 };
+
 	/*
 	 * Save RF/PHY registers for later restoration
 	 */
@@ -4681,9 +4670,15 @@
 #define SAVE_RF_MAX		2
 #define SAVE_PHY_COMM_MAX	10
 #define SAVE_PHY6_MAX		8
-
-	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
-	{ 0x7a, 0x43 };
+	struct bwi_phy *phy = &mac->mac_phy;
+	uint16_t save_rf[SAVE_RF_MAX];
+	uint16_t save_phy_comm[SAVE_PHY_COMM_MAX];
+	uint16_t save_phy6[SAVE_PHY6_MAX];
+	uint16_t rf7b = 0xffff;
+	int16_t nrssi;
+	int i, phy6_idx = 0;
+
+	static const uint16_t save_rf_regs[SAVE_RF_MAX] = { 0x7a, 0x43 };
 	static const uint16_t save_phy_comm_regs[SAVE_PHY_COMM_MAX] = {
 		0x0001, 0x0811, 0x0812, 0x0814,
 		0x0815, 0x005a, 0x0059, 0x0058,
@@ -4693,14 +4688,6 @@
 		0x002e, 0x002f, 0x080f, 0x0810,
 		0x0801, 0x0060, 0x0014, 0x0478
 	};
-
-	struct bwi_phy *phy = &mac->mac_phy;
-	uint16_t save_rf[SAVE_RF_MAX];
-	uint16_t save_phy_comm[SAVE_PHY_COMM_MAX];
-	uint16_t save_phy6[SAVE_PHY6_MAX];
-	uint16_t rf7b = 0xffff;
-	int16_t nrssi;
-	int i, phy6_idx = 0;

 	for (i = 0; i < SAVE_PHY_COMM_MAX; ++i)
 		save_phy_comm[i] = PHY_READ(mac, save_phy_comm_regs[i]);
@@ -4798,7 +4785,7 @@
 	if (phy->phy_rev >= 6) {
 		for (phy6_idx = 0; phy6_idx < 4; ++phy6_idx) {
 			PHY_WRITE(mac, save_phy6_regs[phy6_idx],
-				  save_phy6[phy6_idx]);
+			    save_phy6[phy6_idx]);
 		}
 	}

@@ -4817,7 +4804,7 @@
 	if (phy->phy_rev >= 6) {
 		for (; phy6_idx < SAVE_PHY6_MAX; ++phy6_idx) {
 			PHY_WRITE(mac, save_phy6_regs[phy6_idx],
-				  save_phy6[phy6_idx]);
+			    save_phy6[phy6_idx]);
 		}
 	}

@@ -4836,16 +4823,6 @@
 #define SAVE_RF_MAX		3
 #define SAVE_PHY_COMM_MAX	4
 #define SAVE_PHY3_MAX		8
-
-	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
-	{ 0x7a, 0x52, 0x43 };
-	static const uint16_t save_phy_comm_regs[SAVE_PHY_COMM_MAX] =
-	{ 0x15, 0x5a, 0x59, 0x58 };
-	static const uint16_t save_phy3_regs[SAVE_PHY3_MAX] = {
-		0x002e, 0x002f, 0x080f, 0x0810,
-		0x0801, 0x0060, 0x0014, 0x0478
-	};
-
 	struct bwi_softc *sc = mac->mac_sc;
 	struct bwi_phy *phy = &mac->mac_phy;
 	struct bwi_rf *rf = &mac->mac_rf;
@@ -4857,6 +4834,15 @@
 	int16_t nrssi[2];
 	int i, phy3_idx = 0;

+	static const uint16_t save_rf_regs[SAVE_RF_MAX] =
+	    { 0x7a, 0x52, 0x43 };
+	static const uint16_t save_phy_comm_regs[SAVE_PHY_COMM_MAX] =
+	    { 0x15, 0x5a, 0x59, 0x58 };
+	static const uint16_t save_phy3_regs[SAVE_PHY3_MAX] = {
+		0x002e, 0x002f, 0x080f, 0x0810,
+		0x0801, 0x0060, 0x0014, 0x0478
+	};
+
 	if (rf->rf_rev >= 9)
 		return;
 	else if (rf->rf_rev == 8)
@@ -4890,9 +4876,8 @@
 		    phy->phy_rev == 7) {
 			PHY_SETBITS(mac, 0x478, 0x100);
 			PHY_SETBITS(mac, 0x810, 0x40);
-		} else if (phy->phy_rev == 3 || phy->phy_rev == 5) {
+		} else if (phy->phy_rev == 3 || phy->phy_rev == 5)
 			PHY_CLRBITS(mac, 0x810, 0x40);
-		}

 		PHY_SETBITS(mac, 0x60, 0x40);
 		PHY_SETBITS(mac, 0x14, 0x200);
@@ -4997,7 +4982,7 @@
 	if (phy->phy_rev >= 3) {
 		for (; phy3_idx < SAVE_PHY3_MAX; ++phy3_idx) {
 			PHY_WRITE(mac, save_phy3_regs[phy3_idx],
-				  save_phy3[phy3_idx]);
+			    save_phy3[phy3_idx]);
 		}
 	}

@@ -5139,11 +5124,9 @@

 #define NRSSI_THR1_MASK	__BITS(5, 0)
 #define NRSSI_THR2_MASK	__BITS(11, 6)
-
 	thr = __SHIFTIN((uint32_t)thr1, NRSSI_THR1_MASK) |
-	      __SHIFTIN((uint32_t)thr2, NRSSI_THR2_MASK);
+	    __SHIFTIN((uint32_t)thr2, NRSSI_THR2_MASK);
 	PHY_FILT_SETBITS(mac, BWI_PHYR_NRSSI_THR_11G, 0xf000, thr);
-
 #undef NRSSI_THR1_MASK
 #undef NRSSI_THR2_MASK
 }
@@ -5159,7 +5142,7 @@
 		int i;

 		val = __SHIFTIN(BWI_INVALID_TSSI, BWI_LO_TSSI_MASK) |
-		      __SHIFTIN(BWI_INVALID_TSSI, BWI_HI_TSSI_MASK);
+		    __SHIFTIN(BWI_INVALID_TSSI, BWI_HI_TSSI_MASK);

 		for (i = 0; i < 2; ++i) {
 			MOBJ_WRITE_2(mac, BWI_COMM_MOBJ,
@@ -5331,7 +5314,6 @@
 	else if (pwr_idx >= BWI_TSSI_MAX)
 		pwr_idx = BWI_TSSI_MAX - 1;
 #endif
-
 	*txpwr = rf->rf_txpower_map[pwr_idx];

 	return (0);
@@ -5356,10 +5338,10 @@
 	addr_hi = __SHIFTOUT(paddr, BWI_DESC32_A_FUNC_MASK);

 	addr = __SHIFTIN(addr_lo, BWI_DESC32_A_ADDR_MASK) |
-	       __SHIFTIN(BWI_DESC32_A_FUNC_TXRX, BWI_DESC32_A_FUNC_MASK);
+	    __SHIFTIN(BWI_DESC32_A_FUNC_TXRX, BWI_DESC32_A_FUNC_MASK);

 	ctrl = __SHIFTIN(buf_len, BWI_DESC32_C_BUFLEN_MASK) |
-	       __SHIFTIN(addr_hi, BWI_DESC32_C_ADDRHI_MASK);
+	     __SHIFTIN(addr_hi, BWI_DESC32_C_ADDRHI_MASK);
 	if (desc_idx == ndesc - 1)
 		ctrl |= BWI_DESC32_C_EOR;
 	if (tx) {
@@ -5462,7 +5444,7 @@

 	/* Get locale */
 	sc->sc_locale = __SHIFTOUT(bwi_read_sprom(sc, BWI_SPROM_CARD_INFO),
-				   BWI_SPROM_CARD_INFO_LOCALE);
+	    BWI_SPROM_CARD_INFO_LOCALE);
 	DPRINTF(1, "%s: locale: %d\n", sc->sc_dev.dv_xname, sc->sc_locale);

 	/*
@@ -5479,12 +5461,11 @@
 			ic->ic_phytype = IEEE80211_T_DS;
 		} else {
 			chan_flags = IEEE80211_CHAN_CCK |
-				     IEEE80211_CHAN_OFDM |
-				     IEEE80211_CHAN_DYN |
-				     IEEE80211_CHAN_2GHZ;
+			    IEEE80211_CHAN_OFDM |
+			    IEEE80211_CHAN_DYN |
+			    IEEE80211_CHAN_2GHZ;
 			ic->ic_phytype = IEEE80211_T_OFDM;
-			ic->ic_sup_rates[IEEE80211_MODE_11G] =
-				bwi_rateset_11g;
+			ic->ic_sup_rates[IEEE80211_MODE_11G] = bwi_rateset_11g;
 		}

 		/* XXX depend on locale */
@@ -5507,9 +5488,8 @@
 		/* TODO:11A */
 		error = ENXIO;
 		goto fail;
-	} else {
+	} else
 		panic("unknown phymode %d\n", phy->phy_mode);
-	}

 	sc->sc_fw_version = BWI_FW_VERSION3;
 	sc->sc_dwell_time = 200;
@@ -5566,7 +5546,7 @@
 	uint32_t gpio_in, gpio_out, gpio_en;
 	uint16_t status;

-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);

 	gpio_in = (sc->sc_conf_read)(sc, BWI_PCIR_GPIO_IN);
 	if (gpio_in & BWI_PCIM_GPIO_PWR_ON)
@@ -5735,7 +5715,7 @@
 		}

 		info = __SHIFTIN(revid, BWI_INFO_BBPREV_MASK) |
-		       __SHIFTIN(0, BWI_INFO_BBPPKG_MASK);
+		    __SHIFTIN(0, BWI_INFO_BBPPKG_MASK);
 	}

 	/*
@@ -5764,7 +5744,6 @@
 	sc->sc_bbp_pkg = __SHIFTOUT(info, BWI_INFO_BBPPKG_MASK);
 	DPRINTF(1, "%s: BBP id 0x%04x, BBP rev 0x%x, BBP pkg %d\n",
 	    sc->sc_dev.dv_xname, sc->sc_bbp_id, sc->sc_bbp_rev, sc->sc_bbp_pkg);
-
 	DPRINTF(1, "%s: nregwin %d, cap 0x%08x\n",
 	    sc->sc_dev.dv_xname, nregwin, sc->sc_cap);

@@ -5890,8 +5869,10 @@
 			 * Set service timeout and request timeout
 			 */
 			CSR_SETBITS_4(sc, BWI_CONF_LO,
-			__SHIFTIN(BWI_CONF_LO_SERVTO, BWI_CONF_LO_SERVTO_MASK) |
-			__SHIFTIN(BWI_CONF_LO_REQTO, BWI_CONF_LO_REQTO_MASK));
+			    __SHIFTIN(BWI_CONF_LO_SERVTO,
+			    BWI_CONF_LO_SERVTO_MASK) |
+			    __SHIFTIN(BWI_CONF_LO_REQTO,
+			    BWI_CONF_LO_REQTO_MASK));

 			/*
 			 * If there is common regwin, we switch to that regwin
@@ -5941,8 +5922,8 @@
 	    sc->sc_pci_revid > 0x40)
 		sc->sc_card_flags |= BWI_CARD_F_PA_GPIO9;

-	DPRINTF(1, "%s: card flags 0x%04x\n", sc->sc_dev.dv_xname,
-	    sc->sc_card_flags);
+	DPRINTF(1, "%s: card flags 0x%04x\n",
+	    sc->sc_dev.dv_xname, sc->sc_card_flags);
 }

 void
@@ -5989,9 +5970,9 @@
 		val = CSR_READ_4(sc, BWI_CLOCK_CTRL);

 		src = __SHIFTOUT(val, BWI_CLOCK_CTRL_CLKSRC);
-		if (src == BWI_CLKSRC_LP_OSC) {
+		if (src == BWI_CLKSRC_LP_OSC)
 			div = 1;
-		} else {
+		else {
 			div = (__SHIFTOUT(val, BWI_CLOCK_CTRL_FDIV) + 1) << 2;

 			/* Unknown source */
@@ -6015,8 +5996,8 @@
 	freq->clkfreq_min = bwi_clkfreq[src].freq_min / div;
 	freq->clkfreq_max = bwi_clkfreq[src].freq_max / div;

-	DPRINTF(1, "%s: clkfreq min %u, max %u\n", sc->sc_dev.dv_xname,
-		freq->clkfreq_min, freq->clkfreq_max);
+	DPRINTF(1, "%s: clkfreq min %u, max %u\n",
+	    sc->sc_dev.dv_xname, freq->clkfreq_min, freq->clkfreq_max);
 }

 int
@@ -6098,9 +6079,9 @@
 	}

 	if (sc->sc_cap & BWI_CAP_CLKMODE) {
-		if (com->rw_rev >= 10) {
+		if (com->rw_rev >= 10)
 			CSR_FILT_SETBITS_4(sc, BWI_CLOCK_INFO, 0xffff, 0x40000);
-		} else {
+		else {
 			struct bwi_clock_freq freq;

 			bwi_get_clock_freq(sc, &freq);
@@ -6278,8 +6259,7 @@
 	struct bwi_txbuf_data *tbd = &sc->sc_tx_bdata[BWI_TX_DATA_RING];
 	int trans, idx;

-	if ((ifp->if_flags & IFF_OACTIVE) ||
-	    (ifp->if_flags & IFF_RUNNING) == 0)
+	if ((ifp->if_flags & IFF_OACTIVE) || (ifp->if_flags & IFF_RUNNING) == 0)
 		return;

 	trans = 0;
@@ -6328,22 +6308,18 @@
 			}

 			/* TODO: PS */
-
 #if NBPFILTER > 0
 			if (ifp->if_bpf != NULL)
 				bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
 #endif
-
 			m = ieee80211_encap(ifp, m, &ni);
 			if (m == NULL)
 				continue;
 		}
-
 #if NBPFILTER > 0
 		if (ic->ic_rawbpf != NULL)
 			bpf_mtap(ic->ic_rawbpf, m, BPF_DIRECTION_OUT);
 #endif
-
 		wh = mtod(m, struct ieee80211_frame *);
 		if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
 			m = ieee80211_wep_crypt(ifp, m, 1);
@@ -6397,10 +6373,10 @@
 			    sc->sc_dev.dv_xname);
 			ifp->if_oerrors++;
 			/* TODO */
-		} else {
+		} else
 			ifp->if_timer = 1;
-		}
-	}
+	}
+
 	ieee80211_watchdog(ifp);
 }

@@ -6591,9 +6567,8 @@

 		/* Initial TX power calibration */
 		bwi_mac_calibrate_txpower(mac);
-	} else {
+	} else
 		bwi_set_bssid(sc, bwi_zero_addr);
-	}

 back:
 	error = sc->sc_newstate(ic, nstate, arg);
@@ -6627,7 +6602,7 @@
 int
 bwi_dma_alloc(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	int error, i, has_txstats;
 	bus_addr_t lowaddr = 0;
@@ -6712,7 +6687,6 @@
 	}

 #define TXRX_CTRL(idx)	(BWI_TXRX_CTRL_BASE + (idx) * txrx_ctrl_step)
-
 	/*
 	 * Create TX ring DMA stuffs
 	 */
@@ -6729,8 +6703,7 @@

 	for (i = 0; i < BWI_TX_NRING; ++i) {
 		error = bwi_dma_ring_alloc(sc, sc->sc_txring_dtag,
-					   &sc->sc_tx_rdata[i], tx_ring_sz,
-					   TXRX_CTRL(i));
+		    &sc->sc_tx_rdata[i], tx_ring_sz, TXRX_CTRL(i));
 		if (error) {
 			DPRINTF(1, "%s: %dth TX ring DMA alloc failed\n",
 			    sc->sc_dev.dv_xname, i);
@@ -6768,10 +6741,9 @@
 			return (error);
 		}
 	}
-
 #undef TXRX_CTRL

-	return bwi_dma_mbuf_create(sc);
+	return (bwi_dma_mbuf_create(sc));
 #endif
 	return (0);
 }
@@ -6779,7 +6751,7 @@
 void
 bwi_dma_free(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	if (sc->sc_txring_dtag != NULL) {
 		int i;
@@ -6819,16 +6791,14 @@

 int
 bwi_dma_ring_alloc(struct bwi_softc *sc, bus_dma_tag_t dtag,
-		   struct bwi_ring_data *rd, bus_size_t size,
-		   uint32_t txrx_ctrl)
-{
-	printf("%s\n", __func__);
+    struct bwi_ring_data *rd, bus_size_t size, uint32_t txrx_ctrl)
+{
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	int error;

 	error = bus_dmamem_alloc(dtag, &rd->rdata_desc,
-				 BUS_DMA_WAITOK | BUS_DMA_ZERO,
-				 &rd->rdata_dmap);
+	    BUS_DMA_WAITOK | BUS_DMA_ZERO, &rd->rdata_dmap);
 	if (error) {
 		DPRINTF(1, "%s: can't allocate DMA mem\n", sc->sc_dev.dv_xname);
 		return (error);
@@ -6852,9 +6822,9 @@

 int
 bwi_dma_txstats_alloc(struct bwi_softc *sc, uint32_t ctrl_base,
-		      bus_size_t desc_sz)
-{
-	printf("%s\n", __func__);
+    bus_size_t desc_sz)
+{
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_txstats_data *st;
 	bus_size_t dma_size;
@@ -6945,7 +6915,8 @@
 	}

 	st->stats_ctrl_base = ctrl_base;
-	return 0;
+
+	return (0);
 #endif
 	return (0);
 }
@@ -6953,7 +6924,7 @@
 void
 bwi_dma_txstats_free(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_txstats_data *st;

@@ -6988,7 +6959,7 @@
 int
 bwi_dma_mbuf_create(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_rxbuf_data *rbd = &sc->sc_rx_bdata;
 	int i, j, k, ntx, error;
@@ -7021,11 +6992,10 @@
 			if (error) {
 				DPRINTF(sc, "%s: can't create %dth tbd, %dth "
 				    "DMA map\n", sc->sc_dev.dv_xname), i, j);
-
 				ntx = i;
 				for (k = 0; k < j; ++k) {
 					bus_dmamap_destroy(sc->sc_buf_dtag,
-						tbd->tbd_buf[k].tb_dmap);
+					    tbd->tbd_buf[k].tb_dmap);
 				}
 				goto fail;
 			}
@@ -7036,8 +7006,7 @@
 	/*
 	 * Create RX mbuf DMA map and a spare DMA map
 	 */
-	error = bus_dmamap_create(sc->sc_buf_dtag, 0,
-				  &rbd->rbd_tmp_dmap);
+	error = bus_dmamap_create(sc->sc_buf_dtag, 0, &rbd->rbd_tmp_dmap);
 	if (error) {
 		DPRINTF(1, "%s: can't create spare RX buf DMA map\n",
 		    sc->sc_dev.dv_xname);
@@ -7064,7 +7033,8 @@
 	return 0;
 fail:
 	bwi_dma_mbuf_destroy(sc, ntx, 0);
-	return error;
+
+	return (error);
 #endif
 	return (1);
 }
@@ -7072,7 +7042,7 @@
 void
 bwi_dma_mbuf_destroy(struct bwi_softc *sc, int ntx, int nrx)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	int i, j;

@@ -7132,7 +7102,7 @@
 int
 bwi_init_tx_ring32(struct bwi_softc *sc, int ring_idx)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_ring_data *rd;
 	struct bwi_txbuf_data *tbd;
@@ -7161,14 +7131,14 @@
 	      BWI_TXRX32_CTRL_ENABLE;
 	CSR_WRITE_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_CTRL, val);

-	return 0;
+	return (0);
 #endif
 	return (1);
 }

 void
 bwi_init_rxdesc_ring32(struct bwi_softc *sc, uint32_t ctrl_base,
-		       bus_addr_t paddr, int hdr_size, int ndesc)
+    bus_addr_t paddr, int hdr_size, int ndesc)
 {
 	uint32_t val, addr_hi, addr_lo;

@@ -7192,7 +7162,7 @@
 int
 bwi_init_rx_ring32(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_ring_data *rd = &sc->sc_rx_rdata;
 	int i, error;
@@ -7208,11 +7178,11 @@
 		}
 	}
 	bus_dmamap_sync(sc->sc_rxring_dtag, rd->rdata_dmap,
-			BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREWRITE);

 	bwi_init_rxdesc_ring32(sc, rd->rdata_txrx_ctrl, rd->rdata_paddr,
-			       sizeof(struct bwi_rxbuf_hdr), BWI_RX_NDESC);
-	return 0;
+	    sizeof(struct bwi_rxbuf_hdr), BWI_RX_NDESC);
+	return (0);
 #endif
 	return (1);
 }
@@ -7220,7 +7190,7 @@
 int
 bwi_init_txstats32(struct bwi_softc *sc)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_txstats_data *st = sc->sc_txstats;
 	bus_addr_t stats_paddr;
@@ -7238,11 +7208,12 @@
 		stats_paddr += sizeof(struct bwi_txstats);
 	}
 	bus_dmamap_sync(st->stats_ring_dtag, st->stats_ring_dmap,
-			BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREWRITE);

 	bwi_init_rxdesc_ring32(sc, st->stats_ctrl_base,
-			       st->stats_ring_paddr, 0, BWI_TXSTATS_NDESC);
-	return 0;
+	    st->stats_ring_paddr, 0, BWI_TXSTATS_NDESC);
+
+	return (0);
 #endif
 	return (1);
 }
@@ -7290,21 +7261,21 @@

 void
 bwi_setup_rx_desc64(struct bwi_softc *sc, int buf_idx, bus_addr_t paddr,
-		    int buf_len)
+    int buf_len)
 {
 	/* TODO:64 */
 }

 void
 bwi_setup_tx_desc64(struct bwi_softc *sc, struct bwi_ring_data *rd,
-		    int buf_idx, bus_addr_t paddr, int buf_len)
+    int buf_idx, bus_addr_t paddr, int buf_len)
 {
 	/* TODO:64 */
 }

 void
 bwi_dma_buf_addr(void *arg, bus_dma_segment_t *seg, int nseg,
-		 bus_size_t mapsz, int error)
+    bus_size_t mapsz, int error)
 {
         if (!error) {
 		KASSERT(nseg == 1, ("too many segments(%d)\n", nseg));
@@ -7315,7 +7286,7 @@
 int
 bwi_newbuf(struct bwi_softc *sc, int buf_idx, int init)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_rxbuf_data *rbd = &sc->sc_rx_bdata;
 	struct bwi_rxbuf *rxbuf = &rbd->rbd_buf[buf_idx];
@@ -7393,7 +7364,7 @@

 void
 bwi_set_addr_filter(struct bwi_softc *sc, uint16_t addr_ofs,
-		    const uint8_t *addr)
+    const uint8_t *addr)
 {
 	int i;

@@ -7404,7 +7375,7 @@
 		uint16_t addr_val;

 		addr_val = (uint16_t)addr[i * 2] |
-			   (((uint16_t)addr[(i * 2) + 1]) << 8);
+		    (((uint16_t)addr[(i * 2) + 1]) << 8);
 		CSR_WRITE_2(sc, BWI_ADDR_FILTER_DATA, addr_val);
 	}
 }
@@ -7443,7 +7414,7 @@
 void
 bwi_rxeof(struct bwi_softc *sc, int end_idx)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_ring_data *rd = &sc->sc_rx_rdata;
 	struct bwi_rxbuf_data *rbd = &sc->sc_rx_bdata;
@@ -7502,7 +7473,7 @@
 		ni = ieee80211_find_rxnode(ic, wh);

 		ieee80211_input(ic, m, ni, hdr->rxh_rssi,
-				letoh16(hdr->rxh_tsf));
+		    letoh16(hdr->rxh_tsf));

 		ieee80211_free_node(ni);
 next:
@@ -7511,7 +7482,7 @@

 	rbd->rbd_idx = idx;
 	bus_dmamap_sync(sc->sc_rxring_dtag, rd->rdata_dmap,
-			BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREWRITE);
 #endif
 }

@@ -7593,7 +7564,7 @@
 void
 bwi_free_tx_ring32(struct bwi_softc *sc, int ring_idx)
 {
-	printf("%s\n", __func__);
+	DPRINTF(1, "%s\n", __func__);
 #if 0
 	struct bwi_ring_data *rd;
 	struct bwi_txbuf_data *tbd;
@@ -7605,7 +7576,6 @@
 	tbd = &sc->sc_tx_bdata[ring_idx];

 #define NRETRY 10
-
 	for (i = 0; i < NRETRY; ++i) {
 		val = CSR_READ_4(sc, rd->rdata_txrx_ctrl + BWI_TX32_STATUS);
 		state = __SHIFTOUT(val, BWI_TX32_STATUS_STATE_MASK);
@@ -7633,7 +7603,6 @@
 	if (i == NRETRY)
 		DPRINTF(1, "%s: reset TX ring (%d) timed out\n",
 		    sc->sc_dev.dv_xname, ring_idx);
-
 #undef NRETRY

 	DELAY(1000);
@@ -7766,7 +7735,7 @@

 int
 bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m,
-	  struct ieee80211_node *ni)
+    struct ieee80211_node *ni)
 {
 	printf("%s\n", __func__);
 #if 0
@@ -7853,20 +7822,20 @@

 		ack_rate = ieee80211_ack_rate(ni, rate_fb);
 		dur = ieee80211_txtime(ni,
-		sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN,
-		ack_rate, ic->ic_flags & ~IEEE80211_F_SHPREAMBLE);
+		    sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN,
+		    ack_rate, ic->ic_flags & ~IEEE80211_F_SHPREAMBLE);

 		hdr->txh_fb_duration = htole16(dur);
 	}

 	hdr->txh_id = __SHIFTIN(BWI_TX_DATA_RING, BWI_TXH_ID_RING_MASK) |
-		      __SHIFTIN(idx, BWI_TXH_ID_IDX_MASK);
+	    __SHIFTIN(idx, BWI_TXH_ID_IDX_MASK);

 	bwi_plcp_header(hdr->txh_plcp, pkt_len, rate);
 	bwi_plcp_header(hdr->txh_fb_plcp, pkt_len, rate_fb);

 	phy_ctrl = __SHIFTIN(mac->mac_rf.rf_ant_mode,
-			     BWI_TXH_PHY_C_ANTMODE_MASK);
+	    BWI_TXH_PHY_C_ANTMODE_MASK);
 	if (ieee80211_rate2modtype(rate) == IEEE80211_MODTYPE_OFDM)
 		phy_ctrl |= BWI_TXH_PHY_C_OFDM;
 	else if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && rate != (2 * 1))
@@ -7887,7 +7856,7 @@

 	/* DMA load */
 	error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m,
-				     bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT);
+	    bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT);
 	if (error && error != EFBIG) {
 		DPRINTF(1, "%s: can't load TX buffer (1) %d\n",
 		    sc->sc_dev.dv_xname, error);
@@ -7908,8 +7877,7 @@
 		}

 		error = bus_dmamap_load_mbuf(sc->sc_buf_dtag, tb->tb_dmap, m,
-					     bwi_dma_buf_addr, &paddr,
-					     BUS_DMA_NOWAIT);
+		    bwi_dma_buf_addr, &paddr, BUS_DMA_NOWAIT);
 		if (error) {
 			DPRINTF(1, "%s: can't load TX buffer (2) %d\n",
 			    sc->sc_dev.dv_xname, error);
@@ -8191,8 +8159,8 @@
 	val = CSR_READ_4(sc, BWI_STATE_LO);

 	if ((val & (BWI_STATE_LO_CLOCK |
-		    BWI_STATE_LO_RESET |
-		    disable_bits)) == BWI_STATE_LO_CLOCK) {
+	    BWI_STATE_LO_RESET |
+	    disable_bits)) == BWI_STATE_LO_CLOCK) {
 		DPRINTF(1, "%s: %s is enabled\n", sc->sc_dev.dv_xname,
 		    bwi_regwin_name(rw));
 		return (1);
@@ -8261,8 +8229,8 @@
 	 * Reset and disable regwin with gated clock
 	 */
 	state_lo = BWI_STATE_LO_RESET | disable_bits |
-		   BWI_STATE_LO_CLOCK | BWI_STATE_LO_GATED_CLOCK |
-		   __SHIFTIN(flags, BWI_STATE_LO_FLAGS_MASK);
+	    BWI_STATE_LO_CLOCK | BWI_STATE_LO_GATED_CLOCK |
+	    __SHIFTIN(flags, BWI_STATE_LO_FLAGS_MASK);
 	CSR_WRITE_4(sc, BWI_STATE_LO, state_lo);

 	/* Flush pending bus write */


Fix another global pool destruction ordering problem in the bdb code.

Previously, we potentially tried to use the bdb cache mutex after its
pool had already been cleared.

Reviewed by: brane
             cmpilato

* subversion/libsvn_fs_base/bdb/env.c
  (clear_cache_lock): New cleanup function, NULLs out the bdb cache lock.
  (svn_fs_bdb__init): Set pool cleanup on the bdb cache pool.
  (acquire_cache_mutex, release_cache_mutex): Don't do anything to the
   lock if it's NULL.

--- subversion/libsvn_fs_base/bdb/env.c
+++ subversion/libsvn_fs_base/bdb/env.c
@@ -367,6 +367,15 @@
 /* The mutex that protects bdb_cache. */
 static apr_thread_mutex_t *bdb_cache_lock = NULL;

+/* Cleanup callback to NULL out the cache lock, so we don't try to use it
+   after its pool has been cleared during global shutdown. */
+static apr_status_t
+clear_cache_lock(void *data)
+{
+  bdb_cache_lock = NULL;
+  return APR_SUCCESS;
+}
+
 /* Magic values for atomic initialization of the environment cache. */
 #define BDB_CACHE_UNINITIALIZED 0
 #define BDB_CACHE_START_INIT    1
@@ -412,6 +421,9 @@
                                   " Berkeley DB environment descriptors");
         }

+      apr_pool_cleanup_register(bdb_cache_pool, NULL, clear_cache_lock,
+                                apr_pool_cleanup_null);
+
       svn__atomic_cas(&bdb_cache_state,
                       BDB_CACHE_INITIALIZED,
                       BDB_CACHE_START_INIT);
@@ -443,7 +455,8 @@
 acquire_cache_mutex(void)
 {
 #if APR_HAS_THREADS
-  apr_thread_mutex_lock(bdb_cache_lock);
+  if (bdb_cache_lock)
+    apr_thread_mutex_lock(bdb_cache_lock);
 #endif
 }

@@ -452,7 +465,8 @@
 release_cache_mutex(void)
 {
 #if APR_HAS_THREADS
-  apr_thread_mutex_unlock(bdb_cache_lock);
+  if (bdb_cache_lock)
+    apr_thread_mutex_unlock(bdb_cache_lock);
 #endif
 }


minor formatting change

minor formatting change

--- drivers/lirc_ite8709/lirc_ite8709.c
+++ drivers/lirc_ite8709/lirc_ite8709.c
@@ -420,8 +420,8 @@
 	ite8709_dev->use_count = 0;
 	ite8709_dev->irq = pnp_irq(dev, 0);
 	ite8709_dev->io = pnp_port_start(dev, 2);
-	ite8709_dev->hardware_lock = __SPIN_LOCK_UNLOCKED(
-					ite8709_dev->hardware_lock);
+	ite8709_dev->hardware_lock =
+		__SPIN_LOCK_UNLOCKED(ite8709_dev->hardware_lock);
 	ite8709_dev->acc_pulse = 0;
 	ite8709_dev->acc_space = 0;
 	ite8709_dev->lastbit = 0;


Modify wording of the messages given by --verbose

--- waitpid.c
+++ waitpid.c
@@ -75,23 +75,17 @@
 }

 static inline void
-info (int pid_count, pid_t pid, const char *format, ...)
+info (pid_t pid, const char *format, ...)
 {
   if (!verbose)
     return;

   va_list ap;
+  char prefix[256];

   va_start (ap, format);
-
-  if (pid_count == 1)
-    __print (stdout, NULL, NULL, format, ap);
-  else {
-    char prefix[256];
-    sprintf (prefix, "%ld", (long)pid);
-    __print (stdout, prefix, NULL, format, ap);
-  }
-
+  sprintf (prefix, "%ld", (long)pid);
+  __print (stdout, prefix, NULL, format, ap);
   va_end (ap);
 }

@@ -319,7 +313,7 @@
       fatal ("ptrace failed");

     if (verbose)
-      info (pid_count, pid, "process attached");
+      info (pid, "attached to process");

     active_processes_count++;
   }
@@ -337,7 +331,7 @@
       active_processes_count--;

       if (verbose)
-        info (pid_count, pid, "exited with status %d", exit_status);
+        info (pid, "exited with status %d", exit_status);
     }
     else if (WIFSIGNALED (status)) {
       signal = WTERMSIG (status);
@@ -345,15 +339,13 @@
       active_processes_count--;

       if (verbose)
-        info (pid_count, pid, "killed by %s%s",
-              signame (signal), WCOREDUMP (status) ? " (core dumped)" : "");
+        info (pid, "killed by %s%s", signame (signal), WCOREDUMP (status) ? " (core dumped)" : "");
     }
     else if (WIFSTOPPED (status)) {
       signal = WSTOPSIG (status);

       if (verbose)
-        info (pid_count, pid, "received %s: %s",
-              signame (signal), strsignal (signal));
+        info (pid, "received %s: %s", signame (signal), strsignal (signal));
     }
     else
       abort ();


fix use of gem_bitwait().

fix use of gem_bitwait().

--- dev/ic/gem.c
+++ dev/ic/gem.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: gem.c,v 1.65 2006/11/25 02:12:04 brad Exp $	*/
+/*	$OpenBSD: gem.c,v 1.66 2006/11/25 04:52:49 brad Exp $	*/
 /*	$NetBSD: gem.c,v 1.1 2001/09/16 00:11:43 eeh Exp $ */

 /*
@@ -544,7 +544,7 @@
 	gem_disable_rx(sc);
 	bus_space_write_4(t, h, GEM_RX_CONFIG, 0);
 	/* Wait till it finishes */
-	if (!gem_bitwait(sc, h, GEM_RESET, 1, 0))
+	if (!gem_bitwait(sc, h, GEM_RX_CONFIG, 1, 0))
 		printf("%s: cannot disable rx dma\n", sc->sc_dev.dv_xname);
 	/* Wait 5ms extra. */
 	delay(5000);


Changed the rep-cache.h header to reflect the right file name and description.

Patch by: Edmund Wong <ed{_AT_}kdtc.net>

* subversion/libsvn_fs_fs/rep-cache.h
  Changed "id.h : interface to node ID functions, private to libsvn_fs_fs" to
  "rep-cache.h : interface to rep cache db functions".

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@879205 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/libsvn_fs_fs/rep-cache.h
+++ subversion/libsvn_fs_fs/rep-cache.h
@@ -1,4 +1,4 @@
-/* id.h : interface to node ID functions, private to libsvn_fs_fs
+/* rep-cache.h : interface to rep cache db functions
  *
  * ====================================================================
  *    Licensed to the Subversion Corporation (SVN Corp.) under one


[media] a8293: improve LNB register programming logic

On power-on LNB power supply voltage is disabled, due to that no
need to disable it during probe. Tone is supply is hard-coded as
external tone coming from the demodulator. Program both voltage
and tone on set_voltage(). Use register cache to prevent unneeded
programming.

Signed-off-by: Antti Palosaari <293134fe763ce2d9d8609280ea107c73cbd2eb86@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@osg.samsung.com>


better yet, nuke all references to sc_enaddr except for the copy into arpcom.ac_enaddr

--- dev/ic/hme.c
+++ dev/ic/hme.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: hme.c,v 1.44 2006/12/21 21:43:44 jason Exp $	*/
+/*	$OpenBSD: hme.c,v 1.45 2006/12/21 21:48:11 jason Exp $	*/
 /*	$NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $	*/

 /*-
@@ -228,7 +228,7 @@
 	}
 	sc->sc_rb.rb_dmabase = sc->sc_dmamap->dm_segs[0].ds_addr;

-	printf(", address %s\n", ether_sprintf(sc->sc_enaddr));
+	printf(", address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));

 	/* Initialize ifnet structure. */
 	strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof ifp->if_xname);


ASITiger: One more fix to RETURN_ON_MM_ERROR.

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@13413 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- DeviceAdapters/ASITiger/ASITiger.h
+++ DeviceAdapters/ASITiger/ASITiger.h
@@ -37,10 +37,12 @@
 //////////////////////////////////////////////////////////////////////////////
 // ASI-specific macros
 //
+
+// Use the name 'return_value' that is unlikely to appear within 'result'.
 #define RETURN_ON_MM_ERROR( result ) do { \
-   int ret = (result); \
-   if (ret != DEVICE_OK) { \
-      return ret; \
+   int return_value = (result); \
+   if (return_value != DEVICE_OK) { \
+      return return_value; \
    } \
 } while (0)


On the http-protocol-v2 branch: Revert a portion of changes made in
r35411.  They were bad.  And wrong.  And ... bad.

* subversion/libsvn_ra_serf/options.c
  (capabilities_headers_iterator_callback): Go back to using if's
    instead of if/else's when parsing headers that can have multiple
    values.

git-svn-id: cbe280b51a1a439dffd90e0e5530c9d00cfa6600@875542 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/libsvn_ra_serf/options.c
+++ subversion/libsvn_ra_serf/options.c
@@ -300,23 +300,21 @@
           apr_hash_set(orc->session->capabilities, SVN_RA_CAPABILITY_DEPTH,
                        APR_HASH_KEY_STRING, capability_yes);
         }
-      else if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_MERGEINFO,
-                                           vals))
+      if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_MERGEINFO, vals))
         {
           /* The server doesn't know what repository we're referring
              to, so it can't just say capability_yes. */
           apr_hash_set(orc->session->capabilities, SVN_RA_CAPABILITY_MERGEINFO,
                        APR_HASH_KEY_STRING, capability_server_yes);
         }
-      else if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_LOG_REVPROPS,
-                                           vals))
+      if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_LOG_REVPROPS,
+                                      vals))
         {
           apr_hash_set(orc->session->capabilities,
                        SVN_RA_CAPABILITY_LOG_REVPROPS,
                        APR_HASH_KEY_STRING, capability_yes);
         }
-      else if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_PARTIAL_REPLAY,
-                                           vals))
+      if (svn_cstring_match_glob_list(SVN_DAV_NS_DAV_SVN_PARTIAL_REPLAY, vals))
         {
           apr_hash_set(orc->session->capabilities,
                        SVN_RA_CAPABILITY_PARTIAL_REPLAY,


V4L/DVB (10888): radio-sf16fmi: convert to v4l2_device.

Signed-off-by: Hans Verkuil <f625be9dbdcbbd12a043857af148e8fb895d9a1d@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/radio/radio-sf16fmi.c
+++ drivers/media/radio/radio-sf16fmi.c
@@ -22,113 +22,110 @@
 #include <linux/init.h>		/* Initdata			*/
 #include <linux/ioport.h>	/* request_region		*/
 #include <linux/delay.h>	/* udelay			*/
+#include <linux/isapnp.h>
+#include <linux/mutex.h>
 #include <linux/videodev2.h>	/* kernel radio structs		*/
-#include <media/v4l2-common.h>
+#include <linux/io.h>		/* outb, outb_p			*/
+#include <linux/uaccess.h>	/* copy to/from user		*/
+#include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
-#include <linux/isapnp.h>
-#include <asm/io.h>		/* outb, outb_p			*/
-#include <asm/uaccess.h>	/* copy to/from user		*/
-#include <linux/mutex.h>
-
-#define RADIO_VERSION KERNEL_VERSION(0,0,2)
-
-static struct v4l2_queryctrl radio_qctrl[] = {
-	{
-		.id            = V4L2_CID_AUDIO_MUTE,
-		.name          = "Mute",
-		.minimum       = 0,
-		.maximum       = 1,
-		.default_value = 1,
-		.type          = V4L2_CTRL_TYPE_BOOLEAN,
-	}
-};
-
-struct fmi_device
-{
-	unsigned long in_use;
-	int port;
+
+MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood");
+MODULE_DESCRIPTION("A driver for the SF16MI radio.");
+MODULE_LICENSE("GPL");
+
+static int io = -1;
+static int radio_nr = -1;
+
+module_param(io, int, 0);
+MODULE_PARM_DESC(io, "I/O address of the SF16MI card (0x284 or 0x384)");
+module_param(radio_nr, int, 0);
+
+#define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
+
+struct fmi
+{
+	struct v4l2_device v4l2_dev;
+	struct video_device vdev;
+	int io;
 	int curvol; /* 1 or 0 */
 	unsigned long curfreq; /* freq in kHz */
 	__u32 flags;
+	struct mutex lock;
 };

-static int io = -1;
-static int radio_nr = -1;
-static struct pnp_dev *dev = NULL;
-static struct mutex lock;
+static struct fmi fmi_card;
+static struct pnp_dev *dev;

 /* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
 /* It is only useful to give freq in intervall of 800 (=0.05Mhz),
  * other bits will be truncated, e.g 92.7400016 -> 92.7, but
  * 92.7400017 -> 92.75
  */
-#define RSF16_ENCODE(x)	((x)/800+214)
-#define RSF16_MINFREQ 87*16000
-#define RSF16_MAXFREQ 108*16000
-
-static void outbits(int bits, unsigned int data, int port)
-{
-	while(bits--) {
-		if(data & 1) {
-			outb(5, port);
+#define RSF16_ENCODE(x)	((x) / 800 + 214)
+#define RSF16_MINFREQ (87 * 16000)
+#define RSF16_MAXFREQ (108 * 16000)
+
+static void outbits(int bits, unsigned int data, int io)
+{
+	while (bits--) {
+		if (data & 1) {
+			outb(5, io);
 			udelay(6);
-			outb(7, port);
+			outb(7, io);
 			udelay(6);
 		} else {
-			outb(1, port);
+			outb(1, io);
 			udelay(6);
-			outb(3, port);
+			outb(3, io);
 			udelay(6);
 		}
-		data>>=1;
-	}
-}
-
-static inline void fmi_mute(int port)
-{
-	mutex_lock(&lock);
-	outb(0x00, port);
-	mutex_unlock(&lock);
-}
-
-static inline void fmi_unmute(int port)
-{
-	mutex_lock(&lock);
-	outb(0x08, port);
-	mutex_unlock(&lock);
-}
-
-static inline int fmi_setfreq(struct fmi_device *dev)
-{
-	int myport = dev->port;
-	unsigned long freq = dev->curfreq;
-
-	mutex_lock(&lock);
-
-	outbits(16, RSF16_ENCODE(freq), myport);
-	outbits(8, 0xC0, myport);
+		data >>= 1;
+	}
+}
+
+static inline void fmi_mute(struct fmi *fmi)
+{
+	mutex_lock(&fmi->lock);
+	outb(0x00, fmi->io);
+	mutex_unlock(&fmi->lock);
+}
+
+static inline void fmi_unmute(struct fmi *fmi)
+{
+	mutex_lock(&fmi->lock);
+	outb(0x08, fmi->io);
+	mutex_unlock(&fmi->lock);
+}
+
+static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq)
+{
+	mutex_lock(&fmi->lock);
+	fmi->curfreq = freq;
+
+	outbits(16, RSF16_ENCODE(freq), fmi->io);
+	outbits(8, 0xC0, fmi->io);
 	msleep(143);		/* was schedule_timeout(HZ/7) */
-	mutex_unlock(&lock);
-	if (dev->curvol) fmi_unmute(myport);
-	return 0;
-}
-
-static inline int fmi_getsigstr(struct fmi_device *dev)
+	mutex_unlock(&fmi->lock);
+	if (fmi->curvol)
+		fmi_unmute(fmi);
+	return 0;
+}
+
+static inline int fmi_getsigstr(struct fmi *fmi)
 {
 	int val;
 	int res;
-	int myport = dev->port;
-
-
-	mutex_lock(&lock);
-	val = dev->curvol ? 0x08 : 0x00;	/* unmute/mute */
-	outb(val, myport);
-	outb(val | 0x10, myport);
+
+	mutex_lock(&fmi->lock);
+	val = fmi->curvol ? 0x08 : 0x00;	/* unmute/mute */
+	outb(val, fmi->io);
+	outb(val | 0x10, fmi->io);
 	msleep(143); 		/* was schedule_timeout(HZ/7) */
-	res = (int)inb(myport+1);
-	outb(val, myport);
-
-	mutex_unlock(&lock);
+	res = (int)inb(fmi->io + 1);
+	outb(val, fmi->io);
+
+	mutex_unlock(&fmi->lock);
 	return (res & 2) ? 0 : 0xFFFF;
 }

@@ -137,9 +134,9 @@
 {
 	strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver));
 	strlcpy(v->card, "SF16-FMx radio", sizeof(v->card));
-	sprintf(v->bus_info, "ISA");
+	strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
 	v->version = RADIO_VERSION;
-	v->capabilities = V4L2_CAP_TUNER;
+	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
 	return 0;
 }

@@ -147,18 +144,18 @@
 					struct v4l2_tuner *v)
 {
 	int mult;
-	struct fmi_device *fmi = video_drvdata(file);
+	struct fmi *fmi = video_drvdata(file);

 	if (v->index > 0)
 		return -EINVAL;

-	strcpy(v->name, "FM");
+	strlcpy(v->name, "FM", sizeof(v->name));
 	v->type = V4L2_TUNER_RADIO;
 	mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
-	v->rangelow = RSF16_MINFREQ/mult;
-	v->rangehigh = RSF16_MAXFREQ/mult;
+	v->rangelow = RSF16_MINFREQ / mult;
+	v->rangehigh = RSF16_MAXFREQ / mult;
 	v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO;
-	v->capability = fmi->flags&V4L2_TUNER_CAP_LOW;
+	v->capability = fmi->flags & V4L2_TUNER_CAP_LOW;
 	v->audmode = V4L2_TUNER_MODE_STEREO;
 	v->signal = fmi_getsigstr(fmi);
 	return 0;
@@ -167,32 +164,29 @@
 static int vidioc_s_tuner(struct file *file, void *priv,
 					struct v4l2_tuner *v)
 {
-	if (v->index > 0)
-		return -EINVAL;
-	return 0;
+	return v->index ? -EINVAL : 0;
 }

 static int vidioc_s_frequency(struct file *file, void *priv,
 					struct v4l2_frequency *f)
 {
-	struct fmi_device *fmi = video_drvdata(file);
+	struct fmi *fmi = video_drvdata(file);

 	if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
 		f->frequency *= 1000;
 	if (f->frequency < RSF16_MINFREQ ||
-			f->frequency > RSF16_MAXFREQ )
+			f->frequency > RSF16_MAXFREQ)
 		return -EINVAL;
-	/*rounding in steps of 800 to match th freq
-	that will be used */
-	fmi->curfreq = (f->frequency/800)*800;
-	fmi_setfreq(fmi);
+	/* rounding in steps of 800 to match the freq
+	   that will be used */
+	fmi_setfreq(fmi, (f->frequency / 800) * 800);
 	return 0;
 }

 static int vidioc_g_frequency(struct file *file, void *priv,
 					struct v4l2_frequency *f)
 {
-	struct fmi_device *fmi = video_drvdata(file);
+	struct fmi *fmi = video_drvdata(file);

 	f->type = V4L2_TUNER_RADIO;
 	f->frequency = fmi->curfreq;
@@ -204,14 +198,9 @@
 static int vidioc_queryctrl(struct file *file, void *priv,
 					struct v4l2_queryctrl *qc)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
-		if (qc->id && qc->id == radio_qctrl[i].id) {
-			memcpy(qc, &(radio_qctrl[i]),
-						sizeof(*qc));
-			return 0;
-		}
+	switch (qc->id) {
+	case V4L2_CID_AUDIO_MUTE:
+		return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
 	}
 	return -EINVAL;
 }
@@ -219,7 +208,7 @@
 static int vidioc_g_ctrl(struct file *file, void *priv,
 					struct v4l2_control *ctrl)
 {
-	struct fmi_device *fmi = video_drvdata(file);
+	struct fmi *fmi = video_drvdata(file);

 	switch (ctrl->id) {
 	case V4L2_CID_AUDIO_MUTE:
@@ -232,69 +221,60 @@
 static int vidioc_s_ctrl(struct file *file, void *priv,
 					struct v4l2_control *ctrl)
 {
-	struct fmi_device *fmi = video_drvdata(file);
+	struct fmi *fmi = video_drvdata(file);

 	switch (ctrl->id) {
 	case V4L2_CID_AUDIO_MUTE:
 		if (ctrl->value)
-			fmi_mute(fmi->port);
+			fmi_mute(fmi);
 		else
-			fmi_unmute(fmi->port);
+			fmi_unmute(fmi);
 		fmi->curvol = ctrl->value;
 		return 0;
 	}
 	return -EINVAL;
 }

+static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
+{
+	*i = 0;
+	return 0;
+}
+
+static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
+{
+	return i ? -EINVAL : 0;
+}
+
 static int vidioc_g_audio(struct file *file, void *priv,
 					struct v4l2_audio *a)
 {
-	if (a->index > 1)
-		return -EINVAL;
-
-	strcpy(a->name, "Radio");
+	a->index = 0;
+	strlcpy(a->name, "Radio", sizeof(a->name));
 	a->capability = V4L2_AUDCAP_STEREO;
-	return 0;
-}
-
-static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
-{
-	*i = 0;
-	return 0;
-}
-
-static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
-{
-	if (i != 0)
-		return -EINVAL;
 	return 0;
 }

 static int vidioc_s_audio(struct file *file, void *priv,
 					struct v4l2_audio *a)
 {
-	if (a->index != 0)
-		return -EINVAL;
-	return 0;
-}
-
-static struct fmi_device fmi_unit;
-
-static int fmi_exclusive_open(struct file *file)
-{
-	return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0;
-}
-
-static int fmi_exclusive_release(struct file *file)
-{
-	clear_bit(0, &fmi_unit.in_use);
+	return a->index ? -EINVAL : 0;
+}
+
+static int fmi_open(struct file *file)
+{
+	return 0;
+}
+
+static int fmi_release(struct file *file)
+{
 	return 0;
 }

 static const struct v4l2_file_operations fmi_fops = {
 	.owner		= THIS_MODULE,
-	.open           = fmi_exclusive_open,
-	.release        = fmi_exclusive_release,
+	.open           = fmi_open,
+	.release        = fmi_release,
 	.ioctl		= video_ioctl2,
 };

@@ -313,13 +293,6 @@
 	.vidioc_s_ctrl      = vidioc_s_ctrl,
 };

-static struct video_device fmi_radio = {
-	.name		= "SF16FMx radio",
-	.fops           = &fmi_fops,
-	.ioctl_ops 	= &fmi_ioctl_ops,
-	.release	= video_device_release_empty,
-};
-
 /* ladis: this is my card. does any other types exist? */
 static struct isapnp_device_id id_table[] __devinitdata = {
 	{	ISAPNP_ANY_ID, ISAPNP_ANY_ID,
@@ -344,7 +317,7 @@
 	if (pnp_device_attach(dev) < 0)
 		return -EAGAIN;
 	if (pnp_activate_dev(dev) < 0) {
-		printk ("radio-sf16fmi: PnP configure failed (out of resources?)\n");
+		printk(KERN_ERR "radio-sf16fmi: PnP configure failed (out of resources?)\n");
 		pnp_device_detach(dev);
 		return -ENOMEM;
 	}
@@ -354,59 +327,72 @@
 	}

 	i = pnp_port_start(dev, 0);
-	printk ("radio-sf16fmi: PnP reports card at %#x\n", i);
+	printk(KERN_INFO "radio-sf16fmi: PnP reports card at %#x\n", i);

 	return i;
 }

 static int __init fmi_init(void)
 {
+	struct fmi *fmi = &fmi_card;
+	struct v4l2_device *v4l2_dev = &fmi->v4l2_dev;
+	int res;
+
 	if (io < 0)
 		io = isapnp_fmi_probe();
-	if (io < 0) {
-		printk(KERN_ERR "radio-sf16fmi: No PnP card found.\n");
-		return io;
+	strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name));
+	fmi->io = io;
+	if (fmi->io < 0) {
+		v4l2_err(v4l2_dev, "No PnP card found.\n");
+		return fmi->io;
 	}
 	if (!request_region(io, 2, "radio-sf16fmi")) {
-		printk(KERN_ERR "radio-sf16fmi: port 0x%x already in use\n", io);
+		v4l2_err(v4l2_dev, "port 0x%x already in use\n", fmi->io);
 		pnp_device_detach(dev);
 		return -EBUSY;
 	}

-	fmi_unit.port = io;
-	fmi_unit.curvol = 0;
-	fmi_unit.curfreq = 0;
-	fmi_unit.flags = V4L2_TUNER_CAP_LOW;
-	video_set_drvdata(&fmi_radio, &fmi_unit);
-
-	mutex_init(&lock);
-
-	if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
-		release_region(io, 2);
+	res = v4l2_device_register(NULL, v4l2_dev);
+	if (res < 0) {
+		release_region(fmi->io, 2);
+		pnp_device_detach(dev);
+		v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
+		return res;
+	}
+
+	fmi->flags = V4L2_TUNER_CAP_LOW;
+	strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name));
+	fmi->vdev.v4l2_dev = v4l2_dev;
+	fmi->vdev.fops = &fmi_fops;
+	fmi->vdev.ioctl_ops = &fmi_ioctl_ops;
+	fmi->vdev.release = video_device_release_empty;
+	video_set_drvdata(&fmi->vdev, fmi);
+
+	mutex_init(&fmi->lock);
+
+	if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
+		v4l2_device_unregister(v4l2_dev);
+		release_region(fmi->io, 2);
+		pnp_device_detach(dev);
 		return -EINVAL;
 	}

-	printk(KERN_INFO "SF16FMx radio card driver at 0x%x\n", io);
+	v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
 	/* mute card - prevents noisy bootups */
-	fmi_mute(io);
-	return 0;
-}
-
-MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood");
-MODULE_DESCRIPTION("A driver for the SF16MI radio.");
-MODULE_LICENSE("GPL");
-
-module_param(io, int, 0);
-MODULE_PARM_DESC(io, "I/O address of the SF16MI card (0x284 or 0x384)");
-module_param(radio_nr, int, 0);
-
-static void __exit fmi_cleanup_module(void)
-{
-	video_unregister_device(&fmi_radio);
-	release_region(io, 2);
+	fmi_mute(fmi);
+	return 0;
+}
+
+static void __exit fmi_exit(void)
+{
+	struct fmi *fmi = &fmi_card;
+
+	video_unregister_device(&fmi->vdev);
+	v4l2_device_unregister(&fmi->v4l2_dev);
+	release_region(fmi->io, 2);
 	if (dev)
 		pnp_device_detach(dev);
 }

 module_init(fmi_init);
-module_exit(fmi_cleanup_module);
+module_exit(fmi_exit);


mpi_bio_get_pg0_raid is only called from a process context. let the cfg requests sleep rather than poll for completion.

--- dev/ic/mpi.c
+++ dev/ic/mpi.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: mpi.c,v 1.130 2010/01/03 07:26:44 dlg Exp $ */
+/*	$OpenBSD: mpi.c,v 1.131 2010/01/03 07:28:46 dlg Exp $ */

 /*
  * Copyright (c) 2005, 2006, 2009 David Gwynne <dlg@openbsd.org>
@@ -2731,7 +2731,7 @@
 	struct mpi_cfg_raid_vol_pg0 *rpg0;

 	/* get IOC page 2 */
-	if (mpi_cfg_page(sc, 0, &sc->sc_cfg_hdr, 1, sc->sc_vol_page,
+	if (mpi_req_cfg_page(sc, 0, 0, &sc->sc_cfg_hdr, 1, sc->sc_vol_page,
 	    sc->sc_cfg_hdr.page_length * 4) != 0) {
 		DNPRINTF(MPI_D_IOCTL, "%s: mpi_bio_get_pg0_raid unable to "
 		    "fetch IOC page 2\n", DEVNAME(sc));
@@ -2761,10 +2761,10 @@
 	/* get raid vol page 0 */
 	address = sc->sc_vol_list[id].vol_id |
 	    (sc->sc_vol_list[id].vol_bus << 8);
-	if (mpi_cfg_header(sc, MPI_CONFIG_REQ_PAGE_TYPE_RAID_VOL, 0,
+	if (mpi_req_cfg_header(sc, MPI_CONFIG_REQ_PAGE_TYPE_RAID_VOL, 0, 0,
 	    address, &hdr) != 0)
 		goto done;
-	if (mpi_cfg_page(sc, address, &hdr, 1, rpg0, len)) {
+	if (mpi_req_cfg_page(sc, address, 0, &hdr, 1, rpg0, len)) {
 		DNPRINTF(MPI_D_RAID, "%s: can't get RAID vol cfg page 0\n",
 		    DEVNAME(sc));
 		goto done;


[media] radio-tea5777.c: Get rid of do_div usage

freq fits easily into 32 bits until it gets shifted, so make it 32 bits,
and cast it to 64 bits before shifting.

[ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com: also remove asm/div64.h header, as this is not
 needed anymore]
Signed-off-by: Hans de Goede <9fa1be1a5b5729e4c6b404f34c9ce49ff4882fd8@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/radio/radio-tea5777.c
+++ drivers/media/radio/radio-tea5777.c
@@ -33,7 +33,6 @@
 #include <media/v4l2-fh.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-event.h>
-#include <asm/div64.h>
 #include "radio-tea5777.h"

 MODULE_AUTHOR("Hans de Goede <perex@perex.cz>");
@@ -155,18 +154,17 @@

 static int radio_tea5777_set_freq(struct radio_tea5777 *tea)
 {
-	u64 freq;
+	u32 freq;
 	int res;

 	freq = clamp_t(u32, tea->freq,
-		       TEA5777_FM_RANGELOW, TEA5777_FM_RANGEHIGH) + 8;
-	do_div(freq, 16); /* to kHz */
-
-	freq -= TEA5777_FM_IF;
-	do_div(freq, TEA5777_FM_FREQ_STEP);
+		       TEA5777_FM_RANGELOW, TEA5777_FM_RANGEHIGH);
+	freq = (freq + 8) / 16; /* to kHz */
+
+	freq = (freq - TEA5777_FM_IF) / TEA5777_FM_FREQ_STEP;

 	tea->write_reg &= ~(TEA5777_W_FM_PLL_MASK | TEA5777_W_FM_FREF_MASK);
-	tea->write_reg |= freq << TEA5777_W_FM_PLL_SHIFT;
+	tea->write_reg |= (u64)freq << TEA5777_W_FM_PLL_SHIFT;
 	tea->write_reg |= TEA5777_W_FM_FREF_VALUE << TEA5777_W_FM_FREF_SHIFT;

 	res = tea->ops->write_reg(tea, tea->write_reg);


Start using svn_client_conflict_get_conflicted() in 'svn'.

This covers the easy cases. Property conflicts still need some work.

* subversion/svn/conflict-callbacks.c
  (conflict_func_interactive): Use svn_client_conflict_get_conflicted()
   instead of svn_client_conflict_get_kind().
  (svn_cl__resolve_conflict): Likewise.

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@1727406 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/svn/conflict-callbacks.c
+++ subversion/svn/conflict-callbacks.c
@@ -1406,8 +1406,17 @@
   const char *my_abspath = NULL;
   const char *their_abspath = NULL;
   const char *merged_abspath = svn_client_conflict_get_local_abspath(conflict);
-
-  if (svn_client_conflict_get_kind(conflict) == svn_wc_conflict_kind_text)
+  svn_boolean_t text_conflicted;
+  svn_boolean_t tree_conflicted;
+
+  SVN_ERR(svn_client_conflict_get_conflicted(&text_conflicted,
+                                             NULL, /* ### TODO */
+                                             &tree_conflicted,
+                                             conflict,
+                                             scratch_pool,
+                                             scratch_pool));
+
+  if (text_conflicted)
     SVN_ERR(svn_client_conflict_text_get_contents(NULL, &my_abspath,
                                                   &base_abspath,
                                                   &their_abspath,
@@ -1536,11 +1545,11 @@
      Conflicting edits on a file's text, or
      Conflicting edits on a property.
   */
-  if (((svn_client_conflict_get_kind(conflict) == svn_wc_conflict_kind_text)
+  if (text_conflicted
        && (svn_client_conflict_get_incoming_change(conflict) ==
            svn_wc_conflict_action_edit)
        && (svn_client_conflict_get_local_change(conflict) ==
-           svn_wc_conflict_reason_edited)))
+           svn_wc_conflict_reason_edited))
     SVN_ERR(handle_text_conflict(option_id, save_merged, accept_which,
                                  quit, conflict, path_prefix, pb,
                                  editor_cmd, config, scratch_pool));
@@ -1550,7 +1559,7 @@
                                  quit, path_prefix, pb,
                                  editor_cmd, config, conflict,
                                  result_pool, scratch_pool));
-  else if (svn_client_conflict_get_kind(conflict) == svn_wc_conflict_kind_tree)
+  else if (tree_conflicted)
     SVN_ERR(handle_tree_conflict(option_id, accept_which, quit,
                                  conflict, path_prefix, pb,
                                  scratch_pool));
@@ -1625,6 +1634,17 @@
                          svn_client_ctx_t *ctx,
                          apr_pool_t *scratch_pool)
 {
+  svn_boolean_t text_conflicted;
+  apr_array_header_t **props_conflicted;
+  svn_boolean_t tree_conflicted;
+
+  SVN_ERR(svn_client_conflict_get_conflicted(&text_conflicted,
+                                             &props_conflicted,
+                                             &tree_conflicted,
+                                             conflict,
+                                             scratch_pool,
+                                             scratch_pool));
+
   if (option_id == svn_client_conflict_option_unspecified)
     SVN_ERR(conflict_func_interactive(&option_id, NULL, NULL,
                                       accept_which, quit,
@@ -1642,7 +1662,6 @@
         = svn_cl__local_style_skip_ancestor(
             path_prefix, svn_client_conflict_get_local_abspath(conflict),
             scratch_pool);
-      svn_wc_conflict_kind_t conflict_kind;
       const char *local_abspath;
       const char *lock_abspath;
       svn_error_t *err;
@@ -1655,13 +1674,11 @@
                                                      local_abspath,
                                                      scratch_pool,
                                                      scratch_pool));
-      conflict_kind = svn_client_conflict_get_kind(conflict);
-
       err = svn_wc_resolved_conflict5(
               ctx->wc_ctx, local_abspath, svn_depth_empty, /* ??? */
-              conflict_kind == svn_wc_conflict_kind_text,
-              conflict_kind == svn_wc_conflict_kind_property ? "" : NULL,
-              conflict_kind == svn_wc_conflict_kind_tree,
+              text_conflicted,
+              props_conflicted != NULL ? "" : NULL,
+              tree_conflicted,
               conflict_option_id_to_wc_conflict_choice(option_id),
               ctx->cancel_func, ctx->cancel_baton,
               ctx->notify_func2, ctx->notify_baton2,


Expunge debug code that uses an uninitialized variable. Without the
variable the message doesn't make much sense.

Reported by Maxime Villard.


V4L/DVB (13996): gspca_stv0680: Fix streaming on vga cameras

Streaming of VGA stv0680 based cams (instead of CIF ones) failed, because
we were using the wrong control pipe for certain commands, this patch fixes
this.

Signed-off-by: Hans de Goede <9fa1be1a5b5729e4c6b404f34c9ce49ff4882fd8@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/gspca/stv0680.c
+++ drivers/media/video/gspca/stv0680.c
@@ -53,24 +53,28 @@
 {
 	int ret = -1;
 	u8 req_type = 0;
+	unsigned int pipe = 0;

 	switch (set) {
 	case 0: /*  0xc1  */
 		req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT;
+		pipe = usb_rcvctrlpipe(gspca_dev->dev, 0);
 		break;
 	case 1: /*  0x41  */
 		req_type = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT;
+		pipe = usb_sndctrlpipe(gspca_dev->dev, 0);
 		break;
 	case 2:	/*  0x80  */
 		req_type = USB_DIR_IN | USB_RECIP_DEVICE;
+		pipe = usb_rcvctrlpipe(gspca_dev->dev, 0);
 		break;
 	case 3:	/*  0x40  */
 		req_type = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
+		pipe = usb_sndctrlpipe(gspca_dev->dev, 0);
 		break;
 	}

-	ret = usb_control_msg(gspca_dev->dev,
-			      usb_rcvctrlpipe(gspca_dev->dev, 0),
+	ret = usb_control_msg(gspca_dev->dev, pipe,
 			      req, req_type,
 			      val, 0, gspca_dev->usb_buf, size, 500);

@@ -173,6 +177,8 @@
 		PDEBUG(D_PROBE, "Camera supports CIF mode");
 	if (gspca_dev->usb_buf[7] & 0x02)
 		PDEBUG(D_PROBE, "Camera supports VGA mode");
+	if (gspca_dev->usb_buf[7] & 0x04)
+		PDEBUG(D_PROBE, "Camera supports QCIF mode");
 	if (gspca_dev->usb_buf[7] & 0x08)
 		PDEBUG(D_PROBE, "Camera supports QVGA mode");


Device reset improvements:
- put the reset protocol itself in the separate function __wdcdo_reset()
  so we don't need anymore to keep in sync two reset code paths;
- change the reset protocol to something like FreeBSD and NetBSD do,
  this fixes slave ATA drive detect with weird ATAPI master (reported
  by fgsch@);

Discussed with costa@.
Tested by me, fgsch@, millert@, canacar@.

--- dev/ic/wdc.c
+++ dev/ic/wdc.c
@@ -1,4 +1,4 @@
-/*      $OpenBSD: wdc.c,v 1.70 2003/10/21 18:58:50 jmc Exp $     */
+/*      $OpenBSD: wdc.c,v 1.71 2003/10/26 14:29:47 grange Exp $     */
 /*	$NetBSD: wdc.c,v 1.68 1999/06/23 19:00:17 bouyer Exp $ */

@@ -100,6 +100,7 @@
 struct pool wdc_xfer_pool;

 void  __wdcerror(struct channel_softc *, char *);
+void  __wdcdo_reset(struct channel_softc *);
 int   __wdcwait_reset(struct channel_softc *, int);
 void  __wdccommand_done(struct channel_softc *, struct wdc_xfer *);
 void  __wdccommand_start(struct channel_softc *, struct wdc_xfer *);
@@ -657,10 +658,7 @@
 	}

 	/* reset the channel */
-	CHP_WRITE_REG(chp,wdr_ctlr, WDCTL_RST | WDCTL_4BIT);
-	delay(10);
-	CHP_WRITE_REG(chp, wdr_ctlr, WDCTL_4BIT);
-	delay(2000);
+	__wdcdo_reset(chp);

 	ret_value = __wdcwait_reset(chp, ret_value);
 	WDCDEBUG_PRINT(("%s:%d: after reset, ret_value=0x%d\n",
@@ -1033,10 +1031,7 @@
 	if (!chp->_vtbl)
 		chp->_vtbl = &wdc_default_vtbl;

-	CHP_WRITE_REG(chp, wdr_ctlr, WDCTL_RST | WDCTL_4BIT);
-	delay(10);
-	CHP_WRITE_REG(chp, wdr_ctlr, WDCTL_4BIT);
-	delay(2000);
+	__wdcdo_reset(chp);

 	drv_mask1 = (chp->ch_drive[0].drive_flags & DRIVE) ? 0x01:0x00;
 	drv_mask1 |= (chp->ch_drive[1].drive_flags & DRIVE) ? 0x02:0x00;
@@ -1052,6 +1047,17 @@
 	}

 	return (drv_mask1 != drv_mask2) ? 1 : 0;
+}
+
+void
+__wdcdo_reset(struct channel_softc *chp)
+{
+	wdc_set_drive(chp, 0);
+	DELAY(10);
+	CHP_WRITE_REG(chp, wdr_ctlr, WDCTL_IDS | WDCTL_RST);
+	delay(10000);
+	CHP_WRITE_REG(chp, wdr_ctlr, WDCTL_IDS);
+	delay(10000);
 }

 int


[MTD] [NOR] Support Intel P3x flash support with CFI version 1.5

Signed-off-by: Alexey Korolev <9941e7e9a1d217e5926ceb75deef403f1821c8b2@infradead.org>
Signed-off-by: David Woodhouse <97b3379caa91f4ee97e44013ae4dc6350540fa9d@infradead.org>

--- drivers/mtd/chips/cfi_cmdset_0001.c
+++ drivers/mtd/chips/cfi_cmdset_0001.c
@@ -320,7 +320,7 @@
 		return NULL;

 	if (extp->MajorVersion != '1' ||
-	    (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
+	    (extp->MinorVersion < '0' || extp->MinorVersion > '5')) {
 		printk(KERN_ERR "  Unknown Intel/Sharp Extended Query "
 		       "version %c.%c.\n",  extp->MajorVersion,
 		       extp->MinorVersion);


add 2 missing ReverseInnerIterators

add 2 missing ReverseInnerIterators

--- Eigen/src/SparseCore/SparseBlock.h
+++ Eigen/src/SparseCore/SparseBlock.h
@@ -65,6 +65,17 @@
       protected:
         Index m_outer;
     };
+    class ReverseInnerIterator: public MatrixType::ReverseInnerIterator
+    {
+      public:
+        inline ReverseInnerIterator(const SparseInnerVectorSet& xpr, Index outer)
+          : MatrixType::ReverseInnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
+        {}
+        inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
+        inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
+      protected:
+        Index m_outer;
+    };

     inline SparseInnerVectorSet(const MatrixType& matrix, Index outerStart, Index outerSize)
       : m_matrix(matrix), m_outerStart(outerStart), m_outerSize(outerSize)
@@ -121,6 +132,17 @@
       public:
         inline InnerIterator(const SparseInnerVectorSet& xpr, Index outer)
           : MatrixType::InnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
+        {}
+        inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
+        inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
+      protected:
+        Index m_outer;
+    };
+    class ReverseInnerIterator: public MatrixType::ReverseInnerIterator
+    {
+      public:
+        inline ReverseInnerIterator(const SparseInnerVectorSet& xpr, Index outer)
+          : MatrixType::ReverseInnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
         {}
         inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
         inline Index col() const { return IsRowMajor ? this->index() : m_outer; }


mtd: Add armflash support for multiple blocks of flash

This patch adds MTD concatenation support to integrator-flash.c for
platforms with more than one block of flash memory (e.g. RealView
PB11MPCore). The implementation is based on the sa1100-flash.c one.

Signed-off-by: Catalin Marinas <15ce75b290ebaf27c3f9fd73ab848685ed3d8261@arm.com>
Acked-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>
Signed-off-by: David Woodhouse <b460d66aaf00c296a3db1c1d9eeafc081d5f7d70@intel.com>

--- drivers/mtd/maps/integrator-flash.c
+++ drivers/mtd/maps/integrator-flash.c
@@ -36,27 +36,33 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
+#include <linux/mtd/concat.h>

 #include <asm/mach/flash.h>
 #include <mach/hardware.h>
 #include <asm/system.h>

-#ifdef CONFIG_ARCH_P720T
-#define FLASH_BASE		(0x04000000)
-#define FLASH_SIZE		(64*1024*1024)
-#endif
+#define SUBDEV_NAME_SIZE	(BUS_ID_SIZE + 2)
+
+struct armflash_subdev_info {
+	char			name[SUBDEV_NAME_SIZE];
+	struct mtd_info		*mtd;
+	struct map_info		map;
+	struct flash_platform_data *plat;
+};

 struct armflash_info {
-	struct flash_platform_data *plat;
 	struct resource		*res;
 	struct mtd_partition	*parts;
 	struct mtd_info		*mtd;
-	struct map_info		map;
+	int			nr_subdev;
+	struct armflash_subdev_info subdev[0];
 };

 static void armflash_set_vpp(struct map_info *map, int on)
 {
-	struct armflash_info *info = container_of(map, struct armflash_info, map);
+	struct armflash_subdev_info *info =
+		container_of(map, struct armflash_subdev_info, map);

 	if (info->plat && info->plat->set_vpp)
 		info->plat->set_vpp(on);
@@ -64,32 +70,17 @@

 static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };

-static int armflash_probe(struct platform_device *dev)
-{
-	struct flash_platform_data *plat = dev->dev.platform_data;
-	struct resource *res = dev->resource;
-	unsigned int size = res->end - res->start + 1;
-	struct armflash_info *info;
-	int err;
+static int armflash_subdev_probe(struct armflash_subdev_info *subdev,
+				 struct resource *res)
+{
+	struct flash_platform_data *plat = subdev->plat;
+	resource_size_t size = res->end - res->start + 1;
 	void __iomem *base;
-
-	info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL);
-	if (!info) {
-		err = -ENOMEM;
+	int err = 0;
+
+	if (!request_mem_region(res->start, size, subdev->name)) {
+		err = -EBUSY;
 		goto out;
-	}
-
-	info->plat = plat;
-	if (plat && plat->init) {
-		err = plat->init();
-		if (err)
-			goto no_resource;
-	}
-
-	info->res = request_mem_region(res->start, size, "armflash");
-	if (!info->res) {
-		err = -EBUSY;
-		goto no_resource;
 	}

 	base = ioremap(res->start, size);
@@ -101,27 +92,132 @@
 	/*
 	 * look for CFI based flash parts fitted to this board
 	 */
-	info->map.size		= size;
-	info->map.bankwidth	= plat->width;
-	info->map.phys		= res->start;
-	info->map.virt		= base;
-	info->map.name		= dev_name(&dev->dev);
-	info->map.set_vpp	= armflash_set_vpp;
-
-	simple_map_init(&info->map);
+	subdev->map.size	= size;
+	subdev->map.bankwidth	= plat->width;
+	subdev->map.phys	= res->start;
+	subdev->map.virt	= base;
+	subdev->map.name	= subdev->name;
+	subdev->map.set_vpp	= armflash_set_vpp;
+
+	simple_map_init(&subdev->map);

 	/*
 	 * Also, the CFI layer automatically works out what size
 	 * of chips we have, and does the necessary identification
 	 * for us automatically.
 	 */
-	info->mtd = do_map_probe(plat->map_name, &info->map);
-	if (!info->mtd) {
+	subdev->mtd = do_map_probe(plat->map_name, &subdev->map);
+	if (!subdev->mtd) {
 		err = -ENXIO;
 		goto no_device;
 	}

-	info->mtd->owner = THIS_MODULE;
+	subdev->mtd->owner = THIS_MODULE;
+
+	/* Successful? */
+	if (err == 0)
+		return err;
+
+	if (subdev->mtd)
+		map_destroy(subdev->mtd);
+ no_device:
+	iounmap(base);
+ no_mem:
+	release_mem_region(res->start, size);
+ out:
+	return err;
+}
+
+static void armflash_subdev_remove(struct armflash_subdev_info *subdev)
+{
+	if (subdev->mtd)
+		map_destroy(subdev->mtd);
+	if (subdev->map.virt)
+		iounmap(subdev->map.virt);
+	release_mem_region(subdev->map.phys, subdev->map.size);
+}
+
+static int armflash_probe(struct platform_device *dev)
+{
+	struct flash_platform_data *plat = dev->dev.platform_data;
+	unsigned int size;
+	struct armflash_info *info;
+	int i, nr, err;
+
+	/* Count the number of devices */
+	for (nr = 0; ; nr++)
+		if (!platform_get_resource(dev, IORESOURCE_MEM, nr))
+			break;
+	if (nr == 0) {
+		err = -ENODEV;
+		goto out;
+	}
+
+	size = sizeof(struct armflash_info) +
+		sizeof(struct armflash_subdev_info) * nr;
+	info = kzalloc(size, GFP_KERNEL);
+	if (!info) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	if (plat && plat->init) {
+		err = plat->init();
+		if (err)
+			goto no_resource;
+	}
+
+	for (i = 0; i < nr; i++) {
+		struct armflash_subdev_info *subdev = &info->subdev[i];
+		struct resource *res;
+
+		res = platform_get_resource(dev, IORESOURCE_MEM, i);
+		if (!res)
+			break;
+
+		if (nr == 1)
+			/* No MTD concatenation, just use the default name */
+			snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s",
+				 dev_name(&dev->dev));
+		else
+			snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s-%d",
+				 dev_name(&dev->dev), i);
+		subdev->plat = plat;
+
+		err = armflash_subdev_probe(subdev, res);
+		if (err)
+			break;
+	}
+	info->nr_subdev = i;
+
+	if (err)
+		goto subdev_err;
+
+	if (info->nr_subdev == 1)
+		info->mtd = info->subdev[0].mtd;
+	else if (info->nr_subdev > 1) {
+#ifdef CONFIG_MTD_CONCAT
+		struct mtd_info *cdev[info->nr_subdev];
+
+		/*
+		 * We detected multiple devices.  Concatenate them together.
+		 */
+		for (i = 0; i < info->nr_subdev; i++)
+			cdev[i] = info->subdev[i].mtd;
+
+		info->mtd = mtd_concat_create(cdev, info->nr_subdev,
+					      dev_name(&dev->dev));
+		if (info->mtd == NULL)
+			err = -ENXIO;
+#else
+		printk(KERN_ERR "armflash: multiple devices found but "
+		       "MTD concat support disabled.\n");
+		err = -ENXIO;
+#endif
+	}
+
+	if (err < 0)
+		goto cleanup;

 	err = parse_mtd_partitions(info->mtd, probes, &info->parts, 0);
 	if (err > 0) {
@@ -131,28 +227,30 @@
 			       "mtd partition registration failed: %d\n", err);
 	}

-	if (err == 0)
+	if (err == 0) {
 		platform_set_drvdata(dev, info);
+		return err;
+	}

 	/*
-	 * If we got an error, free all resources.
+	 * We got an error, free all resources.
 	 */
-	if (err < 0) {
-		if (info->mtd) {
-			del_mtd_partitions(info->mtd);
-			map_destroy(info->mtd);
-		}
-		kfree(info->parts);
-
- no_device:
-		iounmap(base);
- no_mem:
-		release_mem_region(res->start, size);
+ cleanup:
+	if (info->mtd) {
+		del_mtd_partitions(info->mtd);
+#ifdef CONFIG_MTD_CONCAT
+		if (info->mtd != info->subdev[0].mtd)
+			mtd_concat_destroy(info->mtd);
+#endif
+	}
+	kfree(info->parts);
+ subdev_err:
+	for (i = info->nr_subdev - 1; i >= 0; i--)
+		armflash_subdev_remove(&info->subdev[i]);
  no_resource:
-		if (plat && plat->exit)
-			plat->exit();
-		kfree(info);
-	}
+	if (plat && plat->exit)
+		plat->exit();
+	kfree(info);
  out:
 	return err;
 }
@@ -160,22 +258,26 @@
 static int armflash_remove(struct platform_device *dev)
 {
 	struct armflash_info *info = platform_get_drvdata(dev);
+	struct flash_platform_data *plat = dev->dev.platform_data;
+	int i;

 	platform_set_drvdata(dev, NULL);

 	if (info) {
 		if (info->mtd) {
 			del_mtd_partitions(info->mtd);
-			map_destroy(info->mtd);
+#ifdef CONFIG_MTD_CONCAT
+			if (info->mtd != info->subdev[0].mtd)
+				mtd_concat_destroy(info->mtd);
+#endif
 		}
 		kfree(info->parts);

-		iounmap(info->map.virt);
-		release_resource(info->res);
-		kfree(info->res);
-
-		if (info->plat && info->plat->exit)
-			info->plat->exit();
+		for (i = info->nr_subdev - 1; i >= 0; i--)
+			armflash_subdev_remove(&info->subdev[i]);
+
+		if (plat && plat->exit)
+			plat->exit();

 		kfree(info);
 	}


mtd: tests: mtd_nandbiterrs: replace msg macro with pr_{info,err}

Use pr_fmt instead of msg macro

Signed-off-by: Vikram Narayanan <6fb9d67c30a5971c642c9e795c13bd70b1391f75@gmail.com>
Signed-off-by: Artem Bityutskiy <2f96f8cd3e2780a209d0ab27d1b44624d0019d3f@linux.intel.com>

--- drivers/mtd/tests/mtd_nandbiterrs.c
+++ drivers/mtd/tests/mtd_nandbiterrs.c
@@ -39,6 +39,9 @@
  * this program; see the file COPYING. If not, write to the Free Software
  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
+
+#define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -46,8 +49,6 @@
 #include <linux/err.h>
 #include <linux/mtd/nand.h>
 #include <linux/slab.h>
-
-#define msg(FMT, VA...) pr_info("mtd_nandbiterrs: "FMT, ##VA)

 static int dev;
 module_param(dev, int, S_IRUGO);
@@ -103,7 +104,7 @@
 	struct erase_info ei;
 	loff_t addr = eraseblock * mtd->erasesize;

-	msg("erase_block\n");
+	pr_info("erase_block\n");

 	memset(&ei, 0, sizeof(struct erase_info));
 	ei.mtd  = mtd;
@@ -112,7 +113,7 @@

 	err = mtd_erase(mtd, &ei);
 	if (err || ei.state == MTD_ERASE_FAILED) {
-		msg("error %d while erasing\n", err);
+		pr_err("error %d while erasing\n", err);
 		if (!err)
 			err = -EIO;
 		return err;
@@ -128,11 +129,11 @@
 	size_t written;

 	if (log)
-		msg("write_page\n");
+		pr_info("write_page\n");

 	err = mtd_write(mtd, offset, mtd->writesize, &written, wbuffer);
 	if (err || written != mtd->writesize) {
-		msg("error: write failed at %#llx\n", (long long)offset);
+		pr_err("error: write failed at %#llx\n", (long long)offset);
 		if (!err)
 			err = -EIO;
 	}
@@ -147,7 +148,7 @@
 	struct mtd_oob_ops ops;

 	if (log)
-		msg("rewrite page\n");
+		pr_info("rewrite page\n");

 	ops.mode      = MTD_OPS_RAW; /* No ECC */
 	ops.len       = mtd->writesize;
@@ -160,7 +161,7 @@

 	err = mtd_write_oob(mtd, offset, &ops);
 	if (err || ops.retlen != mtd->writesize) {
-		msg("error: write_oob failed (%d)\n", err);
+		pr_err("error: write_oob failed (%d)\n", err);
 		if (!err)
 			err = -EIO;
 	}
@@ -177,7 +178,7 @@
 	struct mtd_ecc_stats oldstats;

 	if (log)
-		msg("read_page\n");
+		pr_info("read_page\n");

 	/* Saving last mtd stats */
 	memcpy(&oldstats, &mtd->ecc_stats, sizeof(oldstats));
@@ -187,7 +188,7 @@
 		err = mtd->ecc_stats.corrected - oldstats.corrected;

 	if (err < 0 || read != mtd->writesize) {
-		msg("error: read failed at %#llx\n", (long long)offset);
+		pr_err("error: read failed at %#llx\n", (long long)offset);
 		if (err >= 0)
 			err = -EIO;
 	}
@@ -201,11 +202,11 @@
 	unsigned i, errs = 0;

 	if (log)
-		msg("verify_page\n");
+		pr_info("verify_page\n");

 	for (i = 0; i < mtd->writesize; i++) {
 		if (rbuffer[i] != hash(i+seed)) {
-			msg("Error: page offset %u, expected %02x, got %02x\n",
+			pr_err("Error: page offset %u, expected %02x, got %02x\n",
 				i, hash(i+seed), rbuffer[i]);
 			errs++;
 		}
@@ -230,13 +231,13 @@
 		for (bit = 7; bit >= 0; bit--) {
 			if (CBIT(wbuffer[byte], bit)) {
 				BCLR(wbuffer[byte], bit);
-				msg("Inserted biterror @ %u/%u\n", byte, bit);
+				pr_info("Inserted biterror @ %u/%u\n", byte, bit);
 				return 0;
 			}
 		}
 		byte++;
 	}
-	msg("biterror: Failed to find a '1' bit\n");
+	pr_err("biterror: Failed to find a '1' bit\n");
 	return -EIO;
 }

@@ -248,7 +249,7 @@
 	unsigned i;
 	unsigned errs_per_subpage = 0;

-	msg("incremental biterrors test\n");
+	pr_info("incremental biterrors test\n");

 	for (i = 0; i < mtd->writesize; i++)
 		wbuffer[i] = hash(i+seed);
@@ -265,9 +266,9 @@

 		err = read_page(1);
 		if (err > 0)
-			msg("Read reported %d corrected bit errors\n", err);
+			pr_info("Read reported %d corrected bit errors\n", err);
 		if (err < 0) {
-			msg("After %d biterrors per subpage, read reported error %d\n",
+			pr_err("After %d biterrors per subpage, read reported error %d\n",
 				errs_per_subpage, err);
 			err = 0;
 			goto exit;
@@ -275,11 +276,11 @@

 		err = verify_page(1);
 		if (err) {
-			msg("ECC failure, read data is incorrect despite read success\n");
+			pr_err("ECC failure, read data is incorrect despite read success\n");
 			goto exit;
 		}

-		msg("Successfully corrected %d bit errors per subpage\n",
+		pr_info("Successfully corrected %d bit errors per subpage\n",
 			errs_per_subpage);

 		for (i = 0; i < subcount; i++) {
@@ -311,7 +312,7 @@

 	memset(bitstats, 0, sizeof(bitstats));

-	msg("overwrite biterrors test\n");
+	pr_info("overwrite biterrors test\n");

 	for (i = 0; i < mtd->writesize; i++)
 		wbuffer[i] = hash(i+seed);
@@ -329,18 +330,18 @@
 		err = read_page(0);
 		if (err >= 0) {
 			if (err >= MAXBITS) {
-				msg("Implausible number of bit errors corrected\n");
+				pr_info("Implausible number of bit errors corrected\n");
 				err = -EIO;
 				break;
 			}
 			bitstats[err]++;
 			if (err > max_corrected) {
 				max_corrected = err;
-				msg("Read reported %d corrected bit errors\n",
+				pr_info("Read reported %d corrected bit errors\n",
 					err);
 			}
 		} else { /* err < 0 */
-			msg("Read reported error %d\n", err);
+			pr_info("Read reported error %d\n", err);
 			err = 0;
 			break;
 		}
@@ -348,7 +349,7 @@
 		err = verify_page(0);
 		if (err) {
 			bitstats[max_corrected] = opno;
-			msg("ECC failure, read data is incorrect despite read success\n");
+			pr_info("ECC failure, read data is incorrect despite read success\n");
 			break;
 		}

@@ -357,9 +358,9 @@

 	/* At this point bitstats[0] contains the number of ops with no bit
 	 * errors, bitstats[1] the number of ops with 1 bit error, etc. */
-	msg("Bit error histogram (%d operations total):\n", opno);
+	pr_info("Bit error histogram (%d operations total):\n", opno);
 	for (i = 0; i < max_corrected; i++)
-		msg("Page reads with %3d corrected bit errors: %d\n",
+		pr_info("Page reads with %3d corrected bit errors: %d\n",
 			i, bitstats[i]);

 exit:
@@ -370,36 +371,36 @@
 {
 	int err = 0;

-	msg("\n");
-	msg("==================================================\n");
-	msg("MTD device: %d\n", dev);
+	printk("\n");
+	printk(KERN_INFO "==================================================\n");
+	pr_info("MTD device: %d\n", dev);

 	mtd = get_mtd_device(NULL, dev);
 	if (IS_ERR(mtd)) {
 		err = PTR_ERR(mtd);
-		msg("error: cannot get MTD device\n");
+		pr_err("error: cannot get MTD device\n");
 		goto exit_mtddev;
 	}

 	if (mtd->type != MTD_NANDFLASH) {
-		msg("this test requires NAND flash\n");
+		pr_info("this test requires NAND flash\n");
 		err = -ENODEV;
 		goto exit_nand;
 	}

-	msg("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n",
+	pr_info("MTD device size %llu, eraseblock=%u, page=%u, oob=%u\n",
 		(unsigned long long)mtd->size, mtd->erasesize,
 		mtd->writesize, mtd->oobsize);

 	subsize  = mtd->writesize >> mtd->subpage_sft;
 	subcount = mtd->writesize / subsize;

-	msg("Device uses %d subpages of %d bytes\n", subcount, subsize);
+	pr_info("Device uses %d subpages of %d bytes\n", subcount, subsize);

 	offset     = page_offset * mtd->writesize;
 	eraseblock = mtd_div_by_eb(offset, mtd);

-	msg("Using page=%u, offset=%llu, eraseblock=%u\n",
+	pr_info("Using page=%u, offset=%llu, eraseblock=%u\n",
 		page_offset, offset, eraseblock);

 	wbuffer = kmalloc(mtd->writesize, GFP_KERNEL);
@@ -432,8 +433,8 @@
 		goto exit_error;

 	err = -EIO;
-	msg("finished successfully.\n");
-	msg("==================================================\n");
+	pr_info("finished successfully.\n");
+	printk(KERN_INFO "==================================================\n");

 exit_error:
 	kfree(rbuffer);


drivers/net/ethernet/amd/amd8111e.c: fix error return code

The function amd8111e_probe_one() return 0 for success and negative
value for most of its internal tests failures. There are two exceptions
that are error cases going to err_free_reg:. For this two cases, the
function abort its success execution path, but returns non negative
value, making it dificult for a caller function to notice the error.

This patch fixes the error cases that do not return negative values.

This was found by Coccinelle, but the code change was made by hand.
This patch is not robot generated.

A simplified version of the semantic match that finds this problem is
as follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>

Signed-off-by: Peter Senna Tschudin <d897b756ebf1c425d034f7458a172204a9625378@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/amd/amd8111e.c
+++ drivers/net/ethernet/amd/amd8111e.c
@@ -1845,6 +1845,7 @@
 	if((pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM))==0){
 		printk(KERN_ERR "amd8111e: No Power Management capability, "
 		       "exiting.\n");
+		err = -ENODEV;
 		goto err_free_reg;
 	}

@@ -1852,6 +1853,7 @@
 	if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) < 0) {
 		printk(KERN_ERR "amd8111e: DMA not supported,"
 			"exiting.\n");
+		err = -ENODEV;
 		goto err_free_reg;
 	}


tg3: Don't turn off led on 5719 serdes port 0

Turning off led on port 0 of the 5719 serdes causes all other ports to
lose power and stop functioning. Add tg3_phy_led_bug() function to check
for this condition. We use a switch() in tg3_phy_led_bug() for
consistency with the tg3_phy_power_bug() function.

Signed-off-by: Nithin Nayak Sujir <a41d72140302bfd55cac4982138967475b47eb43@broadcom.com>
Signed-off-by: Michael Chan <6b52f9d672b6134057900fe608467612b789a84e@broadcom.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


net: macb: DMA-unmap full rx-buffer

net: macb: DMA-unmap full rx-buffer

When allocating RX buffers a fixed size is used, while freeing is based
on actually received bytes, resulting in the following kernel warning
when CONFIG_DMA_API_DEBUG is enabled:
 WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:1051 check_unmap+0x258/0x894()
 macb e000b000.ethernet: DMA-API: device driver frees DMA memory with different size [device address=0x000000002d170040] [map size=1536 bytes] [unmap size=60 bytes]
 Modules linked in:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.14.0-rc3-xilinx-00220-g49f84081ce4f #65
 [<c001516c>] (unwind_backtrace) from [<c0011df8>] (show_stack+0x10/0x14)
 [<c0011df8>] (show_stack) from [<c03c775c>] (dump_stack+0x7c/0xc8)
 [<c03c775c>] (dump_stack) from [<c00245cc>] (warn_slowpath_common+0x60/0x84)
 [<c00245cc>] (warn_slowpath_common) from [<c0024670>] (warn_slowpath_fmt+0x2c/0x3c)
 [<c0024670>] (warn_slowpath_fmt) from [<c0227d44>] (check_unmap+0x258/0x894)
 [<c0227d44>] (check_unmap) from [<c0228588>] (debug_dma_unmap_page+0x64/0x70)
 [<c0228588>] (debug_dma_unmap_page) from [<c02ab78c>] (gem_rx+0x118/0x170)
 [<c02ab78c>] (gem_rx) from [<c02ac4d4>] (macb_poll+0x24/0x94)
 [<c02ac4d4>] (macb_poll) from [<c031222c>] (net_rx_action+0x6c/0x188)
 [<c031222c>] (net_rx_action) from [<c0028a28>] (__do_softirq+0x108/0x280)
 [<c0028a28>] (__do_softirq) from [<c0028e8c>] (irq_exit+0x84/0xf8)
 [<c0028e8c>] (irq_exit) from [<c000f360>] (handle_IRQ+0x68/0x8c)
 [<c000f360>] (handle_IRQ) from [<c0008528>] (gic_handle_irq+0x3c/0x60)
 [<c0008528>] (gic_handle_irq) from [<c0012904>] (__irq_svc+0x44/0x78)
 Exception stack(0xc056df20 to 0xc056df68)
 df20: 00000001 c0577430 00000000 c0577430 04ce8e0d 00000002 edfce238 00000000
 df40: 04e20f78 00000002 c05981f4 00000000 00000008 c056df68 c0064008 c02d7658
 df60: 20000013 ffffffff
 [<c0012904>] (__irq_svc) from [<c02d7658>] (cpuidle_enter_state+0x54/0xf8)
 [<c02d7658>] (cpuidle_enter_state) from [<c02d77dc>] (cpuidle_idle_call+0xe0/0x138)
 [<c02d77dc>] (cpuidle_idle_call) from [<c000f660>] (arch_cpu_idle+0x8/0x3c)
 [<c000f660>] (arch_cpu_idle) from [<c006bec4>] (cpu_startup_entry+0xbc/0x124)
 [<c006bec4>] (cpu_startup_entry) from [<c053daec>] (start_kernel+0x350/0x3b0)
 ---[ end trace d5fdc38641bd3a11 ]---
 Mapped at:
  [<c0227184>] debug_dma_map_page+0x48/0x11c
  [<c02ab32c>] gem_rx_refill+0x154/0x1f8
  [<c02ac7b4>] macb_open+0x270/0x3e0
  [<c03152e0>] __dev_open+0x7c/0xfc
  [<c031554c>] __dev_change_flags+0x8c/0x140

Fixing this by passing the same size which is passed during mapping the
memory to the unmap function as well.

Signed-off-by: Soren Brinkmann <f9793267bd24439886cd4a142f9642a9bcc6364b@xilinx.com>
Reviewed-by: Ben Hutchings <73675debcd8a436be48ec22211dcf44fe0df0a64@decadent.org.uk>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


tile: support rx_dropped/rx_errors in tilepro net driver

Signed-off-by: Chris Metcalf <074881f6f5da4d3b5278870ff234d1077ee622c0@tilera.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


qlcnic: fix pause params setting

qlcnic: fix pause params setting

Turning off rx pause param and autoneg param is not supported so
return error in that case.

Signed-off-by: Rajesh Borundia <bf4458971067a5015f487add5635a29856262b3e@qlogic.com>
Signed-off-by: Amit Kumar Salecha <b95978a93e8c5cd598a905aeb6b4a5c23933265e@qlogic.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/qlcnic/qlcnic_ethtool.c
+++ drivers/net/qlcnic/qlcnic_ethtool.c
@@ -578,8 +578,12 @@
 		}
 		QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val);
 	} else if (adapter->ahw.port_type == QLCNIC_XGBE) {
+		if (!pause->rx_pause || pause->autoneg)
+			return -EOPNOTSUPP;
+
 		if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS))
 			return -EIO;
+
 		val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL);
 		if (port == 0) {
 			if (pause->tx_pause)