* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
@ 2004-11-02 10:55 ` Carlo Perassi
2004-11-02 22:16 ` Felipe W Damasio
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-02 10:55 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 110 bytes --]
Hi
this version fix the diff absolute path (2 lines differs)
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: unsigned_drivers_net_tg3_a.patch --]
[-- Type: text/plain, Size: 10299 bytes --]
Signed-off-by: Carlo Perassi <carlo@linux.it>
---
--- linux-2.6.10-rc1-orig/drivers/net/tg3.c 2004-10-23 18:34:24.000000000 +0200
+++ linux-2.6.10-rc1/drivers/net/tg3.c 2004-11-01 23:11:18.000000000 +0100
@@ -471,7 +471,8 @@ static void tg3_switch_clocks(struct tg3
static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -573,7 +575,8 @@ static void tg3_phy_set_wirespeed(struct
static int tg3_bmcr_reset(struct tg3 *tp)
{
u32 phy_control;
- int limit, err;
+ int err;
+ unsigned int limit;
/* OK, reset it, and poll the BMCR_RESET bit until it
* clears or we time out.
@@ -595,7 +598,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
}
udelay(10);
}
- if (limit <= 0)
+ if (!limit)
return -EBUSY;
return 0;
@@ -603,7 +606,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
static int tg3_wait_macro_done(struct tg3 *tp)
{
- int limit = 100;
+ unsigned int limit = 100;
while (limit--) {
u32 tmp32;
@@ -612,7 +615,7 @@ static int tg3_wait_macro_done(struct tg
if ((tmp32 & 0x1000) == 0)
break;
}
- if (limit <= 0)
+ if (!limit)
return -EBUSY;
return 0;
@@ -626,10 +629,10 @@ static int tg3_phy_write_and_check_testp
{ 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
{ 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
};
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -671,7 +674,7 @@ static int tg3_phy_write_and_check_testp
low &= 0x7fff;
high &= 0x000f;
if (low != test_pat[chan][i] ||
- high != test_pat[chan][i+1]) {
+ high != test_pat[chan][i + 1]) {
tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
@@ -686,10 +689,10 @@ static int tg3_phy_write_and_check_testp
static int tg3_phy_reset_chanpat(struct tg3 *tp)
{
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -707,7 +710,8 @@ static int tg3_phy_reset_chanpat(struct
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
{
u32 reg32, phy9_orig;
- int retries, do_phy_reset, err;
+ int retries, err;
+ unsigned int do_phy_reset;
retries = 10;
do_phy_reset = 1;
@@ -1213,7 +1217,7 @@ static void tg3_aux_stat_to_speed_duplex
static int tg3_phy_copper_begin(struct tg3 *tp)
{
u32 new_adv;
- int i;
+ unsigned int i;
if (tp->link_config.phy_is_low_power) {
/* Entering low power mode. Disable gigabit and
@@ -1401,11 +1405,11 @@ static int tg3_copper_is_advertising_all
static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
{
- int current_link_up;
u32 bmsr, dummy;
u16 current_speed;
u8 current_duplex;
- int i, err;
+ int err;
+ unsigned int current_link_up, i;
tw32(MAC_EVENT, 0);
@@ -1989,9 +1993,9 @@ static int tg3_fiber_aneg_smachine(struc
static int fiber_autoneg(struct tg3 *tp, u32 *flags)
{
- int res = 0;
struct tg3_fiber_aneginfo aninfo;
int status = ANEG_FAILED;
+ unsigned int res = 0;
unsigned int tick;
u32 tmp;
@@ -2034,7 +2038,7 @@ static int fiber_autoneg(struct tg3 *tp,
static void tg3_init_bcm8002(struct tg3 *tp)
{
u32 mac_status = tr32(MAC_STATUS);
- int i;
+ unsigned int i;
/* Reset when initting first time or we have a link. */
if ((tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) &&
@@ -2085,8 +2089,7 @@ static int tg3_setup_fiber_hw_autoneg(st
{
u32 sg_dig_ctrl, sg_dig_status;
u32 serdes_cfg, expected_sg_dig_ctrl;
- int workaround, port_a;
- int current_link_up;
+ unsigned int current_link_up, port_a, workaround;
serdes_cfg = 0;
expected_sg_dig_ctrl = 0;
@@ -2194,7 +2197,7 @@ out:
static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
{
- int current_link_up = 0;
+ unsigned int current_link_up = 0;
if (!(mac_status & MAC_STATUS_PCS_SYNCED)) {
tp->tg3_flags &= ~TG3_FLAG_GOT_SERDES_FLOWCTL;
@@ -2257,7 +2260,7 @@ static int tg3_setup_fiber_phy(struct tg
u8 orig_active_duplex;
u32 mac_status;
int current_link_up;
- int i;
+ unsigned int i;
orig_pause_cfg =
(tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
@@ -2533,7 +2536,7 @@ static void tg3_recycle_rx(struct tg3 *t
{
struct tg3_rx_buffer_desc *src_desc, *dest_desc;
struct ring_info *src_map, *dest_map;
- int dest_idx;
+ unsigned int dest_idx;
switch (opaque_key) {
case RXD_OPAQUE_RING_STD:
@@ -2601,7 +2604,7 @@ static int tg3_rx(struct tg3 *tp, int bu
u32 work_mask;
u32 rx_rcb_ptr = tp->rx_rcb_ptr;
u16 hw_idx, sw_idx;
- int received;
+ unsigned int received;
hw_idx = tp->hw_status->idx[0].rx_producer;
/*
@@ -2739,7 +2742,7 @@ static int tg3_poll(struct net_device *n
struct tg3 *tp = netdev_priv(netdev);
struct tg3_hw_status *sblk = tp->hw_status;
unsigned long flags;
- int done;
+ unsigned int done;
spin_lock_irqsave(&tp->lock, flags);
@@ -2962,7 +2965,7 @@ static void tg3_set_txd(struct tg3 *tp,
u32 mss_and_is_end)
{
struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
- int is_end = (mss_and_is_end & 0x1);
+ unsigned int is_end = (mss_and_is_end & 0x1);
u32 mss = (mss_and_is_end >> 1);
u32 vlan_tag = 0;
@@ -3238,7 +3241,7 @@ static int tg3_change_mtu(struct net_dev
static void tg3_free_rings(struct tg3 *tp)
{
struct ring_info *rxp;
- int i;
+ unsigned int i;
for (i = 0; i < TG3_RX_RING_SIZE; i++) {
rxp = &tp->rx_std_buffers[i];
@@ -3528,7 +3531,8 @@ static int tg3_stop_block(struct tg3 *tp
/* tp->lock is held. */
static int tg3_abort_hw(struct tg3 *tp)
{
- int i, err;
+ int err;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -3597,7 +3601,7 @@ out:
static int tg3_nvram_lock(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_NVRAM) {
- int i;
+ unsigned int i;
tw32(NVRAM_SWARB, SWARB_REQ_SET1);
for (i = 0; i < 8000; i++) {
@@ -3701,7 +3705,7 @@ static int tg3_chip_reset(struct tg3 *tp
{
u32 val;
u32 flags_save;
- int i;
+ unsigned int i;
if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
tg3_nvram_lock(tp);
@@ -3763,7 +3767,7 @@ static int tg3_chip_reset(struct tg3 *tp
if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
- int i;
+ unsigned int i;
u32 cfg_val;
/* Wait for link training to complete. */
@@ -3871,7 +3875,7 @@ static void tg3_stop_fw(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
u32 val;
- int i;
+ unsigned int i;
tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
val = tr32(GRC_RX_CPU_EVENT);
@@ -4040,7 +4044,7 @@ u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(
/* tp->lock is held. */
static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
{
- int i;
+ unsigned int i;
if (offset == TX_CPU_BASE &&
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
@@ -4152,7 +4156,8 @@ out:
static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
{
struct fw_info info;
- int err, i;
+ int err;
+ unsigned int i;
info.text_base = TG3_FW_TEXT_ADDR;
info.text_len = TG3_FW_TEXT_LEN;
@@ -4711,7 +4716,8 @@ static int tg3_load_tso_firmware(struct
{
struct fw_info info;
unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
- int err, i;
+ int err;
+ unsigned int i;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
return 0;
@@ -4784,7 +4790,7 @@ static int tg3_load_tso_firmware(struct
static void __tg3_set_mac_addr(struct tg3 *tp)
{
u32 addr_high, addr_low;
- int i;
+ unsigned int i;
addr_high = ((tp->dev->dev_addr[0] << 8) |
tp->dev->dev_addr[1]);
@@ -4857,7 +4863,8 @@ static void __tg3_set_rx_mode(struct net
static int tg3_reset_hw(struct tg3 *tp)
{
u32 val, rdmac_mode;
- int i, err, limit;
+ int err, limit;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -6136,7 +6143,7 @@ static inline u32 calc_crc(unsigned char
{
u32 reg;
u32 tmp;
- int j, k;
+ unsigned int j, k;
reg = 0xffffffff;
@@ -6802,7 +6809,7 @@ static struct ethtool_ops tg3_ethtool_op
/* Chips other than 5700/5701 use the NVRAM for fetching info. */
static void __devinit tg3_nvram_init(struct tg3 *tp)
{
- int j;
+ unsigned int j;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
return;
@@ -6856,7 +6863,7 @@ static int tg3_nvram_read_using_eeprom(s
u32 offset, u32 *val)
{
u32 tmp;
- int i;
+ unsigned int i;
if (offset > EEPROM_ADDR_ADDR_MASK ||
(offset % 4) != 0)
@@ -6889,7 +6896,7 @@ static int tg3_nvram_read_using_eeprom(s
static int __devinit tg3_nvram_read(struct tg3 *tp,
u32 offset, u32 *val)
{
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
@@ -6989,7 +6996,7 @@ static struct subsys_tbl_ent subsys_id_t
static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
{
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(subsys_id_to_phy_id); i++) {
if ((subsys_id_to_phy_id[i].subsys_vendor ==
@@ -7225,7 +7232,7 @@ skip_phy_reset:
static void __devinit tg3_read_partno(struct tg3 *tp)
{
unsigned char vpd_data[256];
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
/* Sun decided not to put the necessary bits in the
@@ -7765,7 +7772,8 @@ static int __devinit tg3_do_test_dma(str
{
struct tg3_internal_buffer_desc test_desc;
u32 sram_dma_descs;
- int i, ret;
+ int ret;
+ unsigned int i;
sram_dma_descs = NIC_SRAM_DMA_DESC_POOL_BASE;
@@ -8106,7 +8114,8 @@ static int __devinit tg3_init_one(struct
unsigned long tg3reg_base, tg3reg_len;
struct net_device *dev;
struct tg3 *tp;
- int i, err, pci_using_dac, pm_cap;
+ int err, pm_cap;
+ unsigned int i, pci_using_dac;
if (tg3_version_printed++ == 0)
printk(KERN_INFO "%s", version);
[-- Attachment #3: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
2004-11-02 10:55 ` Carlo Perassi
@ 2004-11-02 22:16 ` Felipe W Damasio
2004-11-03 7:43 ` Carlo Perassi
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Felipe W Damasio @ 2004-11-02 22:16 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 393 bytes --]
Carlo,
Carlo Perassi wrote:
> static int fiber_autoneg(struct tg3 *tp, u32 *flags)
> {
> - int res = 0;
> struct tg3_fiber_aneginfo aninfo;
> int status = ANEG_FAILED;
> + unsigned int res = 0;
> unsigned int tick;
> u32 tmp;
pedantic comment: Shouldn't you change the function header to "static
unsigned int", instead of forcing a cast back to int on return?
Cheers,
Felipe
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
2004-11-02 10:55 ` Carlo Perassi
2004-11-02 22:16 ` Felipe W Damasio
@ 2004-11-03 7:43 ` Carlo Perassi
2004-11-03 10:37 ` Carlo Perassi
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-03 7:43 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
> pedantic comment: Shouldn't you change the function header to
> "static unsigned int", instead of forcing a cast back to int on return?
fiber_autoneg is called just one time
(in tg3_setup_fiber_by_hand as if (fiber_autoneg(...)))
so you are right
I will send a new version later
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (2 preceding siblings ...)
2004-11-03 7:43 ` Carlo Perassi
@ 2004-11-03 10:37 ` Carlo Perassi
2004-11-03 23:59 ` David S. Miller
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-03 10:37 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
> I will send a new version later
this new version
. modifies the return type of fiber_autoneg and tg3_rx
from int to unsigned int, after
. turn some unsigned int to the original int
compiled and tested
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: unsigned_drivers_net_tg3_b.patch --]
[-- Type: text/plain, Size: 10370 bytes --]
Signed-off-by: Carlo Perassi <carlo@linux.it>
---
--- linux-2.6.10-rc1-orig/drivers/net/tg3.c 2004-10-23 18:34:24.000000000 +0200
+++ linux-2.6.10-rc1-mod/drivers/net/tg3.c 2004-11-03 10:35:34.000000000 +0100
@@ -471,7 +471,8 @@ static void tg3_switch_clocks(struct tg3
static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -573,7 +575,8 @@ static void tg3_phy_set_wirespeed(struct
static int tg3_bmcr_reset(struct tg3 *tp)
{
u32 phy_control;
- int limit, err;
+ int err;
+ unsigned int limit;
/* OK, reset it, and poll the BMCR_RESET bit until it
* clears or we time out.
@@ -595,7 +598,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
}
udelay(10);
}
- if (limit <= 0)
+ if (!limit)
return -EBUSY;
return 0;
@@ -603,7 +606,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
static int tg3_wait_macro_done(struct tg3 *tp)
{
- int limit = 100;
+ unsigned int limit = 100;
while (limit--) {
u32 tmp32;
@@ -612,7 +615,7 @@ static int tg3_wait_macro_done(struct tg
if ((tmp32 & 0x1000) == 0)
break;
}
- if (limit <= 0)
+ if (!limit)
return -EBUSY;
return 0;
@@ -626,10 +629,10 @@ static int tg3_phy_write_and_check_testp
{ 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
{ 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
};
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -671,7 +674,7 @@ static int tg3_phy_write_and_check_testp
low &= 0x7fff;
high &= 0x000f;
if (low != test_pat[chan][i] ||
- high != test_pat[chan][i+1]) {
+ high != test_pat[chan][i + 1]) {
tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
@@ -686,10 +689,10 @@ static int tg3_phy_write_and_check_testp
static int tg3_phy_reset_chanpat(struct tg3 *tp)
{
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -707,7 +710,8 @@ static int tg3_phy_reset_chanpat(struct
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
{
u32 reg32, phy9_orig;
- int retries, do_phy_reset, err;
+ int retries, err;
+ unsigned int do_phy_reset;
retries = 10;
do_phy_reset = 1;
@@ -1213,7 +1217,7 @@ static void tg3_aux_stat_to_speed_duplex
static int tg3_phy_copper_begin(struct tg3 *tp)
{
u32 new_adv;
- int i;
+ unsigned int i;
if (tp->link_config.phy_is_low_power) {
/* Entering low power mode. Disable gigabit and
@@ -1401,11 +1405,11 @@ static int tg3_copper_is_advertising_all
static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
{
- int current_link_up;
u32 bmsr, dummy;
u16 current_speed;
u8 current_duplex;
- int i, err;
+ int err;
+ unsigned int current_link_up, i;
tw32(MAC_EVENT, 0);
@@ -1987,11 +1991,11 @@ static int tg3_fiber_aneg_smachine(struc
return ret;
}
-static int fiber_autoneg(struct tg3 *tp, u32 *flags)
+static unsigned int fiber_autoneg(struct tg3 *tp, u32 *flags)
{
- int res = 0;
struct tg3_fiber_aneginfo aninfo;
int status = ANEG_FAILED;
+ unsigned int res = 0;
unsigned int tick;
u32 tmp;
@@ -2034,7 +2038,7 @@ static int fiber_autoneg(struct tg3 *tp,
static void tg3_init_bcm8002(struct tg3 *tp)
{
u32 mac_status = tr32(MAC_STATUS);
- int i;
+ unsigned int i;
/* Reset when initting first time or we have a link. */
if ((tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) &&
@@ -2257,7 +2261,7 @@ static int tg3_setup_fiber_phy(struct tg
u8 orig_active_duplex;
u32 mac_status;
int current_link_up;
- int i;
+ unsigned int i;
orig_pause_cfg =
(tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
@@ -2533,7 +2537,7 @@ static void tg3_recycle_rx(struct tg3 *t
{
struct tg3_rx_buffer_desc *src_desc, *dest_desc;
struct ring_info *src_map, *dest_map;
- int dest_idx;
+ unsigned int dest_idx;
switch (opaque_key) {
case RXD_OPAQUE_RING_STD:
@@ -2596,12 +2600,12 @@ static int tg3_vlan_rx(struct tg3 *tp, s
* If both the host and chip were to write into the same ring, cache line
* eviction could occur since both entities want it in an exclusive state.
*/
-static int tg3_rx(struct tg3 *tp, int budget)
+static unsigned int tg3_rx(struct tg3 *tp, int budget)
{
u32 work_mask;
u32 rx_rcb_ptr = tp->rx_rcb_ptr;
u16 hw_idx, sw_idx;
- int received;
+ unsigned int received;
hw_idx = tp->hw_status->idx[0].rx_producer;
/*
@@ -2739,7 +2743,7 @@ static int tg3_poll(struct net_device *n
struct tg3 *tp = netdev_priv(netdev);
struct tg3_hw_status *sblk = tp->hw_status;
unsigned long flags;
- int done;
+ unsigned int done;
spin_lock_irqsave(&tp->lock, flags);
@@ -2770,7 +2774,7 @@ static int tg3_poll(struct net_device *n
done = 1;
if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) {
int orig_budget = *budget;
- int work_done;
+ unsigned int work_done;
if (orig_budget > netdev->quota)
orig_budget = netdev->quota;
@@ -2962,7 +2966,7 @@ static void tg3_set_txd(struct tg3 *tp,
u32 mss_and_is_end)
{
struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
- int is_end = (mss_and_is_end & 0x1);
+ unsigned int is_end = (mss_and_is_end & 0x1);
u32 mss = (mss_and_is_end >> 1);
u32 vlan_tag = 0;
@@ -3238,7 +3242,7 @@ static int tg3_change_mtu(struct net_dev
static void tg3_free_rings(struct tg3 *tp)
{
struct ring_info *rxp;
- int i;
+ unsigned int i;
for (i = 0; i < TG3_RX_RING_SIZE; i++) {
rxp = &tp->rx_std_buffers[i];
@@ -3528,7 +3532,8 @@ static int tg3_stop_block(struct tg3 *tp
/* tp->lock is held. */
static int tg3_abort_hw(struct tg3 *tp)
{
- int i, err;
+ int err;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -3597,7 +3602,7 @@ out:
static int tg3_nvram_lock(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_NVRAM) {
- int i;
+ unsigned int i;
tw32(NVRAM_SWARB, SWARB_REQ_SET1);
for (i = 0; i < 8000; i++) {
@@ -3701,7 +3706,7 @@ static int tg3_chip_reset(struct tg3 *tp
{
u32 val;
u32 flags_save;
- int i;
+ unsigned int i;
if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
tg3_nvram_lock(tp);
@@ -3763,7 +3768,7 @@ static int tg3_chip_reset(struct tg3 *tp
if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
- int i;
+ unsigned int i;
u32 cfg_val;
/* Wait for link training to complete. */
@@ -3871,7 +3876,7 @@ static void tg3_stop_fw(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
u32 val;
- int i;
+ unsigned int i;
tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
val = tr32(GRC_RX_CPU_EVENT);
@@ -4040,7 +4045,7 @@ u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(
/* tp->lock is held. */
static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
{
- int i;
+ unsigned int i;
if (offset == TX_CPU_BASE &&
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
@@ -4152,7 +4157,8 @@ out:
static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
{
struct fw_info info;
- int err, i;
+ int err;
+ unsigned int i;
info.text_base = TG3_FW_TEXT_ADDR;
info.text_len = TG3_FW_TEXT_LEN;
@@ -4711,7 +4717,8 @@ static int tg3_load_tso_firmware(struct
{
struct fw_info info;
unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
- int err, i;
+ int err;
+ unsigned int i;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
return 0;
@@ -4784,7 +4791,7 @@ static int tg3_load_tso_firmware(struct
static void __tg3_set_mac_addr(struct tg3 *tp)
{
u32 addr_high, addr_low;
- int i;
+ unsigned int i;
addr_high = ((tp->dev->dev_addr[0] << 8) |
tp->dev->dev_addr[1]);
@@ -4857,7 +4864,8 @@ static void __tg3_set_rx_mode(struct net
static int tg3_reset_hw(struct tg3 *tp)
{
u32 val, rdmac_mode;
- int i, err, limit;
+ int err, limit;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -6136,7 +6144,7 @@ static inline u32 calc_crc(unsigned char
{
u32 reg;
u32 tmp;
- int j, k;
+ unsigned int j, k;
reg = 0xffffffff;
@@ -6802,7 +6810,7 @@ static struct ethtool_ops tg3_ethtool_op
/* Chips other than 5700/5701 use the NVRAM for fetching info. */
static void __devinit tg3_nvram_init(struct tg3 *tp)
{
- int j;
+ unsigned int j;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
return;
@@ -6856,7 +6864,7 @@ static int tg3_nvram_read_using_eeprom(s
u32 offset, u32 *val)
{
u32 tmp;
- int i;
+ unsigned int i;
if (offset > EEPROM_ADDR_ADDR_MASK ||
(offset % 4) != 0)
@@ -6889,7 +6897,7 @@ static int tg3_nvram_read_using_eeprom(s
static int __devinit tg3_nvram_read(struct tg3 *tp,
u32 offset, u32 *val)
{
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
@@ -6989,7 +6997,7 @@ static struct subsys_tbl_ent subsys_id_t
static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
{
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(subsys_id_to_phy_id); i++) {
if ((subsys_id_to_phy_id[i].subsys_vendor ==
@@ -7225,7 +7233,7 @@ skip_phy_reset:
static void __devinit tg3_read_partno(struct tg3 *tp)
{
unsigned char vpd_data[256];
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
/* Sun decided not to put the necessary bits in the
@@ -7765,7 +7773,8 @@ static int __devinit tg3_do_test_dma(str
{
struct tg3_internal_buffer_desc test_desc;
u32 sram_dma_descs;
- int i, ret;
+ int ret;
+ unsigned int i;
sram_dma_descs = NIC_SRAM_DMA_DESC_POOL_BASE;
@@ -8106,7 +8115,8 @@ static int __devinit tg3_init_one(struct
unsigned long tg3reg_base, tg3reg_len;
struct net_device *dev;
struct tg3 *tp;
- int i, err, pci_using_dac, pm_cap;
+ int err, pm_cap;
+ unsigned int i, pci_using_dac;
if (tg3_version_printed++ == 0)
printk(KERN_INFO "%s", version);
[-- Attachment #3: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (3 preceding siblings ...)
2004-11-03 10:37 ` Carlo Perassi
@ 2004-11-03 23:59 ` David S. Miller
2004-11-04 9:35 ` Carlo Perassi
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: David S. Miller @ 2004-11-03 23:59 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 865 bytes --]
On Wed, 3 Nov 2004 11:37:26 +0100
Carlo Perassi <carlo@linux.it> wrote:
> compiled and tested
Did you test with one of these hardware polling loops
actually timing out? I bet the new version wouldn't
work properly.
The 'limit' variables need to be signed, because the
loops are coded like this:
int limit = 100;
while (limit--) {
...
}
if (limit <= 0)
goto fail;
Therefore, on the last iteration, limit will still be decremented
past zero when it hits zero. Now you've changed it to:
unsigned int limit = 100;
while (limit--) {
...
}
if (!limit)
goto fail;
That's not the same. This new test will only pass if
we take (100 - 1) iterations through the loop. It
should pass if we take 100 or more iterations through
the loop.
Actually, the existing tests are wrong and have an off-by-1
error as well, they should all be "if (limit < 0)"
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (4 preceding siblings ...)
2004-11-03 23:59 ` David S. Miller
@ 2004-11-04 9:35 ` Carlo Perassi
2004-11-08 8:07 ` Carlo Perassi
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-04 9:35 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 584 bytes --]
> Actually, the existing tests are wrong and have an off-by-1
> error as well, they should all be "if (limit < 0)"
When I wrote "tested" I mean I used (and I'm still using) for some days
a kernel with these changes without finding weakness in its behavior or
something alike.
You are right about the actual errors and my errors too (and the snippet
you talked about is the only non that trivial part of the patch, and it
was wrong :P)
Please let me know if you'd like a new version without the "if"s or not.
Thanks for your email.
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (5 preceding siblings ...)
2004-11-04 9:35 ` Carlo Perassi
@ 2004-11-08 8:07 ` Carlo Perassi
2004-11-11 22:54 ` David S. Miller
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-08 8:07 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
> Please let me know if you'd like a new version without the "if"s or not.
this is the new version with the discussed changes
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: unsigned_drivers_net_tg3_c.patch --]
[-- Type: text/plain, Size: 9916 bytes --]
Signed-off-by: Carlo Perassi <carlo@linux.it>
---
--- linux-2.6.10-rc1-orig/drivers/net/tg3.c 2004-10-23 18:34:24.000000000 +0200
+++ linux-2.6.10-rc1-mod/drivers/net/tg3.c 2004-11-03 10:35:34.000000000 +0100
@@ -471,7 +471,8 @@ static void tg3_switch_clocks(struct tg3
static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -595,7 +597,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
}
udelay(10);
}
- if (limit <= 0)
+ if (limit < 0)
return -EBUSY;
return 0;
@@ -612,7 +614,7 @@ static int tg3_wait_macro_done(struct tg
if ((tmp32 & 0x1000) == 0)
break;
}
- if (limit <= 0)
+ if (limit < 0)
return -EBUSY;
return 0;
@@ -626,10 +628,10 @@ static int tg3_phy_write_and_check_testp
{ 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
{ 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
};
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -671,7 +673,7 @@ static int tg3_phy_write_and_check_testp
low &= 0x7fff;
high &= 0x000f;
if (low != test_pat[chan][i] ||
- high != test_pat[chan][i+1]) {
+ high != test_pat[chan][i + 1]) {
tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
@@ -686,10 +688,10 @@ static int tg3_phy_write_and_check_testp
static int tg3_phy_reset_chanpat(struct tg3 *tp)
{
- int chan;
+ unsigned int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -707,7 +709,8 @@ static int tg3_phy_reset_chanpat(struct
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
{
u32 reg32, phy9_orig;
- int retries, do_phy_reset, err;
+ int retries, err;
+ unsigned int do_phy_reset;
retries = 10;
do_phy_reset = 1;
@@ -1213,7 +1216,7 @@ static void tg3_aux_stat_to_speed_duplex
static int tg3_phy_copper_begin(struct tg3 *tp)
{
u32 new_adv;
- int i;
+ unsigned int i;
if (tp->link_config.phy_is_low_power) {
/* Entering low power mode. Disable gigabit and
@@ -1401,11 +1404,11 @@ static int tg3_copper_is_advertising_all
static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
{
- int current_link_up;
u32 bmsr, dummy;
u16 current_speed;
u8 current_duplex;
- int i, err;
+ int err;
+ unsigned int current_link_up, i;
tw32(MAC_EVENT, 0);
@@ -1987,11 +1990,11 @@ static int tg3_fiber_aneg_smachine(struc
return ret;
}
-static int fiber_autoneg(struct tg3 *tp, u32 *flags)
+static unsigned int fiber_autoneg(struct tg3 *tp, u32 *flags)
{
- int res = 0;
struct tg3_fiber_aneginfo aninfo;
int status = ANEG_FAILED;
+ unsigned int res = 0;
unsigned int tick;
u32 tmp;
@@ -2034,7 +2037,7 @@ static int fiber_autoneg(struct tg3 *tp,
static void tg3_init_bcm8002(struct tg3 *tp)
{
u32 mac_status = tr32(MAC_STATUS);
- int i;
+ unsigned int i;
/* Reset when initting first time or we have a link. */
if ((tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) &&
@@ -2257,7 +2260,7 @@ static int tg3_setup_fiber_phy(struct tg
u8 orig_active_duplex;
u32 mac_status;
int current_link_up;
- int i;
+ unsigned int i;
orig_pause_cfg =
(tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
@@ -2533,7 +2536,7 @@ static void tg3_recycle_rx(struct tg3 *t
{
struct tg3_rx_buffer_desc *src_desc, *dest_desc;
struct ring_info *src_map, *dest_map;
- int dest_idx;
+ unsigned int dest_idx;
switch (opaque_key) {
case RXD_OPAQUE_RING_STD:
@@ -2596,12 +2599,12 @@ static int tg3_vlan_rx(struct tg3 *tp, s
* If both the host and chip were to write into the same ring, cache line
* eviction could occur since both entities want it in an exclusive state.
*/
-static int tg3_rx(struct tg3 *tp, int budget)
+static unsigned int tg3_rx(struct tg3 *tp, int budget)
{
u32 work_mask;
u32 rx_rcb_ptr = tp->rx_rcb_ptr;
u16 hw_idx, sw_idx;
- int received;
+ unsigned int received;
hw_idx = tp->hw_status->idx[0].rx_producer;
/*
@@ -2739,7 +2742,7 @@ static int tg3_poll(struct net_device *n
struct tg3 *tp = netdev_priv(netdev);
struct tg3_hw_status *sblk = tp->hw_status;
unsigned long flags;
- int done;
+ unsigned int done;
spin_lock_irqsave(&tp->lock, flags);
@@ -2770,7 +2773,7 @@ static int tg3_poll(struct net_device *n
done = 1;
if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) {
int orig_budget = *budget;
- int work_done;
+ unsigned int work_done;
if (orig_budget > netdev->quota)
orig_budget = netdev->quota;
@@ -2962,7 +2965,7 @@ static void tg3_set_txd(struct tg3 *tp,
u32 mss_and_is_end)
{
struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
- int is_end = (mss_and_is_end & 0x1);
+ unsigned int is_end = (mss_and_is_end & 0x1);
u32 mss = (mss_and_is_end >> 1);
u32 vlan_tag = 0;
@@ -3238,7 +3241,7 @@ static int tg3_change_mtu(struct net_dev
static void tg3_free_rings(struct tg3 *tp)
{
struct ring_info *rxp;
- int i;
+ unsigned int i;
for (i = 0; i < TG3_RX_RING_SIZE; i++) {
rxp = &tp->rx_std_buffers[i];
@@ -3528,7 +3531,8 @@ static int tg3_stop_block(struct tg3 *tp
/* tp->lock is held. */
static int tg3_abort_hw(struct tg3 *tp)
{
- int i, err;
+ int err;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -3597,7 +3601,7 @@ out:
static int tg3_nvram_lock(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_NVRAM) {
- int i;
+ unsigned int i;
tw32(NVRAM_SWARB, SWARB_REQ_SET1);
for (i = 0; i < 8000; i++) {
@@ -3701,7 +3705,7 @@ static int tg3_chip_reset(struct tg3 *tp
{
u32 val;
u32 flags_save;
- int i;
+ unsigned int i;
if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
tg3_nvram_lock(tp);
@@ -3763,7 +3767,7 @@ static int tg3_chip_reset(struct tg3 *tp
if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
- int i;
+ unsigned int i;
u32 cfg_val;
/* Wait for link training to complete. */
@@ -3871,7 +3875,7 @@ static void tg3_stop_fw(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
u32 val;
- int i;
+ unsigned int i;
tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
val = tr32(GRC_RX_CPU_EVENT);
@@ -4040,7 +4044,7 @@ u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(
/* tp->lock is held. */
static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
{
- int i;
+ unsigned int i;
if (offset == TX_CPU_BASE &&
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
@@ -4152,7 +4156,8 @@ out:
static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
{
struct fw_info info;
- int err, i;
+ int err;
+ unsigned int i;
info.text_base = TG3_FW_TEXT_ADDR;
info.text_len = TG3_FW_TEXT_LEN;
@@ -4711,7 +4716,8 @@ static int tg3_load_tso_firmware(struct
{
struct fw_info info;
unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
- int err, i;
+ int err;
+ unsigned int i;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
return 0;
@@ -4784,7 +4790,7 @@ static int tg3_load_tso_firmware(struct
static void __tg3_set_mac_addr(struct tg3 *tp)
{
u32 addr_high, addr_low;
- int i;
+ unsigned int i;
addr_high = ((tp->dev->dev_addr[0] << 8) |
tp->dev->dev_addr[1]);
@@ -4857,7 +4863,8 @@ static void __tg3_set_rx_mode(struct net
static int tg3_reset_hw(struct tg3 *tp)
{
u32 val, rdmac_mode;
- int i, err, limit;
+ int err, limit;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -6136,7 +6143,7 @@ static inline u32 calc_crc(unsigned char
{
u32 reg;
u32 tmp;
- int j, k;
+ unsigned int j, k;
reg = 0xffffffff;
@@ -6802,7 +6809,7 @@ static struct ethtool_ops tg3_ethtool_op
/* Chips other than 5700/5701 use the NVRAM for fetching info. */
static void __devinit tg3_nvram_init(struct tg3 *tp)
{
- int j;
+ unsigned int j;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
return;
@@ -6856,7 +6863,7 @@ static int tg3_nvram_read_using_eeprom(s
u32 offset, u32 *val)
{
u32 tmp;
- int i;
+ unsigned int i;
if (offset > EEPROM_ADDR_ADDR_MASK ||
(offset % 4) != 0)
@@ -6889,7 +6896,7 @@ static int tg3_nvram_read_using_eeprom(s
static int __devinit tg3_nvram_read(struct tg3 *tp,
u32 offset, u32 *val)
{
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
@@ -6989,7 +6996,7 @@ static struct subsys_tbl_ent subsys_id_t
static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
{
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(subsys_id_to_phy_id); i++) {
if ((subsys_id_to_phy_id[i].subsys_vendor ==
@@ -7225,7 +7232,7 @@ skip_phy_reset:
static void __devinit tg3_read_partno(struct tg3 *tp)
{
unsigned char vpd_data[256];
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
/* Sun decided not to put the necessary bits in the
@@ -7765,7 +7772,8 @@ static int __devinit tg3_do_test_dma(str
{
struct tg3_internal_buffer_desc test_desc;
u32 sram_dma_descs;
- int i, ret;
+ int ret;
+ unsigned int i;
sram_dma_descs = NIC_SRAM_DMA_DESC_POOL_BASE;
@@ -8106,7 +8114,8 @@ static int __devinit tg3_init_one(struct
unsigned long tg3reg_base, tg3reg_len;
struct net_device *dev;
struct tg3 *tp;
- int i, err, pci_using_dac, pm_cap;
+ int err, pm_cap;
+ unsigned int i, pci_using_dac;
if (tg3_version_printed++ == 0)
printk(KERN_INFO "%s", version);
[-- Attachment #3: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (6 preceding siblings ...)
2004-11-08 8:07 ` Carlo Perassi
@ 2004-11-11 22:54 ` David S. Miller
2004-11-12 0:14 ` Stefan Sperling
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: David S. Miller @ 2004-11-11 22:54 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 754 bytes --]
On Mon, 8 Nov 2004 09:07:26 +0100
Carlo Perassi <carlo@linux.it> wrote:
> > Please let me know if you'd like a new version without the "if"s or not.
>
> this is the new version with the discussed changes
Carlo... please look at this carefully:
@@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -595,7 +597,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
}
udelay(10);
}
- if (limit <= 0)
+ if (limit < 0)
return -EBUSY;
How can an "unsigned" value every be less than zero?
Didn't the compiler even warn you about this?
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (7 preceding siblings ...)
2004-11-11 22:54 ` David S. Miller
@ 2004-11-12 0:14 ` Stefan Sperling
2004-11-12 10:27 ` Carlo Perassi
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Stefan Sperling @ 2004-11-12 0:14 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]
On Thu, Nov 11, 2004 at 02:54:20PM -0800, David S. Miller wrote:
> On Mon, 8 Nov 2004 09:07:26 +0100
> Carlo Perassi <carlo@linux.it> wrote:
>
> > > Please let me know if you'd like a new version without the "if"s or not.
> >
> > this is the new version with the discussed changes
>
> Carlo... please look at this carefully:
>
> @@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
> static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
> {
> u32 frame_val;
> - int loops, ret;
> + int ret;
> + unsigned int loops;
>
> if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
> tw32_f(MAC_MI_MODE,
> @@ -595,7 +597,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
> }
> udelay(10);
> }
> - if (limit <= 0)
> + if (limit < 0)
> return -EBUSY;
>
> How can an "unsigned" value every be less than zero?
> Didn't the compiler even warn you about this?
Er, where's the declaration of limit in the above code snippet?
;-)
stefan
--
Give me a fish and I will eat today.
Teach me to fish and I will eat forever.
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (8 preceding siblings ...)
2004-11-12 0:14 ` Stefan Sperling
@ 2004-11-12 10:27 ` Carlo Perassi
2004-11-12 11:29 ` Carlo Perassi
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-12 10:27 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 342 bytes --]
> How can an "unsigned" value every be less than zero?
> Didn't the compiler even warn you about this?
You are right but tg3_writephy (the original or the modified version)
does not contain the snippet the patch is referring to.
I'm going to see what is happened.
I will write later.
Thanks.
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (9 preceding siblings ...)
2004-11-12 10:27 ` Carlo Perassi
@ 2004-11-12 11:29 ` Carlo Perassi
2004-11-12 15:13 ` Carlo Perassi
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-12 11:29 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
> You are right but tg3_writephy (the original or the modified version)
It's not tg3_writephy the patch is referring.
Sorry.
I found what is happened.
Thanks again.
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (10 preceding siblings ...)
2004-11-12 11:29 ` Carlo Perassi
@ 2004-11-12 15:13 ` Carlo Perassi
2004-11-18 0:23 ` David S. Miller
2004-11-18 9:35 ` Carlo Perassi
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-12 15:13 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
I read the old patch: limit in tg3_bmcr_reset and tg3_wait_macro_done
was not defined as unsigned.
Anyway I compiled and tested this new patch.
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: unsigned_drivers_net_tg3_d.patch --]
[-- Type: text/plain, Size: 6923 bytes --]
Signed-off-by: Carlo Perassi <carlo@linux.it>
---
--- linux-2.6.10-rc1-orig/drivers/net/tg3.c 2004-10-22 23:39:40.000000000 +0200
+++ linux-2.6.10-rc1-mod/drivers/net/tg3.c 2004-11-12 15:39:22.000000000 +0100
@@ -471,7 +471,8 @@ static void tg3_switch_clocks(struct tg3
static int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -518,7 +519,8 @@ static int tg3_readphy(struct tg3 *tp, i
static int tg3_writephy(struct tg3 *tp, int reg, u32 val)
{
u32 frame_val;
- int loops, ret;
+ int ret;
+ unsigned int loops;
if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
tw32_f(MAC_MI_MODE,
@@ -595,7 +597,7 @@ static int tg3_bmcr_reset(struct tg3 *tp
}
udelay(10);
}
- if (limit <= 0)
+ if (limit < 0)
return -EBUSY;
return 0;
@@ -612,7 +614,7 @@ static int tg3_wait_macro_done(struct tg
if ((tmp32 & 0x1000) == 0)
break;
}
- if (limit <= 0)
+ if (limit < 0)
return -EBUSY;
return 0;
@@ -629,7 +631,7 @@ static int tg3_phy_write_and_check_testp
int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -689,7 +691,7 @@ static int tg3_phy_reset_chanpat(struct
int chan;
for (chan = 0; chan < 4; chan++) {
- int i;
+ unsigned int i;
tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
(chan * 0x2000) | 0x0200);
@@ -1213,7 +1215,7 @@ static void tg3_aux_stat_to_speed_duplex
static int tg3_phy_copper_begin(struct tg3 *tp)
{
u32 new_adv;
- int i;
+ unsigned int i;
if (tp->link_config.phy_is_low_power) {
/* Entering low power mode. Disable gigabit and
@@ -1405,7 +1407,8 @@ static int tg3_setup_copper_phy(struct t
u32 bmsr, dummy;
u16 current_speed;
u8 current_duplex;
- int i, err;
+ int err;
+ unsigned int i;
tw32(MAC_EVENT, 0);
@@ -2034,7 +2037,7 @@ static int fiber_autoneg(struct tg3 *tp,
static void tg3_init_bcm8002(struct tg3 *tp)
{
u32 mac_status = tr32(MAC_STATUS);
- int i;
+ unsigned int i;
/* Reset when initting first time or we have a link. */
if ((tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) &&
@@ -2257,7 +2260,7 @@ static int tg3_setup_fiber_phy(struct tg
u8 orig_active_duplex;
u32 mac_status;
int current_link_up;
- int i;
+ unsigned int i;
orig_pause_cfg =
(tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
@@ -2533,7 +2536,7 @@ static void tg3_recycle_rx(struct tg3 *t
{
struct tg3_rx_buffer_desc *src_desc, *dest_desc;
struct ring_info *src_map, *dest_map;
- int dest_idx;
+ unsigned int dest_idx;
switch (opaque_key) {
case RXD_OPAQUE_RING_STD:
@@ -2596,7 +2599,7 @@ static int tg3_vlan_rx(struct tg3 *tp, s
* If both the host and chip were to write into the same ring, cache line
* eviction could occur since both entities want it in an exclusive state.
*/
-static int tg3_rx(struct tg3 *tp, int budget)
+static unsigned int tg3_rx(struct tg3 *tp, int budget)
{
u32 work_mask;
u32 rx_rcb_ptr = tp->rx_rcb_ptr;
@@ -2739,7 +2742,7 @@ static int tg3_poll(struct net_device *n
struct tg3 *tp = netdev_priv(netdev);
struct tg3_hw_status *sblk = tp->hw_status;
unsigned long flags;
- int done;
+ unsigned int done;
spin_lock_irqsave(&tp->lock, flags);
@@ -3238,7 +3241,7 @@ static int tg3_change_mtu(struct net_dev
static void tg3_free_rings(struct tg3 *tp)
{
struct ring_info *rxp;
- int i;
+ unsigned int i;
for (i = 0; i < TG3_RX_RING_SIZE; i++) {
rxp = &tp->rx_std_buffers[i];
@@ -3528,7 +3531,8 @@ static int tg3_stop_block(struct tg3 *tp
/* tp->lock is held. */
static int tg3_abort_hw(struct tg3 *tp)
{
- int i, err;
+ int err;
+ unsigned int i;
tg3_disable_ints(tp);
@@ -3597,7 +3601,7 @@ out:
static int tg3_nvram_lock(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_NVRAM) {
- int i;
+ unsigned int i;
tw32(NVRAM_SWARB, SWARB_REQ_SET1);
for (i = 0; i < 8000; i++) {
@@ -3701,7 +3705,7 @@ static int tg3_chip_reset(struct tg3 *tp
{
u32 val;
u32 flags_save;
- int i;
+ unsigned int i;
if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
tg3_nvram_lock(tp);
@@ -3763,7 +3767,7 @@ static int tg3_chip_reset(struct tg3 *tp
if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
- int i;
+ unsigned int i;
u32 cfg_val;
/* Wait for link training to complete. */
@@ -3871,7 +3875,7 @@ static void tg3_stop_fw(struct tg3 *tp)
{
if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
u32 val;
- int i;
+ unsigned int i;
tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
val = tr32(GRC_RX_CPU_EVENT);
@@ -4040,7 +4044,7 @@ u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(
/* tp->lock is held. */
static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
{
- int i;
+ unsigned int i;
if (offset == TX_CPU_BASE &&
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
@@ -4152,7 +4156,8 @@ out:
static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
{
struct fw_info info;
- int err, i;
+ int err;
+ unsigned int i;
info.text_base = TG3_FW_TEXT_ADDR;
info.text_len = TG3_FW_TEXT_LEN;
@@ -4711,7 +4716,8 @@ static int tg3_load_tso_firmware(struct
{
struct fw_info info;
unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
- int err, i;
+ int err;
+ unsigned int i;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
return 0;
@@ -4784,7 +4790,7 @@ static int tg3_load_tso_firmware(struct
static void __tg3_set_mac_addr(struct tg3 *tp)
{
u32 addr_high, addr_low;
- int i;
+ unsigned int i;
addr_high = ((tp->dev->dev_addr[0] << 8) |
tp->dev->dev_addr[1]);
@@ -6136,7 +6142,8 @@ static inline u32 calc_crc(unsigned char
{
u32 reg;
u32 tmp;
- int j, k;
+ int j;
+ unsigned int k;
reg = 0xffffffff;
@@ -6802,7 +6809,7 @@ static struct ethtool_ops tg3_ethtool_op
/* Chips other than 5700/5701 use the NVRAM for fetching info. */
static void __devinit tg3_nvram_init(struct tg3 *tp)
{
- int j;
+ unsigned int j;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
return;
@@ -6856,7 +6863,7 @@ static int tg3_nvram_read_using_eeprom(s
u32 offset, u32 *val)
{
u32 tmp;
- int i;
+ unsigned int i;
if (offset > EEPROM_ADDR_ADDR_MASK ||
(offset % 4) != 0)
@@ -6889,7 +6896,7 @@ static int tg3_nvram_read_using_eeprom(s
static int __devinit tg3_nvram_read(struct tg3 *tp,
u32 offset, u32 *val)
{
- int i;
+ unsigned int i;
if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
@@ -8106,7 +8113,8 @@ static int __devinit tg3_init_one(struct
unsigned long tg3reg_base, tg3reg_len;
struct net_device *dev;
struct tg3 *tp;
- int i, err, pci_using_dac, pm_cap;
+ int err, pm_cap;
+ unsigned int i, pci_using_dac;
if (tg3_version_printed++ == 0)
printk(KERN_INFO "%s", version);
[-- Attachment #3: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (11 preceding siblings ...)
2004-11-12 15:13 ` Carlo Perassi
@ 2004-11-18 0:23 ` David S. Miller
2004-11-18 9:35 ` Carlo Perassi
13 siblings, 0 replies; 15+ messages in thread
From: David S. Miller @ 2004-11-18 0:23 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]
On Fri, 12 Nov 2004 16:13:45 +0100
Carlo Perassi <carlo@linux.it> wrote:
> I read the old patch: limit in tg3_bmcr_reset and tg3_wait_macro_done
> was not defined as unsigned.
> Anyway I compiled and tested this new patch.
I'm sorry for being such a pest, but this patch still
does add new bugs to the driver. Even the first hunk.
That first hunk changes "loops" to be unsigned in
tg3_readphy().
The loop and error control logic is:
loops = LOOPS_INIT;
while (loops-- > 0) {
..
}
..
if (loops > 0)
success path
With a signed value of loops, the success path check
will not pass when the loop exits due to the while()
check.
But with an unsigned value what happens is:
1) while (loops-- > 0) passes because loops starts
at '1', but this decrement brings it down to
zero, the loop executes
2) while (loops-- > 0) fails because loops starts
at '0', and this decrement changes loops to
a _VERY LARGE_ unsigned number.
3) if (loops > 0) passes erroneously.
We've been back and forth at least 3 times now on this
patch wrt. loop termination issues in error paths. I
really don't see any real value in dorking with the
signnedness of these integers especially since after 3
round-trips this "cleanup" still introduces new bugs.
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int
2004-11-02 10:18 [KJ] [PATCH] driver/net/tg3.c: some s/int/unsigned int Carlo Perassi
` (12 preceding siblings ...)
2004-11-18 0:23 ` David S. Miller
@ 2004-11-18 9:35 ` Carlo Perassi
13 siblings, 0 replies; 15+ messages in thread
From: Carlo Perassi @ 2004-11-18 9:35 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 209 bytes --]
> I'm sorry for being such a pest, but this patch still
Don't worry. Forget the first hunk or the whole patch as you want.
Thank you for your detailed answer.
--
Carlo Perassi - http://www.linux.it/~carlo/
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 15+ messages in thread