Commit fa28a2b2 authored by David S. Miller's avatar David S. Miller

Merge branch 'phylib-simplifications'

Heiner Kallweit says:

====================
net: phy: further phylib simplifications after recent changes to the state machine

After the recent changes to the state machine phylib can be further
simplified (w/o having to make any assumptions).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d79e26a7 34d884e3
...@@ -723,30 +723,26 @@ static int phy_disable_interrupts(struct phy_device *phydev) ...@@ -723,30 +723,26 @@ static int phy_disable_interrupts(struct phy_device *phydev)
} }
/** /**
* phy_change - Called by the phy_interrupt to handle PHY changes * phy_interrupt - PHY interrupt handler
* @phydev: phy_device struct that interrupted * @irq: interrupt line
* @phy_dat: phy_device pointer
*
* Description: Handle PHY interrupt
*/ */
static irqreturn_t phy_change(struct phy_device *phydev) static irqreturn_t phy_interrupt(int irq, void *phy_dat)
{ {
if (phy_interrupt_is_valid(phydev)) { struct phy_device *phydev = phy_dat;
if (phydev->drv->did_interrupt &&
!phydev->drv->did_interrupt(phydev))
return IRQ_NONE;
if (phydev->state == PHY_HALTED)
if (phy_disable_interrupts(phydev))
goto phy_err;
}
mutex_lock(&phydev->lock); if (PHY_HALTED == phydev->state)
if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state)) return IRQ_NONE; /* It can't be ours. */
phydev->state = PHY_CHANGELINK;
mutex_unlock(&phydev->lock); if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
return IRQ_NONE;
/* reschedule state queue work to run as soon as possible */ /* reschedule state queue work to run as soon as possible */
phy_trigger_machine(phydev); phy_trigger_machine(phydev);
if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev)) if (phy_clear_interrupt(phydev))
goto phy_err; goto phy_err;
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -755,36 +751,6 @@ static irqreturn_t phy_change(struct phy_device *phydev) ...@@ -755,36 +751,6 @@ static irqreturn_t phy_change(struct phy_device *phydev)
return IRQ_NONE; return IRQ_NONE;
} }
/**
* phy_change_work - Scheduled by the phy_mac_interrupt to handle PHY changes
* @work: work_struct that describes the work to be done
*/
void phy_change_work(struct work_struct *work)
{
struct phy_device *phydev =
container_of(work, struct phy_device, phy_queue);
phy_change(phydev);
}
/**
* phy_interrupt - PHY interrupt handler
* @irq: interrupt line
* @phy_dat: phy_device pointer
*
* Description: When a PHY interrupt occurs, the handler disables
* interrupts, and uses phy_change to handle the interrupt.
*/
static irqreturn_t phy_interrupt(int irq, void *phy_dat)
{
struct phy_device *phydev = phy_dat;
if (PHY_HALTED == phydev->state)
return IRQ_NONE; /* It can't be ours. */
return phy_change(phydev);
}
/** /**
* phy_enable_interrupts - Enable the interrupts from the PHY side * phy_enable_interrupts - Enable the interrupts from the PHY side
* @phydev: target phy_device struct * @phydev: target phy_device struct
...@@ -863,7 +829,7 @@ void phy_stop(struct phy_device *phydev) ...@@ -863,7 +829,7 @@ void phy_stop(struct phy_device *phydev)
phy_state_machine(&phydev->state_queue.work); phy_state_machine(&phydev->state_queue.work);
/* 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 irq handler
* will not reenable interrupts. * will not reenable interrupts.
*/ */
} }
...@@ -946,9 +912,6 @@ void phy_state_machine(struct work_struct *work) ...@@ -946,9 +912,6 @@ void phy_state_machine(struct work_struct *work)
break; break;
case PHY_NOLINK: case PHY_NOLINK:
case PHY_RUNNING: case PHY_RUNNING:
if (!phy_polling_mode(phydev))
break;
/* fall through */
case PHY_CHANGELINK: case PHY_CHANGELINK:
case PHY_RESUMING: case PHY_RESUMING:
err = phy_check_link_status(phydev); err = phy_check_link_status(phydev);
...@@ -1013,7 +976,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -1013,7 +976,7 @@ void phy_state_machine(struct work_struct *work)
void phy_mac_interrupt(struct phy_device *phydev) void phy_mac_interrupt(struct phy_device *phydev)
{ {
/* Trigger a state machine change */ /* Trigger a state machine change */
queue_work(system_power_efficient_wq, &phydev->phy_queue); phy_trigger_machine(phydev);
} }
EXPORT_SYMBOL(phy_mac_interrupt); EXPORT_SYMBOL(phy_mac_interrupt);
......
...@@ -587,7 +587,6 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, ...@@ -587,7 +587,6 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
mutex_init(&dev->lock); mutex_init(&dev->lock);
INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
INIT_WORK(&dev->phy_queue, phy_change_work);
/* Request the appropriate module unconditionally; don't /* Request the appropriate module unconditionally; don't
* bother trying to do so only if it isn't already loaded, * bother trying to do so only if it isn't already loaded,
......
...@@ -298,7 +298,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); ...@@ -298,7 +298,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
* - timer moves to NOLINK or RUNNING * - timer moves to NOLINK or RUNNING
* *
* NOLINK: PHY is up, but not currently plugged in. * NOLINK: PHY is up, but not currently plugged in.
* - If the timer notes that the link comes back, we move to RUNNING * - irq or timer will set RUNNING if link comes back
* - phy_stop moves to HALTED * - phy_stop moves to HALTED
* *
* FORCING: PHY is being configured with forced settings * FORCING: PHY is being configured with forced settings
...@@ -309,10 +309,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); ...@@ -309,10 +309,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
* *
* RUNNING: PHY is currently up, running, and possibly sending * RUNNING: PHY is currently up, running, and possibly sending
* and/or receiving packets * and/or receiving packets
* - timer will set CHANGELINK if we're polling (this ensures the * - irq or timer will set NOLINK if link goes down
* link state is polled every other cycle of this state machine,
* which makes it every other second)
* - irq will set CHANGELINK
* - phy_stop moves to HALTED * - phy_stop moves to HALTED
* *
* CHANGELINK: PHY experienced a change in link state * CHANGELINK: PHY experienced a change in link state
...@@ -372,7 +369,6 @@ struct phy_c45_device_ids { ...@@ -372,7 +369,6 @@ struct phy_c45_device_ids {
* giving up on the current attempt at acquiring a link * giving up on the current attempt at acquiring a link
* irq: IRQ number of the PHY's interrupt (-1 if none) * irq: IRQ number of the PHY's interrupt (-1 if none)
* phy_timer: The timer for handling the state machine * phy_timer: The timer for handling the state machine
* phy_queue: A work_queue for the phy_mac_interrupt
* attached_dev: The attached enet driver's device instance ptr * attached_dev: The attached enet driver's device instance ptr
* adjust_link: Callback for the enet controller to respond to * adjust_link: Callback for the enet controller to respond to
* changes in the link state. * changes in the link state.
...@@ -457,7 +453,6 @@ struct phy_device { ...@@ -457,7 +453,6 @@ struct phy_device {
void *priv; void *priv;
/* Interrupt and Polling infrastructure */ /* Interrupt and Polling infrastructure */
struct work_struct phy_queue;
struct delayed_work state_queue; struct delayed_work state_queue;
struct mutex lock; struct mutex lock;
...@@ -1032,7 +1027,6 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner); ...@@ -1032,7 +1027,6 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner);
int phy_drivers_register(struct phy_driver *new_driver, int n, int phy_drivers_register(struct phy_driver *new_driver, int n,
struct module *owner); struct module *owner);
void phy_state_machine(struct work_struct *work); void phy_state_machine(struct work_struct *work);
void phy_change_work(struct work_struct *work);
void phy_mac_interrupt(struct phy_device *phydev); void phy_mac_interrupt(struct phy_device *phydev);
void phy_start_machine(struct phy_device *phydev); void phy_start_machine(struct phy_device *phydev);
void phy_stop_machine(struct phy_device *phydev); void phy_stop_machine(struct phy_device *phydev);
......
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