diff options
author | Joe Perches <joe@perches.com> | 2010-02-27 09:43:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-17 00:23:25 -0400 |
commit | 0dc7d2b3cbfcf4ff20bdc68f563a2e52e6a2178f (patch) | |
tree | 9f81abd6d5d494230a4d23b1a27f399f5832f9e7 /drivers/net/ksz884x.c | |
parent | ca50910185fcce694af0cc194de50d2374a7c7ef (diff) |
drivers/net/ks*: Use netdev_<level>, netif_<level> and pr_<level>
I'm not sure this is correct.
It changes logging macros from:
dev_<level>(&ks->spidev->dev,
to
netdev_<level>(ks->netdev,
Comments?
Use netdev_<level>
Use netif_<level>
Use pr_<level>
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Add missing line to message in ks8851_remove
Change kmalloc/memset(,0) to kzalloc
Remove ks_<level> macros
Consolidation code into set_media_state
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ksz884x.c')
-rw-r--r-- | drivers/net/ksz884x.c | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c index 0f59099ee72f..f3357ae13f86 100644 --- a/drivers/net/ksz884x.c +++ b/drivers/net/ksz884x.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
18 | |||
17 | #include <linux/init.h> | 19 | #include <linux/init.h> |
18 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
19 | #include <linux/module.h> | 21 | #include <linux/module.h> |
@@ -1483,11 +1485,6 @@ struct dev_priv { | |||
1483 | int promiscuous; | 1485 | int promiscuous; |
1484 | }; | 1486 | }; |
1485 | 1487 | ||
1486 | #define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg) | ||
1487 | #define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg) | ||
1488 | #define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg) | ||
1489 | #define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg) | ||
1490 | |||
1491 | #define DRV_NAME "KSZ884X PCI" | 1488 | #define DRV_NAME "KSZ884X PCI" |
1492 | #define DEVICE_NAME "KSZ884x PCI" | 1489 | #define DEVICE_NAME "KSZ884x PCI" |
1493 | #define DRV_VERSION "1.0.0" | 1490 | #define DRV_VERSION "1.0.0" |
@@ -3834,7 +3831,7 @@ static void ksz_check_desc_num(struct ksz_desc_info *info) | |||
3834 | alloc >>= 1; | 3831 | alloc >>= 1; |
3835 | } | 3832 | } |
3836 | if (alloc != 1 || shift < MIN_DESC_SHIFT) { | 3833 | if (alloc != 1 || shift < MIN_DESC_SHIFT) { |
3837 | printk(KERN_ALERT "Hardware descriptor numbers not right!\n"); | 3834 | pr_alert("Hardware descriptor numbers not right!\n"); |
3838 | while (alloc) { | 3835 | while (alloc) { |
3839 | shift++; | 3836 | shift++; |
3840 | alloc >>= 1; | 3837 | alloc >>= 1; |
@@ -4545,8 +4542,7 @@ static int ksz_alloc_mem(struct dev_info *adapter) | |||
4545 | (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) / | 4542 | (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) / |
4546 | DESC_ALIGNMENT) * DESC_ALIGNMENT); | 4543 | DESC_ALIGNMENT) * DESC_ALIGNMENT); |
4547 | if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc)) | 4544 | if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc)) |
4548 | printk(KERN_ALERT | 4545 | pr_alert("Hardware descriptor size not right!\n"); |
4549 | "Hardware descriptor size not right!\n"); | ||
4550 | ksz_check_desc_num(&hw->rx_desc_info); | 4546 | ksz_check_desc_num(&hw->rx_desc_info); |
4551 | ksz_check_desc_num(&hw->tx_desc_info); | 4547 | ksz_check_desc_num(&hw->tx_desc_info); |
4552 | 4548 | ||
@@ -5319,10 +5315,10 @@ static irqreturn_t netdev_intr(int irq, void *dev_id) | |||
5319 | u32 data; | 5315 | u32 data; |
5320 | 5316 | ||
5321 | hw->intr_mask &= ~KS884X_INT_TX_STOPPED; | 5317 | hw->intr_mask &= ~KS884X_INT_TX_STOPPED; |
5322 | printk(KERN_INFO "Tx stopped\n"); | 5318 | pr_info("Tx stopped\n"); |
5323 | data = readl(hw->io + KS_DMA_TX_CTRL); | 5319 | data = readl(hw->io + KS_DMA_TX_CTRL); |
5324 | if (!(data & DMA_TX_ENABLE)) | 5320 | if (!(data & DMA_TX_ENABLE)) |
5325 | printk(KERN_INFO "Tx disabled\n"); | 5321 | pr_info("Tx disabled\n"); |
5326 | break; | 5322 | break; |
5327 | } | 5323 | } |
5328 | } while (0); | 5324 | } while (0); |
@@ -5495,6 +5491,18 @@ static int prepare_hardware(struct net_device *dev) | |||
5495 | return 0; | 5491 | return 0; |
5496 | } | 5492 | } |
5497 | 5493 | ||
5494 | static void set_media_state(struct net_device *dev, int media_state) | ||
5495 | { | ||
5496 | struct dev_priv *priv = netdev_priv(dev); | ||
5497 | |||
5498 | if (media_state == priv->media_state) | ||
5499 | netif_carrier_on(dev); | ||
5500 | else | ||
5501 | netif_carrier_off(dev); | ||
5502 | netif_info(priv, link, dev, "link %s\n", | ||
5503 | media_state == priv->media_state ? "on" : "off"); | ||
5504 | } | ||
5505 | |||
5498 | /** | 5506 | /** |
5499 | * netdev_open - open network device | 5507 | * netdev_open - open network device |
5500 | * @dev: Network device. | 5508 | * @dev: Network device. |
@@ -5584,15 +5592,7 @@ static int netdev_open(struct net_device *dev) | |||
5584 | 5592 | ||
5585 | priv->media_state = port->linked->state; | 5593 | priv->media_state = port->linked->state; |
5586 | 5594 | ||
5587 | if (media_connected == priv->media_state) | 5595 | set_media_state(dev, media_connected); |
5588 | netif_carrier_on(dev); | ||
5589 | else | ||
5590 | netif_carrier_off(dev); | ||
5591 | if (netif_msg_link(priv)) | ||
5592 | printk(KERN_INFO "%s link %s\n", dev->name, | ||
5593 | (media_connected == priv->media_state ? | ||
5594 | "on" : "off")); | ||
5595 | |||
5596 | netif_start_queue(dev); | 5596 | netif_start_queue(dev); |
5597 | 5597 | ||
5598 | return 0; | 5598 | return 0; |
@@ -6682,16 +6682,8 @@ static void update_link(struct net_device *dev, struct dev_priv *priv, | |||
6682 | { | 6682 | { |
6683 | if (priv->media_state != port->linked->state) { | 6683 | if (priv->media_state != port->linked->state) { |
6684 | priv->media_state = port->linked->state; | 6684 | priv->media_state = port->linked->state; |
6685 | if (netif_running(dev)) { | 6685 | if (netif_running(dev)) |
6686 | if (media_connected == priv->media_state) | 6686 | set_media_state(dev, media_connected); |
6687 | netif_carrier_on(dev); | ||
6688 | else | ||
6689 | netif_carrier_off(dev); | ||
6690 | if (netif_msg_link(priv)) | ||
6691 | printk(KERN_INFO "%s link %s\n", dev->name, | ||
6692 | (media_connected == priv->media_state ? | ||
6693 | "on" : "off")); | ||
6694 | } | ||
6695 | } | 6687 | } |
6696 | } | 6688 | } |
6697 | 6689 | ||
@@ -6985,7 +6977,7 @@ static int __init pcidev_init(struct pci_dev *pdev, | |||
6985 | int pi; | 6977 | int pi; |
6986 | int port_count; | 6978 | int port_count; |
6987 | int result; | 6979 | int result; |
6988 | char banner[80]; | 6980 | char banner[sizeof(version)]; |
6989 | struct ksz_switch *sw = NULL; | 6981 | struct ksz_switch *sw = NULL; |
6990 | 6982 | ||
6991 | result = pci_enable_device(pdev); | 6983 | result = pci_enable_device(pdev); |
@@ -7009,10 +7001,9 @@ static int __init pcidev_init(struct pci_dev *pdev, | |||
7009 | 7001 | ||
7010 | result = -ENOMEM; | 7002 | result = -ENOMEM; |
7011 | 7003 | ||
7012 | info = kmalloc(sizeof(struct platform_info), GFP_KERNEL); | 7004 | info = kzalloc(sizeof(struct platform_info), GFP_KERNEL); |
7013 | if (!info) | 7005 | if (!info) |
7014 | goto pcidev_init_dev_err; | 7006 | goto pcidev_init_dev_err; |
7015 | memset(info, 0, sizeof(struct platform_info)); | ||
7016 | 7007 | ||
7017 | hw_priv = &info->dev_info; | 7008 | hw_priv = &info->dev_info; |
7018 | hw_priv->pdev = pdev; | 7009 | hw_priv->pdev = pdev; |
@@ -7026,15 +7017,15 @@ static int __init pcidev_init(struct pci_dev *pdev, | |||
7026 | cnt = hw_init(hw); | 7017 | cnt = hw_init(hw); |
7027 | if (!cnt) { | 7018 | if (!cnt) { |
7028 | if (msg_enable & NETIF_MSG_PROBE) | 7019 | if (msg_enable & NETIF_MSG_PROBE) |
7029 | printk(KERN_ALERT "chip not detected\n"); | 7020 | pr_alert("chip not detected\n"); |
7030 | result = -ENODEV; | 7021 | result = -ENODEV; |
7031 | goto pcidev_init_alloc_err; | 7022 | goto pcidev_init_alloc_err; |
7032 | } | 7023 | } |
7033 | 7024 | ||
7034 | sprintf(banner, "%s\n", version); | 7025 | snprintf(banner, sizeof(banner), "%s", version); |
7035 | banner[13] = cnt + '0'; | 7026 | banner[13] = cnt + '0'; /* Replace x in "Micrel KSZ884x" */ |
7036 | ks_info(hw_priv, "%s", banner); | 7027 | dev_info(&hw_priv->pdev->dev, "%s\n", banner); |
7037 | ks_dbg(hw_priv, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq); | 7028 | dev_dbg(&hw_priv->pdev->dev, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq); |
7038 | 7029 | ||
7039 | /* Assume device is KSZ8841. */ | 7030 | /* Assume device is KSZ8841. */ |
7040 | hw->dev_count = 1; | 7031 | hw->dev_count = 1; |