Skip to content

Commit 93f4ddd

Browse files
JoePerchesdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a79da69 commit 93f4ddd

File tree

2 files changed

+85
-122
lines changed

2 files changed

+85
-122
lines changed

drivers/net/ethernet/via/via-velocity.c

Lines changed: 85 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* MODULE_LICENSE("GPL");
3333
*/
3434

35+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
36+
3537
#include <linux/module.h>
3638
#include <linux/types.h>
3739
#include <linux/bitops.h>
@@ -80,7 +82,6 @@ enum velocity_bus_type {
8082
};
8183

8284
static int velocity_nics;
83-
static int msglevel = MSG_LEVEL_INFO;
8485

8586
static void velocity_set_power_state(struct velocity_info *vptr, char state)
8687
{
@@ -405,24 +406,22 @@ static const char *get_chip_name(enum chip_type chip_id)
405406
* @max: highest value allowed
406407
* @def: default value
407408
* @name: property name
408-
* @dev: device name
409409
*
410410
* Set an integer property in the module options. This function does
411411
* all the verification and checking as well as reporting so that
412412
* we don't duplicate code for each option.
413413
*/
414414
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)
416416
{
417417
if (val == -1)
418418
*opt = def;
419419
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);
422422
*opt = def;
423423
} 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);
426425
*opt = val;
427426
}
428427
}
@@ -434,25 +433,24 @@ static void velocity_set_int_opt(int *opt, int val, int min, int max, int def,
434433
* @def: default value (yes/no)
435434
* @flag: numeric value to set for true.
436435
* @name: property name
437-
* @dev: device name
438436
*
439437
* Set a boolean property in the module options. This function does
440438
* all the verification and checking as well as reporting so that
441439
* we don't duplicate code for each option.
442440
*/
443441
static void velocity_set_bool_opt(u32 *opt, int val, int def, u32 flag,
444-
char *name, const char *devname)
442+
char *name)
445443
{
446444
(*opt) &= (~flag);
447445
if (val == -1)
448446
*opt |= (def ? flag : 0);
449447
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);
452450
*opt |= (def ? flag : 0);
453451
} 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");
456454
*opt |= (val ? flag : 0);
457455
}
458456
}
@@ -461,24 +459,38 @@ static void velocity_set_bool_opt(u32 *opt, int val, int def, u32 flag,
461459
* velocity_get_options - set options on device
462460
* @opts: option structure for the device
463461
* @index: index of option to use in module options array
464-
* @devname: device name
465462
*
466463
* Turn the module and command options into a single structure
467464
* for the current device
468465
*/
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");
482494
opts->numrx = (opts->numrx & ~3);
483495
}
484496

@@ -880,7 +892,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
880892
(mii_status==curr_status)) {
881893
vptr->mii_status=mii_check_media_mode(vptr->mac_regs);
882894
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");
884896
return 0;
885897
}
886898
*/
@@ -892,7 +904,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
892904
* If connection type is AUTO
893905
*/
894906
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");
896908
/* clear force MAC mode bit */
897909
BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR);
898910
/* 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)
927939
if (mii_status & VELOCITY_DUPLEX_FULL) {
928940
CHIPGCR |= CHIPGCR_FCFDX;
929941
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");
931944
if (vptr->rev_id < REV_ID_VT3216_A0)
932945
BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR);
933946
} else {
934947
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");
936950
writeb(CHIPGCR, &regs->CHIPGCR);
937951
if (vptr->rev_id < REV_ID_VT3216_A0)
938952
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)
985999
*/
9861000
static void velocity_print_link_status(struct velocity_info *vptr)
9871001
{
1002+
const char *link;
1003+
const char *speed;
1004+
const char *duplex;
9881005

9891006
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";
9931013

9941014
if (vptr->mii_status & VELOCITY_SPEED_1000)
995-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps");
1015+
speed = "1000";
9961016
else if (vptr->mii_status & VELOCITY_SPEED_100)
997-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps");
1017+
speed = "100";
9981018
else
999-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps");
1019+
speed = "10";
10001020

10011021
if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
1002-
VELOCITY_PRT(MSG_LEVEL_INFO, " full duplex\n");
1022+
duplex = "full";
10031023
else
1004-
VELOCITY_PRT(MSG_LEVEL_INFO, " half duplex\n");
1024+
duplex = "half";
10051025
} else {
1006-
VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", vptr->netdev->name);
1026+
link = "forced";
1027+
10071028
switch (vptr->options.spd_dpx) {
10081029
case SPD_DPX_1000_FULL:
1009-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps full duplex\n");
1030+
speed = "1000";
1031+
duplex = "full";
10101032
break;
10111033
case SPD_DPX_100_HALF:
1012-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps half duplex\n");
1034+
speed = "100";
1035+
duplex = "half";
10131036
break;
10141037
case SPD_DPX_100_FULL:
1015-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps full duplex\n");
1038+
speed = "100";
1039+
duplex = "full";
10161040
break;
10171041
case SPD_DPX_10_HALF:
1018-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps half duplex\n");
1042+
speed = "10";
1043+
duplex = "half";
10191044
break;
10201045
case SPD_DPX_10_FULL:
1021-
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 10M bps full duplex\n");
1046+
speed = "10";
1047+
duplex = "full";
10221048
break;
10231049
default:
1050+
speed = "unknown";
1051+
duplex = "unknown";
10241052
break;
10251053
}
10261054
}
1055+
netdev_notice(vptr->netdev, "Link %s speed %sM bps %s duplex\n",
1056+
link, speed, duplex);
10271057
}
10281058

10291059
/**
@@ -1621,8 +1651,7 @@ static int velocity_init_rd_ring(struct velocity_info *vptr)
16211651
velocity_init_rx_ring_indexes(vptr);
16221652

16231653
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");
16261655
velocity_free_rd_ring(vptr);
16271656
goto out;
16281657
}
@@ -1805,7 +1834,8 @@ static void velocity_error(struct velocity_info *vptr, int status)
18051834
if (status & ISR_TXSTLI) {
18061835
struct mac_regs __iomem *regs = vptr->mac_regs;
18071836

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]));
18091839
BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
18101840
writew(TRDCSR_RUN, &regs->TDCSRClr);
18111841
netif_stop_queue(vptr->netdev);
@@ -2036,7 +2066,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
20362066

20372067
if (unlikely(rd->rdesc0.RSR & (RSR_STP | RSR_EDP | RSR_RL))) {
20382068
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");
20402070
stats->rx_length_errors++;
20412071
return -EINVAL;
20422072
}
@@ -2721,11 +2751,8 @@ static int velocity_get_platform_info(struct velocity_info *vptr)
27212751
*/
27222752
static void velocity_print_info(struct velocity_info *vptr)
27232753
{
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);
27292756
}
27302757

27312758
static u32 velocity_get_link(struct net_device *dev)
@@ -2748,10 +2775,8 @@ static int velocity_probe(struct device *dev, int irq,
27482775
const struct velocity_info_tbl *info,
27492776
enum velocity_bus_type bustype)
27502777
{
2751-
static int first = 1;
27522778
struct net_device *netdev;
27532779
int i;
2754-
const char *drv_string;
27552780
struct velocity_info *vptr;
27562781
struct mac_regs __iomem *regs;
27572782
int ret = -ENOMEM;
@@ -2773,13 +2798,9 @@ static int velocity_probe(struct device *dev, int irq,
27732798
SET_NETDEV_DEV(netdev, dev);
27742799
vptr = netdev_priv(netdev);
27752800

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");
27832804

27842805
netdev->irq = irq;
27852806
vptr->netdev = netdev;
@@ -2815,9 +2836,7 @@ static int velocity_probe(struct device *dev, int irq,
28152836
netdev->dev_addr[i] = readb(&regs->PAR[i]);
28162837

28172838

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);
28212840

28222841
/*
28232842
* 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
34693488
return 0;
34703489
}
34713490

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-
34823491
static int get_pending_timer_val(int val)
34833492
{
34843493
int mult_bits = val >> 6;
@@ -3653,8 +3662,6 @@ static const struct ethtool_ops velocity_ethtool_ops = {
36533662
.get_drvinfo = velocity_get_drvinfo,
36543663
.get_wol = velocity_ethtool_get_wol,
36553664
.set_wol = velocity_ethtool_set_wol,
3656-
.get_msglevel = velocity_get_msglevel,
3657-
.set_msglevel = velocity_set_msglevel,
36583665
.get_link = velocity_get_link,
36593666
.get_strings = velocity_get_strings,
36603667
.get_sset_count = velocity_get_sset_count,

drivers/net/ethernet/via/via-velocity.h

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,50 +1286,6 @@ struct velocity_context {
12861286
velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\
12871287
(id);})
12881288

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-
13331289
#define VELOCITY_WOL_MAGIC 0x00000000UL
13341290
#define VELOCITY_WOL_PHY 0x00000001UL
13351291
#define VELOCITY_WOL_ARP 0x00000002UL

0 commit comments

Comments
 (0)