lkml.org 
[lkml]   [2006]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 5/5] [pci pm] Make pci_choose_state() use the real device state requested

    - Look at pm_message_t::state (along with the message event type) to
    determine the PCI power state to return. This allows all of the PCI
    power states to be used with this helper (and with the sysfs runtime
    PM interface).

    [ Previously, the returned value was limited to PCI_D0 or PCI_D3hot
    depending on whether PM_EVENT_ON or PM_EVENT_{FREEZE,SUSPEND} were
    specified. ]

    - Print an error w/ device info when we get an invalid state; use
    WARN_ON() instead of BUG(), so we don't needlessly crash a machine.

    - Print state translation when debug is enabled.

    Signed-off-by: Patrick Mochel <mochel@linux.intel.com>

    ---

    drivers/pci/pci.c | 29 +++++++++++++++++++----------
    1 files changed, 19 insertions(+), 10 deletions(-)

    applies-to: 7b4d08b2816a4aefc2b9891091e6a790526ea15e
    8a658ba724d1f1e71fc951745e091aa1afa4ff6f
    diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
    index d2d1879..2f160aa 100644
    --- a/drivers/pci/pci.c
    +++ b/drivers/pci/pci.c
    @@ -404,30 +404,39 @@ int (*platform_pci_choose_state)(struct
    * message.
    */

    -pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
    +pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t msg)
    {
    + pci_power_t state = PCI_D3hot;
    int ret;

    if (!pci_find_capability(dev, PCI_CAP_ID_PM))
    return PCI_D0;

    if (platform_pci_choose_state) {
    - ret = platform_pci_choose_state(dev, state);
    + ret = platform_pci_choose_state(dev, msg);
    if (ret >= 0)
    - state.event = ret;
    + msg.state = ret;
    }

    - switch (state.event) {
    + switch (msg.event) {
    case PM_EVENT_ON:
    - return PCI_D0;
    + state = PCI_D0;
    + break;
    case PM_EVENT_FREEZE:
    case PM_EVENT_SUSPEND:
    - return PCI_D3hot;
    + if (msg.state && msg.state <= PCI_D3hot)
    + state = msg.state;
    + break;
    default:
    - printk("They asked me for state %d\n", state.event);
    - BUG();
    - }
    - return PCI_D0;
    + dev_err(&dev->dev, "PCI: Invalid PM Event [Event %d] [State %u]\n",
    + msg.event, msg.state);
    + WARN_ON(1);
    + state = PCI_D0;
    + break;
    + }
    + dev_dbg(&dev->dev, "PCI: Translated Power Message %d/%u -> %u\n",
    + msg.event, msg.state, state);
    + return state;
    }

    EXPORT_SYMBOL(pci_choose_state);
    ---
    0.99.9.GIT
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-02-18 03:07    [W:0.028 / U:0.352 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site