Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

via-velocity: Use more typical logging styles

Use netdev_<level> in place of VELOCITY_PRT.
Use pr_<level> in place of printk(KERN_<LEVEL>.

Miscellanea:

o Add pr_fmt to prefix pr_<level> output with "via-velocity: "
o Remove now unused functions and macros
o Realign some logging lines
o Remove devname where pr_<level> is also used

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Joe Perches and committed by
David S. Miller
93f4ddd6 a79da695

+82 -119
+82 -75
drivers/net/ethernet/via/via-velocity.c
··· 32 32 * MODULE_LICENSE("GPL"); 33 33 */ 34 34 35 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 36 + 35 37 #include <linux/module.h> 36 38 #include <linux/types.h> 37 39 #include <linux/bitops.h> ··· 82 80 }; 83 81 84 82 static int velocity_nics; 85 - static int msglevel = MSG_LEVEL_INFO; 86 83 87 84 static void velocity_set_power_state(struct velocity_info *vptr, char state) 88 85 { ··· 406 405 * @max: highest value allowed 407 406 * @def: default value 408 407 * @name: property name 409 - * @dev: device name 410 408 * 411 409 * Set an integer property in the module options. This function does 412 410 * all the verification and checking as well as reporting so that 413 411 * we don't duplicate code for each option. 414 412 */ 415 413 static void velocity_set_int_opt(int *opt, int val, int min, int max, int def, 416 - char *name, const char *devname) 414 + char *name) 417 415 { 418 416 if (val == -1) 419 417 *opt = def; 420 418 else if (val < min || val > max) { 421 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n", 422 - devname, name, min, max); 419 + pr_notice("the value of parameter %s is invalid, the valid range is (%d-%d)\n", 420 + name, min, max); 423 421 *opt = def; 424 422 } else { 425 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n", 426 - devname, name, val); 423 + pr_info("set value of parameter %s to %d\n", name, val); 427 424 *opt = val; 428 425 } 429 426 } ··· 433 434 * @def: default value (yes/no) 434 435 * @flag: numeric value to set for true. 435 436 * @name: property name 436 - * @dev: device name 437 437 * 438 438 * Set a boolean property in the module options. This function does 439 439 * all the verification and checking as well as reporting so that 440 440 * we don't duplicate code for each option. 441 441 */ 442 442 static void velocity_set_bool_opt(u32 *opt, int val, int def, u32 flag, 443 - char *name, const char *devname) 443 + char *name) 444 444 { 445 445 (*opt) &= (~flag); 446 446 if (val == -1) 447 447 *opt |= (def ? flag : 0); 448 448 else if (val < 0 || val > 1) { 449 - printk(KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1)\n", 450 - devname, name); 449 + pr_notice("the value of parameter %s is invalid, the valid range is (%d-%d)\n", 450 + name, 0, 1); 451 451 *opt |= (def ? flag : 0); 452 452 } else { 453 - printk(KERN_INFO "%s: set parameter %s to %s\n", 454 - devname, name, val ? "TRUE" : "FALSE"); 453 + pr_info("set parameter %s to %s\n", 454 + name, val ? "TRUE" : "FALSE"); 455 455 *opt |= (val ? flag : 0); 456 456 } 457 457 } ··· 459 461 * velocity_get_options - set options on device 460 462 * @opts: option structure for the device 461 463 * @index: index of option to use in module options array 462 - * @devname: device name 463 464 * 464 465 * Turn the module and command options into a single structure 465 466 * for the current device 466 467 */ 467 - static void velocity_get_options(struct velocity_opt *opts, int index, 468 - const char *devname) 468 + static void velocity_get_options(struct velocity_opt *opts, int index) 469 469 { 470 470 471 - velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, "rx_thresh", devname); 472 - velocity_set_int_opt(&opts->DMA_length, DMA_length[index], DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, "DMA_length", devname); 473 - velocity_set_int_opt(&opts->numrx, RxDescriptors[index], RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, "RxDescriptors", devname); 474 - velocity_set_int_opt(&opts->numtx, TxDescriptors[index], TX_DESC_MIN, TX_DESC_MAX, TX_DESC_DEF, "TxDescriptors", devname); 471 + velocity_set_int_opt(&opts->rx_thresh, rx_thresh[index], 472 + RX_THRESH_MIN, RX_THRESH_MAX, RX_THRESH_DEF, 473 + "rx_thresh"); 474 + velocity_set_int_opt(&opts->DMA_length, DMA_length[index], 475 + DMA_LENGTH_MIN, DMA_LENGTH_MAX, DMA_LENGTH_DEF, 476 + "DMA_length"); 477 + velocity_set_int_opt(&opts->numrx, RxDescriptors[index], 478 + RX_DESC_MIN, RX_DESC_MAX, RX_DESC_DEF, 479 + "RxDescriptors"); 480 + velocity_set_int_opt(&opts->numtx, TxDescriptors[index], 481 + TX_DESC_MIN, TX_DESC_MAX, TX_DESC_DEF, 482 + "TxDescriptors"); 475 483 476 - velocity_set_int_opt(&opts->flow_cntl, flow_control[index], FLOW_CNTL_MIN, FLOW_CNTL_MAX, FLOW_CNTL_DEF, "flow_control", devname); 477 - velocity_set_bool_opt(&opts->flags, IP_byte_align[index], IP_ALIG_DEF, VELOCITY_FLAGS_IP_ALIGN, "IP_byte_align", devname); 478 - velocity_set_int_opt((int *) &opts->spd_dpx, speed_duplex[index], MED_LNK_MIN, MED_LNK_MAX, MED_LNK_DEF, "Media link mode", devname); 479 - velocity_set_int_opt(&opts->wol_opts, wol_opts[index], WOL_OPT_MIN, WOL_OPT_MAX, WOL_OPT_DEF, "Wake On Lan options", devname); 484 + velocity_set_int_opt(&opts->flow_cntl, flow_control[index], 485 + FLOW_CNTL_MIN, FLOW_CNTL_MAX, FLOW_CNTL_DEF, 486 + "flow_control"); 487 + velocity_set_bool_opt(&opts->flags, IP_byte_align[index], 488 + IP_ALIG_DEF, VELOCITY_FLAGS_IP_ALIGN, 489 + "IP_byte_align"); 490 + velocity_set_int_opt((int *) &opts->spd_dpx, speed_duplex[index], 491 + MED_LNK_MIN, MED_LNK_MAX, MED_LNK_DEF, 492 + "Media link mode"); 493 + velocity_set_int_opt(&opts->wol_opts, wol_opts[index], 494 + WOL_OPT_MIN, WOL_OPT_MAX, WOL_OPT_DEF, 495 + "Wake On Lan options"); 480 496 opts->numrx = (opts->numrx & ~3); 481 497 } 482 498 ··· 892 880 (mii_status==curr_status)) { 893 881 vptr->mii_status=mii_check_media_mode(vptr->mac_regs); 894 882 vptr->mii_status=check_connection_type(vptr->mac_regs); 895 - VELOCITY_PRT(MSG_LEVEL_INFO, "Velocity link no change\n"); 883 + netdev_info(vptr->netdev, "Velocity link no change\n"); 896 884 return 0; 897 885 } 898 886 */ ··· 904 892 * If connection type is AUTO 905 893 */ 906 894 if (mii_status & VELOCITY_AUTONEG_ENABLE) { 907 - VELOCITY_PRT(MSG_LEVEL_INFO, "Velocity is AUTO mode\n"); 895 + netdev_info(vptr->netdev, "Velocity is in AUTO mode\n"); 908 896 /* clear force MAC mode bit */ 909 897 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR); 910 898 /* set duplex mode of MAC according to duplex mode of MII */ ··· 939 927 if (mii_status & VELOCITY_DUPLEX_FULL) { 940 928 CHIPGCR |= CHIPGCR_FCFDX; 941 929 writeb(CHIPGCR, &regs->CHIPGCR); 942 - VELOCITY_PRT(MSG_LEVEL_INFO, "set Velocity to forced full mode\n"); 930 + netdev_info(vptr->netdev, 931 + "set Velocity to forced full mode\n"); 943 932 if (vptr->rev_id < REV_ID_VT3216_A0) 944 933 BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR); 945 934 } else { 946 935 CHIPGCR &= ~CHIPGCR_FCFDX; 947 - VELOCITY_PRT(MSG_LEVEL_INFO, "set Velocity to forced half mode\n"); 936 + netdev_info(vptr->netdev, 937 + "set Velocity to forced half mode\n"); 948 938 writeb(CHIPGCR, &regs->CHIPGCR); 949 939 if (vptr->rev_id < REV_ID_VT3216_A0) 950 940 BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR); ··· 999 985 */ 1000 986 static void velocity_print_link_status(struct velocity_info *vptr) 1001 987 { 988 + const char *link; 989 + const char *speed; 990 + const char *duplex; 1002 991 1003 992 if (vptr->mii_status & VELOCITY_LINK_FAIL) { 1004 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect cable link\n", vptr->netdev->name); 1005 - } else if (vptr->options.spd_dpx == SPD_DPX_AUTO) { 1006 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link auto-negotiation", vptr->netdev->name); 993 + netdev_notice(vptr->netdev, "failed to detect cable link\n"); 994 + return; 995 + } 996 + 997 + if (vptr->options.spd_dpx == SPD_DPX_AUTO) { 998 + link = "auto-negotiation"; 1007 999 1008 1000 if (vptr->mii_status & VELOCITY_SPEED_1000) 1009 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps"); 1001 + speed = "1000"; 1010 1002 else if (vptr->mii_status & VELOCITY_SPEED_100) 1011 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps"); 1003 + speed = "100"; 1012 1004 else 1013 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps"); 1005 + speed = "10"; 1014 1006 1015 1007 if (vptr->mii_status & VELOCITY_DUPLEX_FULL) 1016 - VELOCITY_PRT(MSG_LEVEL_INFO, " full duplex\n"); 1008 + duplex = "full"; 1017 1009 else 1018 - VELOCITY_PRT(MSG_LEVEL_INFO, " half duplex\n"); 1010 + duplex = "half"; 1019 1011 } else { 1020 - VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", vptr->netdev->name); 1012 + link = "forced"; 1013 + 1021 1014 switch (vptr->options.spd_dpx) { 1022 1015 case SPD_DPX_1000_FULL: 1023 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps full duplex\n"); 1016 + speed = "1000"; 1017 + duplex = "full"; 1024 1018 break; 1025 1019 case SPD_DPX_100_HALF: 1026 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps half duplex\n"); 1020 + speed = "100"; 1021 + duplex = "half"; 1027 1022 break; 1028 1023 case SPD_DPX_100_FULL: 1029 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps full duplex\n"); 1024 + speed = "100"; 1025 + duplex = "full"; 1030 1026 break; 1031 1027 case SPD_DPX_10_HALF: 1032 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps half duplex\n"); 1028 + speed = "10"; 1029 + duplex = "half"; 1033 1030 break; 1034 1031 case SPD_DPX_10_FULL: 1035 - VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps full duplex\n"); 1032 + speed = "10"; 1033 + duplex = "full"; 1036 1034 break; 1037 1035 default: 1036 + speed = "unknown"; 1037 + duplex = "unknown"; 1038 1038 break; 1039 1039 } 1040 1040 } 1041 + netdev_notice(vptr->netdev, "Link %s speed %sM bps %s duplex\n", 1042 + link, speed, duplex); 1041 1043 } 1042 1044 1043 1045 /** ··· 1651 1621 velocity_init_rx_ring_indexes(vptr); 1652 1622 1653 1623 if (velocity_rx_refill(vptr) != vptr->options.numrx) { 1654 - VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR 1655 - "%s: failed to allocate RX buffer.\n", vptr->netdev->name); 1624 + netdev_err(vptr->netdev, "failed to allocate RX buffer\n"); 1656 1625 velocity_free_rd_ring(vptr); 1657 1626 goto out; 1658 1627 } ··· 1834 1805 if (status & ISR_TXSTLI) { 1835 1806 struct mac_regs __iomem *regs = vptr->mac_regs; 1836 1807 1837 - printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(&regs->TDIdx[0])); 1808 + netdev_err(vptr->netdev, "TD structure error TDindex=%hx\n", 1809 + readw(&regs->TDIdx[0])); 1838 1810 BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR); 1839 1811 writew(TRDCSR_RUN, &regs->TDCSRClr); 1840 1812 netif_stop_queue(vptr->netdev); ··· 2066 2036 2067 2037 if (unlikely(rd->rdesc0.RSR & (RSR_STP | RSR_EDP | RSR_RL))) { 2068 2038 if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) 2069 - VELOCITY_PRT(MSG_LEVEL_VERBOSE, KERN_ERR " %s : the received frame spans multiple RDs.\n", vptr->netdev->name); 2039 + netdev_err(vptr->netdev, "received frame spans multiple RDs\n"); 2070 2040 stats->rx_length_errors++; 2071 2041 return -EINVAL; 2072 2042 } ··· 2751 2721 */ 2752 2722 static void velocity_print_info(struct velocity_info *vptr) 2753 2723 { 2754 - struct net_device *dev = vptr->netdev; 2755 - 2756 - printk(KERN_INFO "%s: %s\n", dev->name, get_chip_name(vptr->chip_id)); 2757 - printk(KERN_INFO "%s: Ethernet Address: %pM\n", 2758 - dev->name, dev->dev_addr); 2724 + netdev_info(vptr->netdev, "%s - Ethernet Address: %pM\n", 2725 + get_chip_name(vptr->chip_id), vptr->netdev->dev_addr); 2759 2726 } 2760 2727 2761 2728 static u32 velocity_get_link(struct net_device *dev) ··· 2775 2748 const struct velocity_info_tbl *info, 2776 2749 enum velocity_bus_type bustype) 2777 2750 { 2778 - static int first = 1; 2779 2751 struct net_device *netdev; 2780 2752 int i; 2781 - const char *drv_string; 2782 2753 struct velocity_info *vptr; 2783 2754 struct mac_regs __iomem *regs; 2784 2755 int ret = -ENOMEM; ··· 2798 2773 SET_NETDEV_DEV(netdev, dev); 2799 2774 vptr = netdev_priv(netdev); 2800 2775 2801 - if (first) { 2802 - printk(KERN_INFO "%s Ver. %s\n", 2803 - VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION); 2804 - printk(KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n"); 2805 - printk(KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n"); 2806 - first = 0; 2807 - } 2776 + pr_info_once("%s Ver. %s\n", VELOCITY_FULL_DRV_NAM, VELOCITY_VERSION); 2777 + pr_info_once("Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n"); 2778 + pr_info_once("Copyright (c) 2004 Red Hat Inc.\n"); 2808 2779 2809 2780 netdev->irq = irq; 2810 2781 vptr->netdev = netdev; ··· 2836 2815 netdev->dev_addr[i] = readb(&regs->PAR[i]); 2837 2816 2838 2817 2839 - drv_string = dev_driver_string(dev); 2840 - 2841 - velocity_get_options(&vptr->options, velocity_nics, drv_string); 2818 + velocity_get_options(&vptr->options, velocity_nics); 2842 2819 2843 2820 /* 2844 2821 * Mask out the options cannot be set to the chip ··· 3488 3469 return 0; 3489 3470 } 3490 3471 3491 - static u32 velocity_get_msglevel(struct net_device *dev) 3492 - { 3493 - return msglevel; 3494 - } 3495 - 3496 - static void velocity_set_msglevel(struct net_device *dev, u32 value) 3497 - { 3498 - msglevel = value; 3499 - } 3500 - 3501 3472 static int get_pending_timer_val(int val) 3502 3473 { 3503 3474 int mult_bits = val >> 6; ··· 3662 3653 .get_drvinfo = velocity_get_drvinfo, 3663 3654 .get_wol = velocity_ethtool_get_wol, 3664 3655 .set_wol = velocity_ethtool_set_wol, 3665 - .get_msglevel = velocity_get_msglevel, 3666 - .set_msglevel = velocity_set_msglevel, 3667 3656 .get_link = velocity_get_link, 3668 3657 .get_strings = velocity_get_strings, 3669 3658 .get_sset_count = velocity_get_sset_count,
-44
drivers/net/ethernet/via/via-velocity.h
··· 1286 1286 velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\ 1287 1287 (id);}) 1288 1288 1289 - /* 1290 - * Inline debug routine 1291 - */ 1292 - 1293 - 1294 - enum velocity_msg_level { 1295 - MSG_LEVEL_ERR = 0, //Errors that will cause abnormal operation. 1296 - MSG_LEVEL_NOTICE = 1, //Some errors need users to be notified. 1297 - MSG_LEVEL_INFO = 2, //Normal message. 1298 - MSG_LEVEL_VERBOSE = 3, //Will report all trival errors. 1299 - MSG_LEVEL_DEBUG = 4 //Only for debug purpose. 1300 - }; 1301 - 1302 - #ifdef VELOCITY_DEBUG 1303 - #define ASSERT(x) { \ 1304 - if (!(x)) { \ 1305 - printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\ 1306 - __func__, __LINE__);\ 1307 - BUG(); \ 1308 - }\ 1309 - } 1310 - #define VELOCITY_DBG(p,args...) printk(p, ##args) 1311 - #else 1312 - #define ASSERT(x) 1313 - #define VELOCITY_DBG(x) 1314 - #endif 1315 - 1316 - #define VELOCITY_PRT(l, p, args...) do {if (l<=msglevel) printk( p ,##args);} while (0) 1317 - 1318 - #define VELOCITY_PRT_CAMMASK(p,t) {\ 1319 - int i;\ 1320 - if ((t)==VELOCITY_MULTICAST_CAM) {\ 1321 - for (i=0;i<(MCAM_SIZE/8);i++)\ 1322 - printk("%02X",(p)->mCAMmask[i]);\ 1323 - }\ 1324 - else {\ 1325 - for (i=0;i<(VCAM_SIZE/8);i++)\ 1326 - printk("%02X",(p)->vCAMmask[i]);\ 1327 - }\ 1328 - printk("\n");\ 1329 - } 1330 - 1331 - 1332 - 1333 1289 #define VELOCITY_WOL_MAGIC 0x00000000UL 1334 1290 #define VELOCITY_WOL_PHY 0x00000001UL 1335 1291 #define VELOCITY_WOL_ARP 0x00000002UL