Commit 2f53e904 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by David S. Miller

phy: coding style fixes

The recent patch from Florian Fainelli fixed all 'checkpatch.pl' errors but left
the numerous warnings:

- including <asm/io.h> instead of <linux/io.h>;

- including <asm/uaccess.h> instead of <linux/uaccess.h>;

- *extern* declaration in .c file;

- block comments using empty /* line;

- block comments not starting with * on the middle lines;

- block comments not having trailing */ on a separate line;

- EXPORT_SYMBOL() not immediately following its function;

- unnecessary {} for signle statement block;

- spaces before tabs.

While fixing these, also fix the following style issues (some of which were
found running 'checkpatch.pl --strict'):

- alignment not matching open paren;

- missing {} on one of the *if* arms where another has them;

- use of sizeof(struct structure) instead of sizeof(*variable);

- multiple assignments on one line;

- empty line before };

- file names in the heading comments;

- missing spaces around operators;

- no {} around multi-line *if* operator's arm;

- unneeded () around subexpressions;

- incomplete kernel-doc comment style;

- comment line exceeding 80 characters;

- missing empty line after declarations.
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ffeed1be
/* /* Framework for configuring and reading PHY devices
* drivers/net/phy/phy.c
*
* Framework for configuring and reading PHY devices
* Based on code in sungem_phy.c and gianfar_phy.c * Based on code in sungem_phy.c and gianfar_phy.c
* *
* Author: Andy Fleming * Author: Andy Fleming
...@@ -36,11 +33,11 @@ ...@@ -36,11 +33,11 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/mdio.h> #include <linux/mdio.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/atomic.h> #include <linux/atomic.h>
#include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/uaccess.h>
/** /**
* phy_print_status - Convenience function to print out the current phy status * phy_print_status - Convenience function to print out the current phy status
...@@ -48,13 +45,14 @@ ...@@ -48,13 +45,14 @@
*/ */
void phy_print_status(struct phy_device *phydev) void phy_print_status(struct phy_device *phydev)
{ {
if (phydev->link) if (phydev->link) {
pr_info("%s - Link is Up - %d/%s\n", pr_info("%s - Link is Up - %d/%s\n",
dev_name(&phydev->dev), dev_name(&phydev->dev),
phydev->speed, phydev->speed,
DUPLEX_FULL == phydev->duplex ? "Full" : "Half"); DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
else } else {
pr_info("%s - Link is Down\n", dev_name(&phydev->dev)); pr_info("%s - Link is Down\n", dev_name(&phydev->dev));
}
} }
EXPORT_SYMBOL(phy_print_status); EXPORT_SYMBOL(phy_print_status);
...@@ -114,7 +112,8 @@ static inline int phy_aneg_done(struct phy_device *phydev) ...@@ -114,7 +112,8 @@ static inline int phy_aneg_done(struct phy_device *phydev)
} }
/* A structure for mapping a particular speed and duplex /* A structure for mapping a particular speed and duplex
* combination to a particular SUPPORTED and ADVERTISED value */ * combination to a particular SUPPORTED and ADVERTISED value
*/
struct phy_setting { struct phy_setting {
int speed; int speed;
int duplex; int duplex;
...@@ -177,8 +176,7 @@ static inline int phy_find_setting(int speed, int duplex) ...@@ -177,8 +176,7 @@ static inline int phy_find_setting(int speed, int duplex)
int idx = 0; int idx = 0;
while (idx < ARRAY_SIZE(settings) && while (idx < ARRAY_SIZE(settings) &&
(settings[idx].speed != speed || (settings[idx].speed != speed || settings[idx].duplex != duplex))
settings[idx].duplex != duplex))
idx++; idx++;
return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1; return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1;
...@@ -245,8 +243,7 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) ...@@ -245,8 +243,7 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
if (cmd->phy_address != phydev->addr) if (cmd->phy_address != phydev->addr)
return -EINVAL; return -EINVAL;
/* We make sure that we don't pass unsupported /* We make sure that we don't pass unsupported values in to the PHY */
* values in to the PHY */
cmd->advertising &= phydev->supported; cmd->advertising &= phydev->supported;
/* Verify the settings we care about. */ /* Verify the settings we care about. */
...@@ -313,8 +310,7 @@ EXPORT_SYMBOL(phy_ethtool_gset); ...@@ -313,8 +310,7 @@ EXPORT_SYMBOL(phy_ethtool_gset);
* PHYCONTROL layer. It changes registers without regard to * PHYCONTROL layer. It changes registers without regard to
* current state. Use at own risk. * current state. Use at own risk.
*/ */
int phy_mii_ioctl(struct phy_device *phydev, int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
struct ifreq *ifr, int cmd)
{ {
struct mii_ioctl_data *mii_data = if_mii(ifr); struct mii_ioctl_data *mii_data = if_mii(ifr);
u16 val = mii_data->val_in; u16 val = mii_data->val_in;
...@@ -334,18 +330,17 @@ int phy_mii_ioctl(struct phy_device *phydev, ...@@ -334,18 +330,17 @@ int phy_mii_ioctl(struct phy_device *phydev,
if (mii_data->phy_id == phydev->addr) { if (mii_data->phy_id == phydev->addr) {
switch (mii_data->reg_num) { switch (mii_data->reg_num) {
case MII_BMCR: case MII_BMCR:
if ((val & (BMCR_RESET|BMCR_ANENABLE)) == 0) if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0)
phydev->autoneg = AUTONEG_DISABLE; phydev->autoneg = AUTONEG_DISABLE;
else else
phydev->autoneg = AUTONEG_ENABLE; phydev->autoneg = AUTONEG_ENABLE;
if ((!phydev->autoneg) && (val & BMCR_FULLDPLX)) if (!phydev->autoneg && (val & BMCR_FULLDPLX))
phydev->duplex = DUPLEX_FULL; phydev->duplex = DUPLEX_FULL;
else else
phydev->duplex = DUPLEX_HALF; phydev->duplex = DUPLEX_HALF;
if ((!phydev->autoneg) && if (!phydev->autoneg && (val & BMCR_SPEED1000))
(val & BMCR_SPEED1000))
phydev->speed = SPEED_1000; phydev->speed = SPEED_1000;
else if ((!phydev->autoneg) && else if (!phydev->autoneg &&
(val & BMCR_SPEED100)) (val & BMCR_SPEED100))
phydev->speed = SPEED_100; phydev->speed = SPEED_100;
break; break;
...@@ -494,7 +489,8 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) ...@@ -494,7 +489,8 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
/* The MDIO bus is not allowed to be written in interrupt /* The MDIO bus is not allowed to be written in interrupt
* context, so we need to disable the irq here. A work * context, so we need to disable the irq here. A work
* queue will write the PHY to disable and clear the * queue will write the PHY to disable and clear the
* interrupt, and then reenable the irq line. */ * interrupt, and then reenable the irq line.
*/
disable_irq_nosync(irq); disable_irq_nosync(irq);
atomic_inc(&phydev->irq_disable); atomic_inc(&phydev->irq_disable);
...@@ -595,15 +591,13 @@ int phy_stop_interrupts(struct phy_device *phydev) ...@@ -595,15 +591,13 @@ int phy_stop_interrupts(struct phy_device *phydev)
free_irq(phydev->irq, phydev); free_irq(phydev->irq, phydev);
/* /* Cannot call flush_scheduled_work() here as desired because
* Cannot call flush_scheduled_work() here as desired because
* of rtnl_lock(), but we do not really care about what would * of rtnl_lock(), but we do not really care about what would
* be done, except from enable_irq(), so cancel any work * be done, except from enable_irq(), so cancel any work
* possibly pending and take care of the matter below. * possibly pending and take care of the matter below.
*/ */
cancel_work_sync(&phydev->phy_queue); cancel_work_sync(&phydev->phy_queue);
/* /* If work indeed has been cancelled, disable_irq() will have
* If work indeed has been cancelled, disable_irq() will have
* been left unbalanced from phy_interrupt() and enable_irq() * been left unbalanced from phy_interrupt() and enable_irq()
* has to be called so that other devices on the line work. * has to be called so that other devices on the line work.
*/ */
...@@ -691,12 +685,12 @@ void phy_stop(struct phy_device *phydev) ...@@ -691,12 +685,12 @@ void phy_stop(struct phy_device *phydev)
out_unlock: out_unlock:
mutex_unlock(&phydev->lock); mutex_unlock(&phydev->lock);
/* /* Cannot call flush_scheduled_work() here as desired because
* Cannot call flush_scheduled_work() here as desired because
* of rtnl_lock(), but PHY_HALTED shall guarantee phy_change() * of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
* will not reenable interrupts. * will not reenable interrupts.
*/ */
} }
EXPORT_SYMBOL(phy_stop);
/** /**
...@@ -727,7 +721,6 @@ void phy_start(struct phy_device *phydev) ...@@ -727,7 +721,6 @@ void phy_start(struct phy_device *phydev)
} }
mutex_unlock(&phydev->lock); mutex_unlock(&phydev->lock);
} }
EXPORT_SYMBOL(phy_stop);
EXPORT_SYMBOL(phy_start); EXPORT_SYMBOL(phy_start);
/** /**
...@@ -765,8 +758,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -765,8 +758,7 @@ void phy_state_machine(struct work_struct *work)
if (err < 0) if (err < 0)
break; break;
/* If the link is down, give up on /* If the link is down, give up on negotiation for now */
* negotiation for now */
if (!phydev->link) { if (!phydev->link) {
phydev->state = PHY_NOLINK; phydev->state = PHY_NOLINK;
netif_carrier_off(phydev->attached_dev); netif_carrier_off(phydev->attached_dev);
...@@ -774,8 +766,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -774,8 +766,7 @@ void phy_state_machine(struct work_struct *work)
break; break;
} }
/* Check if negotiation is done. Break /* Check if negotiation is done. Break if there's an error */
* if there's an error */
err = phy_aneg_done(phydev); err = phy_aneg_done(phydev);
if (err < 0) if (err < 0)
break; break;
...@@ -788,8 +779,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -788,8 +779,7 @@ void phy_state_machine(struct work_struct *work)
} else if (0 == phydev->link_timeout--) { } else if (0 == phydev->link_timeout--) {
needs_aneg = 1; needs_aneg = 1;
/* If we have the magic_aneg bit, /* If we have the magic_aneg bit, we try again */
* we try again */
if (phydev->drv->flags & PHY_HAS_MAGICANEG) if (phydev->drv->flags & PHY_HAS_MAGICANEG)
break; break;
} }
...@@ -864,8 +854,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -864,8 +854,7 @@ void phy_state_machine(struct work_struct *work)
if (err) if (err)
break; break;
err = phy_config_interrupt(phydev, err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
PHY_INTERRUPT_ENABLED);
if (err) if (err)
break; break;
...@@ -876,8 +865,8 @@ void phy_state_machine(struct work_struct *work) ...@@ -876,8 +865,8 @@ void phy_state_machine(struct work_struct *work)
break; break;
/* err > 0 if AN is done. /* err > 0 if AN is done.
* Otherwise, it's 0, and we're * Otherwise, it's 0, and we're still waiting for AN
* still waiting for AN */ */
if (err > 0) { if (err > 0) {
err = phy_read_status(phydev); err = phy_read_status(phydev);
if (err) if (err)
...@@ -886,8 +875,9 @@ void phy_state_machine(struct work_struct *work) ...@@ -886,8 +875,9 @@ void phy_state_machine(struct work_struct *work)
if (phydev->link) { if (phydev->link) {
phydev->state = PHY_RUNNING; phydev->state = PHY_RUNNING;
netif_carrier_on(phydev->attached_dev); netif_carrier_on(phydev->attached_dev);
} else } else {
phydev->state = PHY_NOLINK; phydev->state = PHY_NOLINK;
}
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
} else { } else {
phydev->state = PHY_AN; phydev->state = PHY_AN;
...@@ -901,8 +891,9 @@ void phy_state_machine(struct work_struct *work) ...@@ -901,8 +891,9 @@ void phy_state_machine(struct work_struct *work)
if (phydev->link) { if (phydev->link) {
phydev->state = PHY_RUNNING; phydev->state = PHY_RUNNING;
netif_carrier_on(phydev->attached_dev); netif_carrier_on(phydev->attached_dev);
} else } else {
phydev->state = PHY_NOLINK; phydev->state = PHY_NOLINK;
}
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
} }
break; break;
...@@ -1091,7 +1082,6 @@ int phy_get_eee_err(struct phy_device *phydev) ...@@ -1091,7 +1082,6 @@ int phy_get_eee_err(struct phy_device *phydev)
{ {
return phy_read_mmd_indirect(phydev->bus, MDIO_PCS_EEE_WK_ERR, return phy_read_mmd_indirect(phydev->bus, MDIO_PCS_EEE_WK_ERR,
MDIO_MMD_PCS, phydev->addr); MDIO_MMD_PCS, phydev->addr);
} }
EXPORT_SYMBOL(phy_get_eee_err); EXPORT_SYMBOL(phy_get_eee_err);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment