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>
@@ -80,7 +82,6 @@ enum velocity_bus_type {
80
82
};
81
83
82
84
static int velocity_nics ;
83
- static int msglevel = MSG_LEVEL_INFO ;
84
85
85
86
static void velocity_set_power_state (struct velocity_info * vptr , char state )
86
87
{
@@ -405,24 +406,22 @@ static const char *get_chip_name(enum chip_type chip_id)
405
406
* @max: highest value allowed
406
407
* @def: default value
407
408
* @name: property name
408
- * @dev: device name
409
409
*
410
410
* Set an integer property in the module options. This function does
411
411
* all the verification and checking as well as reporting so that
412
412
* we don't duplicate code for each option.
413
413
*/
414
414
static void velocity_set_int_opt (int * opt , int val , int min , int max , int def ,
415
- char * name , const char * devname )
415
+ char * name )
416
416
{
417
417
if (val == -1 )
418
418
* opt = def ;
419
419
else if (val < min || val > max ) {
420
- VELOCITY_PRT ( MSG_LEVEL_INFO , KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n" ,
421
- devname , name , min , max );
420
+ pr_notice ( " the value of parameter %s is invalid, the valid range is (%d-%d)\n" ,
421
+ name , min , max );
422
422
* opt = def ;
423
423
} else {
424
- VELOCITY_PRT (MSG_LEVEL_INFO , KERN_INFO "%s: set value of parameter %s to %d\n" ,
425
- devname , name , val );
424
+ pr_info ("set value of parameter %s to %d\n" , name , val );
426
425
* opt = val ;
427
426
}
428
427
}
@@ -434,25 +433,24 @@ static void velocity_set_int_opt(int *opt, int val, int min, int max, int def,
434
433
* @def: default value (yes/no)
435
434
* @flag: numeric value to set for true.
436
435
* @name: property name
437
- * @dev: device name
438
436
*
439
437
* Set a boolean property in the module options. This function does
440
438
* all the verification and checking as well as reporting so that
441
439
* we don't duplicate code for each option.
442
440
*/
443
441
static void velocity_set_bool_opt (u32 * opt , int val , int def , u32 flag ,
444
- char * name , const char * devname )
442
+ char * name )
445
443
{
446
444
(* opt ) &= (~flag );
447
445
if (val == -1 )
448
446
* opt |= (def ? flag : 0 );
449
447
else if (val < 0 || val > 1 ) {
450
- printk ( KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (0-1 )\n" ,
451
- devname , name );
448
+ pr_notice ( " the value of parameter %s is invalid, the valid range is (%d-%d )\n" ,
449
+ name , 0 , 1 );
452
450
* opt |= (def ? flag : 0 );
453
451
} else {
454
- printk ( KERN_INFO "%s: set parameter %s to %s\n" ,
455
- devname , name , val ? "TRUE" : "FALSE" );
452
+ pr_info ( " set parameter %s to %s\n" ,
453
+ name , val ? "TRUE" : "FALSE" );
456
454
* opt |= (val ? flag : 0 );
457
455
}
458
456
}
@@ -461,24 +459,38 @@ static void velocity_set_bool_opt(u32 *opt, int val, int def, u32 flag,
461
459
* velocity_get_options - set options on device
462
460
* @opts: option structure for the device
463
461
* @index: index of option to use in module options array
464
- * @devname: device name
465
462
*
466
463
* Turn the module and command options into a single structure
467
464
* for the current device
468
465
*/
469
- static void velocity_get_options (struct velocity_opt * opts , int index ,
470
- const char * devname )
471
- {
472
-
473
- velocity_set_int_opt (& opts -> rx_thresh , rx_thresh [index ], RX_THRESH_MIN , RX_THRESH_MAX , RX_THRESH_DEF , "rx_thresh" , devname );
474
- velocity_set_int_opt (& opts -> DMA_length , DMA_length [index ], DMA_LENGTH_MIN , DMA_LENGTH_MAX , DMA_LENGTH_DEF , "DMA_length" , devname );
475
- velocity_set_int_opt (& opts -> numrx , RxDescriptors [index ], RX_DESC_MIN , RX_DESC_MAX , RX_DESC_DEF , "RxDescriptors" , devname );
476
- velocity_set_int_opt (& opts -> numtx , TxDescriptors [index ], TX_DESC_MIN , TX_DESC_MAX , TX_DESC_DEF , "TxDescriptors" , devname );
477
-
478
- velocity_set_int_opt (& opts -> flow_cntl , flow_control [index ], FLOW_CNTL_MIN , FLOW_CNTL_MAX , FLOW_CNTL_DEF , "flow_control" , devname );
479
- velocity_set_bool_opt (& opts -> flags , IP_byte_align [index ], IP_ALIG_DEF , VELOCITY_FLAGS_IP_ALIGN , "IP_byte_align" , devname );
480
- velocity_set_int_opt ((int * ) & opts -> spd_dpx , speed_duplex [index ], MED_LNK_MIN , MED_LNK_MAX , MED_LNK_DEF , "Media link mode" , devname );
481
- velocity_set_int_opt (& opts -> wol_opts , wol_opts [index ], WOL_OPT_MIN , WOL_OPT_MAX , WOL_OPT_DEF , "Wake On Lan options" , devname );
466
+ static void velocity_get_options (struct velocity_opt * opts , int index )
467
+ {
468
+
469
+ velocity_set_int_opt (& opts -> rx_thresh , rx_thresh [index ],
470
+ RX_THRESH_MIN , RX_THRESH_MAX , RX_THRESH_DEF ,
471
+ "rx_thresh" );
472
+ velocity_set_int_opt (& opts -> DMA_length , DMA_length [index ],
473
+ DMA_LENGTH_MIN , DMA_LENGTH_MAX , DMA_LENGTH_DEF ,
474
+ "DMA_length" );
475
+ velocity_set_int_opt (& opts -> numrx , RxDescriptors [index ],
476
+ RX_DESC_MIN , RX_DESC_MAX , RX_DESC_DEF ,
477
+ "RxDescriptors" );
478
+ velocity_set_int_opt (& opts -> numtx , TxDescriptors [index ],
479
+ TX_DESC_MIN , TX_DESC_MAX , TX_DESC_DEF ,
480
+ "TxDescriptors" );
481
+
482
+ velocity_set_int_opt (& opts -> flow_cntl , flow_control [index ],
483
+ FLOW_CNTL_MIN , FLOW_CNTL_MAX , FLOW_CNTL_DEF ,
484
+ "flow_control" );
485
+ velocity_set_bool_opt (& opts -> flags , IP_byte_align [index ],
486
+ IP_ALIG_DEF , VELOCITY_FLAGS_IP_ALIGN ,
487
+ "IP_byte_align" );
488
+ velocity_set_int_opt ((int * ) & opts -> spd_dpx , speed_duplex [index ],
489
+ MED_LNK_MIN , MED_LNK_MAX , MED_LNK_DEF ,
490
+ "Media link mode" );
491
+ velocity_set_int_opt (& opts -> wol_opts , wol_opts [index ],
492
+ WOL_OPT_MIN , WOL_OPT_MAX , WOL_OPT_DEF ,
493
+ "Wake On Lan options" );
482
494
opts -> numrx = (opts -> numrx & ~3 );
483
495
}
484
496
@@ -880,7 +892,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
880
892
(mii_status==curr_status)) {
881
893
vptr->mii_status=mii_check_media_mode(vptr->mac_regs);
882
894
vptr->mii_status=check_connection_type(vptr->mac_regs);
883
- VELOCITY_PRT(MSG_LEVEL_INFO , "Velocity link no change\n");
895
+ netdev_info(vptr->netdev , "Velocity link no change\n");
884
896
return 0;
885
897
}
886
898
*/
@@ -892,7 +904,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
892
904
* If connection type is AUTO
893
905
*/
894
906
if (mii_status & VELOCITY_AUTONEG_ENABLE ) {
895
- VELOCITY_PRT ( MSG_LEVEL_INFO , "Velocity is AUTO mode\n" );
907
+ netdev_info ( vptr -> netdev , "Velocity is in AUTO mode\n" );
896
908
/* clear force MAC mode bit */
897
909
BYTE_REG_BITS_OFF (CHIPGCR_FCMODE , & regs -> CHIPGCR );
898
910
/* set duplex mode of MAC according to duplex mode of MII */
@@ -927,12 +939,14 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
927
939
if (mii_status & VELOCITY_DUPLEX_FULL ) {
928
940
CHIPGCR |= CHIPGCR_FCFDX ;
929
941
writeb (CHIPGCR , & regs -> CHIPGCR );
930
- VELOCITY_PRT (MSG_LEVEL_INFO , "set Velocity to forced full mode\n" );
942
+ netdev_info (vptr -> netdev ,
943
+ "set Velocity to forced full mode\n" );
931
944
if (vptr -> rev_id < REV_ID_VT3216_A0 )
932
945
BYTE_REG_BITS_OFF (TCR_TB2BDIS , & regs -> TCR );
933
946
} else {
934
947
CHIPGCR &= ~CHIPGCR_FCFDX ;
935
- VELOCITY_PRT (MSG_LEVEL_INFO , "set Velocity to forced half mode\n" );
948
+ netdev_info (vptr -> netdev ,
949
+ "set Velocity to forced half mode\n" );
936
950
writeb (CHIPGCR , & regs -> CHIPGCR );
937
951
if (vptr -> rev_id < REV_ID_VT3216_A0 )
938
952
BYTE_REG_BITS_ON (TCR_TB2BDIS , & regs -> TCR );
@@ -985,45 +999,61 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
985
999
*/
986
1000
static void velocity_print_link_status (struct velocity_info * vptr )
987
1001
{
1002
+ const char * link ;
1003
+ const char * speed ;
1004
+ const char * duplex ;
988
1005
989
1006
if (vptr -> mii_status & VELOCITY_LINK_FAIL ) {
990
- VELOCITY_PRT (MSG_LEVEL_INFO , KERN_NOTICE "%s: failed to detect cable link\n" , vptr -> netdev -> name );
991
- } else if (vptr -> options .spd_dpx == SPD_DPX_AUTO ) {
992
- VELOCITY_PRT (MSG_LEVEL_INFO , KERN_NOTICE "%s: Link auto-negotiation" , vptr -> netdev -> name );
1007
+ netdev_notice (vptr -> netdev , "failed to detect cable link\n" );
1008
+ return ;
1009
+ }
1010
+
1011
+ if (vptr -> options .spd_dpx == SPD_DPX_AUTO ) {
1012
+ link = "auto-negotiation" ;
993
1013
994
1014
if (vptr -> mii_status & VELOCITY_SPEED_1000 )
995
- VELOCITY_PRT ( MSG_LEVEL_INFO , " speed 1000M bps" ) ;
1015
+ speed = "1000" ;
996
1016
else if (vptr -> mii_status & VELOCITY_SPEED_100 )
997
- VELOCITY_PRT ( MSG_LEVEL_INFO , " speed 100M bps" ) ;
1017
+ speed = "100" ;
998
1018
else
999
- VELOCITY_PRT ( MSG_LEVEL_INFO , " speed 10M bps" ) ;
1019
+ speed = "10" ;
1000
1020
1001
1021
if (vptr -> mii_status & VELOCITY_DUPLEX_FULL )
1002
- VELOCITY_PRT ( MSG_LEVEL_INFO , " full duplex\n" ) ;
1022
+ duplex = " full" ;
1003
1023
else
1004
- VELOCITY_PRT ( MSG_LEVEL_INFO , " half duplex\n" ) ;
1024
+ duplex = " half" ;
1005
1025
} else {
1006
- VELOCITY_PRT (MSG_LEVEL_INFO , KERN_NOTICE "%s: Link forced" , vptr -> netdev -> name );
1026
+ link = "forced" ;
1027
+
1007
1028
switch (vptr -> options .spd_dpx ) {
1008
1029
case SPD_DPX_1000_FULL :
1009
- VELOCITY_PRT (MSG_LEVEL_INFO , " speed 1000M bps full duplex\n" );
1030
+ speed = "1000" ;
1031
+ duplex = "full" ;
1010
1032
break ;
1011
1033
case SPD_DPX_100_HALF :
1012
- VELOCITY_PRT (MSG_LEVEL_INFO , " speed 100M bps half duplex\n" );
1034
+ speed = "100" ;
1035
+ duplex = "half" ;
1013
1036
break ;
1014
1037
case SPD_DPX_100_FULL :
1015
- VELOCITY_PRT (MSG_LEVEL_INFO , " speed 100M bps full duplex\n" );
1038
+ speed = "100" ;
1039
+ duplex = "full" ;
1016
1040
break ;
1017
1041
case SPD_DPX_10_HALF :
1018
- VELOCITY_PRT (MSG_LEVEL_INFO , " speed 10M bps half duplex\n" );
1042
+ speed = "10" ;
1043
+ duplex = "half" ;
1019
1044
break ;
1020
1045
case SPD_DPX_10_FULL :
1021
- VELOCITY_PRT (MSG_LEVEL_INFO , " speed 10M bps full duplex\n" );
1046
+ speed = "10" ;
1047
+ duplex = "full" ;
1022
1048
break ;
1023
1049
default :
1050
+ speed = "unknown" ;
1051
+ duplex = "unknown" ;
1024
1052
break ;
1025
1053
}
1026
1054
}
1055
+ netdev_notice (vptr -> netdev , "Link %s speed %sM bps %s duplex\n" ,
1056
+ link , speed , duplex );
1027
1057
}
1028
1058
1029
1059
/**
@@ -1621,8 +1651,7 @@ static int velocity_init_rd_ring(struct velocity_info *vptr)
1621
1651
velocity_init_rx_ring_indexes (vptr );
1622
1652
1623
1653
if (velocity_rx_refill (vptr ) != vptr -> options .numrx ) {
1624
- VELOCITY_PRT (MSG_LEVEL_ERR , KERN_ERR
1625
- "%s: failed to allocate RX buffer.\n" , vptr -> netdev -> name );
1654
+ netdev_err (vptr -> netdev , "failed to allocate RX buffer\n" );
1626
1655
velocity_free_rd_ring (vptr );
1627
1656
goto out ;
1628
1657
}
@@ -1805,7 +1834,8 @@ static void velocity_error(struct velocity_info *vptr, int status)
1805
1834
if (status & ISR_TXSTLI ) {
1806
1835
struct mac_regs __iomem * regs = vptr -> mac_regs ;
1807
1836
1808
- printk (KERN_ERR "TD structure error TDindex=%hx\n" , readw (& regs -> TDIdx [0 ]));
1837
+ netdev_err (vptr -> netdev , "TD structure error TDindex=%hx\n" ,
1838
+ readw (& regs -> TDIdx [0 ]));
1809
1839
BYTE_REG_BITS_ON (TXESR_TDSTR , & regs -> TXESR );
1810
1840
writew (TRDCSR_RUN , & regs -> TDCSRClr );
1811
1841
netif_stop_queue (vptr -> netdev );
@@ -2036,7 +2066,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
2036
2066
2037
2067
if (unlikely (rd -> rdesc0 .RSR & (RSR_STP | RSR_EDP | RSR_RL ))) {
2038
2068
if (rd -> rdesc0 .RSR & (RSR_STP | RSR_EDP ))
2039
- VELOCITY_PRT ( MSG_LEVEL_VERBOSE , KERN_ERR " %s : the received frame spans multiple RDs. \n", vptr -> netdev -> name );
2069
+ netdev_err ( vptr -> netdev , " received frame spans multiple RDs\n" );
2040
2070
stats -> rx_length_errors ++ ;
2041
2071
return - EINVAL ;
2042
2072
}
@@ -2721,11 +2751,8 @@ static int velocity_get_platform_info(struct velocity_info *vptr)
2721
2751
*/
2722
2752
static void velocity_print_info (struct velocity_info * vptr )
2723
2753
{
2724
- struct net_device * dev = vptr -> netdev ;
2725
-
2726
- printk (KERN_INFO "%s: %s\n" , dev -> name , get_chip_name (vptr -> chip_id ));
2727
- printk (KERN_INFO "%s: Ethernet Address: %pM\n" ,
2728
- dev -> name , dev -> dev_addr );
2754
+ netdev_info (vptr -> netdev , "%s - Ethernet Address: %pM\n" ,
2755
+ get_chip_name (vptr -> chip_id ), vptr -> netdev -> dev_addr );
2729
2756
}
2730
2757
2731
2758
static u32 velocity_get_link (struct net_device * dev )
@@ -2748,10 +2775,8 @@ static int velocity_probe(struct device *dev, int irq,
2748
2775
const struct velocity_info_tbl * info ,
2749
2776
enum velocity_bus_type bustype )
2750
2777
{
2751
- static int first = 1 ;
2752
2778
struct net_device * netdev ;
2753
2779
int i ;
2754
- const char * drv_string ;
2755
2780
struct velocity_info * vptr ;
2756
2781
struct mac_regs __iomem * regs ;
2757
2782
int ret = - ENOMEM ;
@@ -2773,13 +2798,9 @@ static int velocity_probe(struct device *dev, int irq,
2773
2798
SET_NETDEV_DEV (netdev , dev );
2774
2799
vptr = netdev_priv (netdev );
2775
2800
2776
- if (first ) {
2777
- printk (KERN_INFO "%s Ver. %s\n" ,
2778
- VELOCITY_FULL_DRV_NAM , VELOCITY_VERSION );
2779
- printk (KERN_INFO "Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n" );
2780
- printk (KERN_INFO "Copyright (c) 2004 Red Hat Inc.\n" );
2781
- first = 0 ;
2782
- }
2801
+ pr_info_once ("%s Ver. %s\n" , VELOCITY_FULL_DRV_NAM , VELOCITY_VERSION );
2802
+ pr_info_once ("Copyright (c) 2002, 2003 VIA Networking Technologies, Inc.\n" );
2803
+ pr_info_once ("Copyright (c) 2004 Red Hat Inc.\n" );
2783
2804
2784
2805
netdev -> irq = irq ;
2785
2806
vptr -> netdev = netdev ;
@@ -2815,9 +2836,7 @@ static int velocity_probe(struct device *dev, int irq,
2815
2836
netdev -> dev_addr [i ] = readb (& regs -> PAR [i ]);
2816
2837
2817
2838
2818
- drv_string = dev_driver_string (dev );
2819
-
2820
- velocity_get_options (& vptr -> options , velocity_nics , drv_string );
2839
+ velocity_get_options (& vptr -> options , velocity_nics );
2821
2840
2822
2841
/*
2823
2842
* Mask out the options cannot be set to the chip
@@ -3469,16 +3488,6 @@ static int velocity_ethtool_set_wol(struct net_device *dev, struct ethtool_wolin
3469
3488
return 0 ;
3470
3489
}
3471
3490
3472
- static u32 velocity_get_msglevel (struct net_device * dev )
3473
- {
3474
- return msglevel ;
3475
- }
3476
-
3477
- static void velocity_set_msglevel (struct net_device * dev , u32 value )
3478
- {
3479
- msglevel = value ;
3480
- }
3481
-
3482
3491
static int get_pending_timer_val (int val )
3483
3492
{
3484
3493
int mult_bits = val >> 6 ;
@@ -3653,8 +3662,6 @@ static const struct ethtool_ops velocity_ethtool_ops = {
3653
3662
.get_drvinfo = velocity_get_drvinfo ,
3654
3663
.get_wol = velocity_ethtool_get_wol ,
3655
3664
.set_wol = velocity_ethtool_set_wol ,
3656
- .get_msglevel = velocity_get_msglevel ,
3657
- .set_msglevel = velocity_set_msglevel ,
3658
3665
.get_link = velocity_get_link ,
3659
3666
.get_strings = velocity_get_strings ,
3660
3667
.get_sset_count = velocity_get_sset_count ,
0 commit comments