2018-01-26 23:22:04 +03:00
// SPDX-License-Identifier: GPL-2.0+
2005-04-17 02:20:36 +04:00
/*
* PCI Express Hot Plug Controller Driver
*
* Copyright ( C ) 1995 , 2001 Compaq Computer Corporation
* Copyright ( C ) 2001 Greg Kroah - Hartman ( greg @ kroah . com )
* Copyright ( C ) 2001 IBM Corp .
* Copyright ( C ) 2003 - 2004 Intel Corporation
*
* All rights reserved .
*
2005-08-17 02:16:10 +04:00
* Send feedback to < greg @ kroah . com > , < kristen . c . accardi @ intel . com >
2005-04-17 02:20:36 +04:00
*
*/
# include <linux/module.h>
# include <linux/kernel.h>
# include <linux/types.h>
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
# include <linux/slab.h>
2005-04-17 02:20:36 +04:00
# include <linux/pci.h>
# include "../pci.h"
# include "pciehp.h"
2007-08-10 03:09:36 +04:00
/* The following routines constitute the bulk of the
2005-04-17 02:20:36 +04:00
hotplug controller logic
*/
2014-04-19 04:13:49 +04:00
static void set_slot_off ( struct controller * ctrl , struct slot * pslot )
2005-04-17 02:20:36 +04:00
{
/* turn off slot, turn on Amber LED, turn off Green LED if supported*/
2008-04-26 01:39:06 +04:00
if ( POWER_CTRL ( ctrl ) ) {
2013-12-15 00:06:16 +04:00
pciehp_power_off_slot ( pslot ) ;
2008-10-24 09:26:35 +04:00
/*
* After turning power off , we must wait for at least 1 second
* before taking any action that relies on power having been
* removed from the slot / adapter .
*/
msleep ( 1000 ) ;
2005-04-17 02:20:36 +04:00
}
2013-12-16 04:23:54 +04:00
pciehp_green_led_off ( pslot ) ;
pciehp_set_attention_status ( pslot , 1 ) ;
2005-04-17 02:20:36 +04:00
}
/**
* board_added - Called after a board has been added to the system .
2007-11-28 20:04:30 +03:00
* @ p_slot : & slot where board is added
2005-04-17 02:20:36 +04:00
*
2007-11-28 20:04:30 +03:00
* Turns power on for the board .
* Configures board .
2005-04-17 02:20:36 +04:00
*/
2005-11-01 03:20:09 +03:00
static int board_added ( struct slot * p_slot )
2005-04-17 02:20:36 +04:00
{
2006-12-22 04:01:09 +03:00
int retval = 0 ;
2005-11-01 03:20:08 +03:00
struct controller * ctrl = p_slot - > ctrl ;
2009-09-15 12:30:14 +04:00
struct pci_bus * parent = ctrl - > pcie - > port - > subordinate ;
2005-04-17 02:20:36 +04:00
2008-04-26 01:39:06 +04:00
if ( POWER_CTRL ( ctrl ) ) {
2005-04-17 02:20:36 +04:00
/* Power on slot */
2009-09-15 12:30:48 +04:00
retval = pciehp_power_on_slot ( p_slot ) ;
2006-12-22 04:01:09 +03:00
if ( retval )
return retval ;
2005-04-17 02:20:36 +04:00
}
2007-08-10 03:09:36 +04:00
2013-12-16 04:23:54 +04:00
pciehp_green_led_blink ( p_slot ) ;
2005-04-17 02:20:36 +04:00
2006-12-22 04:01:09 +03:00
/* Check link training status */
2009-09-15 12:30:48 +04:00
retval = pciehp_check_link_status ( ctrl ) ;
2006-12-22 04:01:09 +03:00
if ( retval ) {
2008-10-23 06:47:32 +04:00
ctrl_err ( ctrl , " Failed to check link status \n " ) ;
2009-11-13 09:14:10 +03:00
goto err_exit ;
2005-04-17 02:20:36 +04:00
}
/* Check for a power fault */
2009-11-13 09:14:10 +03:00
if ( ctrl - > power_fault_detected | | pciehp_query_power_fault ( p_slot ) ) {
2016-09-08 23:19:58 +03:00
ctrl_err ( ctrl , " Slot(%s): Power fault \n " , slot_name ( p_slot ) ) ;
2009-09-15 12:33:30 +04:00
retval = - EIO ;
2005-11-01 03:20:06 +03:00
goto err_exit ;
2005-04-17 02:20:36 +04:00
}
2006-12-22 04:01:09 +03:00
retval = pciehp_configure_device ( p_slot ) ;
if ( retval ) {
2017-10-13 21:35:46 +03:00
if ( retval ! = - EEXIST ) {
ctrl_err ( ctrl , " Cannot add device at %04x:%02x:00 \n " ,
pci_domain_nr ( parent ) , parent - > number ) ;
2014-02-12 04:36:51 +04:00
goto err_exit ;
2017-10-13 21:35:46 +03:00
}
2005-11-01 03:20:06 +03:00
}
2005-04-17 02:20:36 +04:00
2013-12-16 04:23:54 +04:00
pciehp_green_led_on ( p_slot ) ;
2016-08-04 02:29:45 +03:00
pciehp_set_attention_status ( p_slot , 0 ) ;
2005-04-17 02:20:36 +04:00
return 0 ;
2005-11-01 03:20:06 +03:00
err_exit :
set_slot_off ( ctrl , p_slot ) ;
2006-12-22 04:01:09 +03:00
return retval ;
2005-04-17 02:20:36 +04:00
}
/**
2007-11-28 20:04:30 +03:00
* remove_board - Turns off slot and LEDs
* @ p_slot : slot where board is being removed
2005-04-17 02:20:36 +04:00
*/
2018-07-20 01:27:36 +03:00
static void remove_board ( struct slot * p_slot )
2005-04-17 02:20:36 +04:00
{
2005-11-01 03:20:08 +03:00
struct controller * ctrl = p_slot - > ctrl ;
2005-04-17 02:20:36 +04:00
2018-07-20 01:27:36 +03:00
pciehp_unconfigure_device ( p_slot ) ;
2005-04-17 02:20:36 +04:00
2008-04-26 01:39:06 +04:00
if ( POWER_CTRL ( ctrl ) ) {
2013-12-15 00:06:16 +04:00
pciehp_power_off_slot ( p_slot ) ;
2008-10-24 09:26:35 +04:00
/*
* After turning power off , we must wait for at least 1 second
* before taking any action that relies on power having been
* removed from the slot / adapter .
*/
msleep ( 1000 ) ;
2005-04-17 02:20:36 +04:00
}
2009-09-15 12:30:48 +04:00
/* turn off Green LED */
2013-12-16 04:23:54 +04:00
pciehp_green_led_off ( p_slot ) ;
2005-04-17 02:20:36 +04:00
}
2015-10-12 22:10:12 +03:00
void pciehp_queue_pushbutton_work ( struct work_struct * work )
{
struct slot * p_slot = container_of ( work , struct slot , work . work ) ;
2005-04-17 02:20:36 +04:00
2007-03-07 02:02:26 +03:00
mutex_lock ( & p_slot - > lock ) ;
switch ( p_slot - > state ) {
case BLINKINGOFF_STATE :
2018-07-20 01:27:41 +03:00
p_slot - > state = POWEROFF_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
pciehp_disable_slot ( p_slot ) ;
return ;
2007-03-07 02:02:26 +03:00
case BLINKINGON_STATE :
2018-07-20 01:27:41 +03:00
p_slot - > state = POWERON_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
pciehp_enable_slot ( p_slot ) ;
return ;
2007-03-07 02:02:26 +03:00
default :
2015-10-12 22:10:12 +03:00
break ;
2005-04-17 02:20:36 +04:00
}
2007-03-07 02:02:26 +03:00
mutex_unlock ( & p_slot - > lock ) ;
2005-04-17 02:20:36 +04:00
}
2018-07-20 01:27:41 +03:00
void pciehp_handle_button_press ( struct slot * p_slot )
2005-04-17 02:20:36 +04:00
{
2007-03-07 02:02:26 +03:00
struct controller * ctrl = p_slot - > ctrl ;
2005-04-17 02:20:36 +04:00
2018-07-20 01:27:41 +03:00
mutex_lock ( & p_slot - > lock ) ;
2007-03-07 02:02:26 +03:00
switch ( p_slot - > state ) {
2018-07-20 01:27:45 +03:00
case OFF_STATE :
case ON_STATE :
if ( p_slot - > state = = ON_STATE ) {
2007-03-07 02:02:26 +03:00
p_slot - > state = BLINKINGOFF_STATE ;
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Powering off due to button press \n " ,
2014-04-19 04:13:50 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
} else {
p_slot - > state = BLINKINGON_STATE ;
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s) Powering on due to button press \n " ,
2014-04-19 04:13:50 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
}
/* blink green LED and turn off amber */
2013-12-16 04:23:54 +04:00
pciehp_green_led_blink ( p_slot ) ;
pciehp_set_attention_status ( p_slot , 0 ) ;
2018-07-20 01:27:42 +03:00
schedule_delayed_work ( & p_slot - > work , 5 * HZ ) ;
2007-03-07 02:02:26 +03:00
break ;
case BLINKINGOFF_STATE :
case BLINKINGON_STATE :
/*
* Cancel if we are still blinking ; this means that we
* press the attention again before the 5 sec . limit
* expires to cancel hot - add or hot - remove
*/
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Button cancel \n " , slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
cancel_delayed_work ( & p_slot - > work ) ;
2018-07-20 01:27:45 +03:00
if ( p_slot - > state = = BLINKINGOFF_STATE ) {
p_slot - > state = ON_STATE ;
2013-12-16 04:23:54 +04:00
pciehp_green_led_on ( p_slot ) ;
2018-07-20 01:27:45 +03:00
} else {
p_slot - > state = OFF_STATE ;
2013-12-16 04:23:54 +04:00
pciehp_green_led_off ( p_slot ) ;
2018-07-20 01:27:45 +03:00
}
2013-12-16 04:23:54 +04:00
pciehp_set_attention_status ( p_slot , 0 ) ;
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Action canceled due to button press \n " ,
2014-04-19 04:13:50 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
case POWEROFF_STATE :
case POWERON_STATE :
/*
* Ignore if the slot is on power - on or power - off state ;
* this means that the previous attention button action
* to hot - add or hot - remove is undergoing
*/
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Button ignored \n " ,
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
default :
2016-09-08 23:19:58 +03:00
ctrl_err ( ctrl , " Slot(%s): Ignoring invalid state %#x \n " ,
slot_name ( p_slot ) , p_slot - > state ) ;
2007-03-07 02:02:26 +03:00
break ;
2005-04-17 02:20:36 +04:00
}
2018-07-20 01:27:41 +03:00
mutex_unlock ( & p_slot - > lock ) ;
2005-04-17 02:20:36 +04:00
}
2018-07-20 01:27:41 +03:00
void pciehp_handle_link_change ( struct slot * p_slot )
2014-02-05 06:29:10 +04:00
{
struct controller * ctrl = p_slot - > ctrl ;
2018-07-20 01:27:41 +03:00
bool link_active ;
mutex_lock ( & p_slot - > lock ) ;
link_active = pciehp_check_link_active ( ctrl ) ;
2014-02-05 06:29:10 +04:00
switch ( p_slot - > state ) {
case BLINKINGON_STATE :
case BLINKINGOFF_STATE :
cancel_delayed_work ( & p_slot - > work ) ;
/* Fall through */
2018-07-20 01:27:45 +03:00
case ON_STATE :
case OFF_STATE :
2018-07-20 01:27:41 +03:00
if ( link_active ) {
p_slot - > state = POWERON_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
ctrl_info ( ctrl , " Slot(%s): Link Up \n " , slot_name ( p_slot ) ) ;
pciehp_enable_slot ( p_slot ) ;
} else {
p_slot - > state = POWEROFF_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
ctrl_info ( ctrl , " Slot(%s): Link Down \n " , slot_name ( p_slot ) ) ;
pciehp_disable_slot ( p_slot ) ;
}
return ;
2014-02-05 06:29:10 +04:00
break ;
case POWERON_STATE :
2018-07-20 01:27:41 +03:00
if ( link_active ) {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Link Up event ignored; already powering on \n " ,
2014-02-05 06:29:10 +04:00
slot_name ( p_slot ) ) ;
} else {
2018-07-20 01:27:41 +03:00
p_slot - > state = POWEROFF_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Link Down event queued; currently getting powered on \n " ,
2014-02-05 06:29:10 +04:00
slot_name ( p_slot ) ) ;
2018-07-20 01:27:41 +03:00
pciehp_disable_slot ( p_slot ) ;
return ;
2014-02-05 06:29:10 +04:00
}
break ;
case POWEROFF_STATE :
2018-07-20 01:27:41 +03:00
if ( link_active ) {
p_slot - > state = POWERON_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Link Up event queued; currently getting powered off \n " ,
2014-02-05 06:29:10 +04:00
slot_name ( p_slot ) ) ;
2018-07-20 01:27:41 +03:00
pciehp_enable_slot ( p_slot ) ;
return ;
2014-02-05 06:29:10 +04:00
} else {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Link Down event ignored; already powering off \n " ,
2014-02-05 06:29:10 +04:00
slot_name ( p_slot ) ) ;
}
break ;
default :
2016-09-08 23:19:58 +03:00
ctrl_err ( ctrl , " Slot(%s): Ignoring invalid state %#x \n " ,
slot_name ( p_slot ) , p_slot - > state ) ;
2014-02-05 06:29:10 +04:00
break ;
}
2018-07-20 01:27:41 +03:00
mutex_unlock ( & p_slot - > lock ) ;
2014-02-05 06:29:10 +04:00
}
2018-07-20 01:27:41 +03:00
void pciehp_handle_presence_change ( struct slot * slot )
2007-03-07 02:02:26 +03:00
{
2018-07-20 01:27:41 +03:00
struct controller * ctrl = slot - > ctrl ;
u8 present ;
mutex_lock ( & slot - > lock ) ;
pciehp_get_adapter_status ( slot , & present ) ;
ctrl_info ( ctrl , " Slot(%s): Card %spresent \n " , slot_name ( slot ) ,
present ? " " : " not " ) ;
if ( present ) {
slot - > state = POWERON_STATE ;
mutex_unlock ( & slot - > lock ) ;
pciehp_enable_slot ( slot ) ;
} else {
slot - > state = POWEROFF_STATE ;
mutex_unlock ( & slot - > lock ) ;
pciehp_disable_slot ( slot ) ;
2007-03-07 02:02:26 +03:00
}
}
2014-02-05 06:31:11 +04:00
/*
* Note : This function must be called with slot - > hotplug_lock held
*/
2018-07-20 01:27:40 +03:00
static int __pciehp_enable_slot ( struct slot * p_slot )
2005-04-17 02:20:36 +04:00
{
u8 getstatus = 0 ;
2008-09-05 07:11:26 +04:00
struct controller * ctrl = p_slot - > ctrl ;
2005-04-17 02:20:36 +04:00
2013-12-15 00:06:16 +04:00
pciehp_get_adapter_status ( p_slot , & getstatus ) ;
if ( ! getstatus ) {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): No adapter \n " , slot_name ( p_slot ) ) ;
2006-09-20 04:04:33 +04:00
return - ENODEV ;
2005-04-17 02:20:36 +04:00
}
2008-04-26 01:39:06 +04:00
if ( MRL_SENS ( p_slot - > ctrl ) ) {
2013-12-15 00:06:16 +04:00
pciehp_get_latch_status ( p_slot , & getstatus ) ;
if ( getstatus ) {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Latch open \n " ,
2008-10-23 06:47:32 +04:00
slot_name ( p_slot ) ) ;
2006-09-20 04:04:33 +04:00
return - ENODEV ;
2005-04-17 02:20:36 +04:00
}
}
2007-08-10 03:09:36 +04:00
2008-04-26 01:39:06 +04:00
if ( POWER_CTRL ( p_slot - > ctrl ) ) {
2013-12-15 00:06:16 +04:00
pciehp_get_power_status ( p_slot , & getstatus ) ;
if ( getstatus ) {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already enabled \n " ,
2008-10-23 06:47:32 +04:00
slot_name ( p_slot ) ) ;
2016-11-19 11:32:46 +03:00
return 0 ;
2005-04-17 02:20:36 +04:00
}
}
2016-09-08 01:50:30 +03:00
return board_added ( p_slot ) ;
2005-04-17 02:20:36 +04:00
}
2018-07-20 01:27:40 +03:00
int pciehp_enable_slot ( struct slot * slot )
{
struct controller * ctrl = slot - > ctrl ;
int ret ;
mutex_lock ( & slot - > hotplug_lock ) ;
ret = __pciehp_enable_slot ( slot ) ;
mutex_unlock ( & slot - > hotplug_lock ) ;
if ( ret & & ATTN_BUTTN ( ctrl ) )
pciehp_green_led_off ( slot ) ; /* may be blinking */
mutex_lock ( & slot - > lock ) ;
2018-07-20 01:27:45 +03:00
slot - > state = ret ? OFF_STATE : ON_STATE ;
2018-07-20 01:27:40 +03:00
mutex_unlock ( & slot - > lock ) ;
return ret ;
}
2014-02-05 06:31:11 +04:00
/*
* Note : This function must be called with slot - > hotplug_lock held
*/
2018-07-20 01:27:40 +03:00
static int __pciehp_disable_slot ( struct slot * p_slot )
2005-04-17 02:20:36 +04:00
{
u8 getstatus = 0 ;
2008-09-05 07:11:26 +04:00
struct controller * ctrl = p_slot - > ctrl ;
2005-04-17 02:20:36 +04:00
2008-04-26 01:39:06 +04:00
if ( POWER_CTRL ( p_slot - > ctrl ) ) {
2013-12-15 00:06:16 +04:00
pciehp_get_power_status ( p_slot , & getstatus ) ;
if ( ! getstatus ) {
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already disabled \n " ,
2008-10-23 06:47:32 +04:00
slot_name ( p_slot ) ) ;
2006-09-20 04:04:33 +04:00
return - EINVAL ;
2005-04-17 02:20:36 +04:00
}
}
2018-07-20 01:27:36 +03:00
remove_board ( p_slot ) ;
return 0 ;
2005-04-17 02:20:36 +04:00
}
2018-07-20 01:27:40 +03:00
int pciehp_disable_slot ( struct slot * slot )
{
int ret ;
mutex_lock ( & slot - > hotplug_lock ) ;
ret = __pciehp_disable_slot ( slot ) ;
mutex_unlock ( & slot - > hotplug_lock ) ;
mutex_lock ( & slot - > lock ) ;
2018-07-20 01:27:45 +03:00
slot - > state = OFF_STATE ;
2018-07-20 01:27:40 +03:00
mutex_unlock ( & slot - > lock ) ;
return ret ;
}
2007-03-07 02:02:26 +03:00
int pciehp_sysfs_enable_slot ( struct slot * p_slot )
{
2008-09-05 07:11:26 +04:00
struct controller * ctrl = p_slot - > ctrl ;
2007-03-07 02:02:26 +03:00
mutex_lock ( & p_slot - > lock ) ;
switch ( p_slot - > state ) {
case BLINKINGON_STATE :
cancel_delayed_work ( & p_slot - > work ) ;
2018-07-20 01:27:45 +03:00
case OFF_STATE :
2007-03-07 02:02:26 +03:00
p_slot - > state = POWERON_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
2018-07-20 01:27:40 +03:00
return pciehp_enable_slot ( p_slot ) ;
2007-03-07 02:02:26 +03:00
case POWERON_STATE :
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already in powering on state \n " ,
2008-10-21 03:41:38 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
case BLINKINGOFF_STATE :
2018-07-20 01:27:45 +03:00
case ON_STATE :
2007-03-07 02:02:26 +03:00
case POWEROFF_STATE :
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already enabled \n " ,
2008-10-21 03:41:38 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
default :
2016-09-08 23:19:58 +03:00
ctrl_err ( ctrl , " Slot(%s): Invalid state %#x \n " ,
slot_name ( p_slot ) , p_slot - > state ) ;
2007-03-07 02:02:26 +03:00
break ;
}
mutex_unlock ( & p_slot - > lock ) ;
2018-07-20 01:27:40 +03:00
return - ENODEV ;
2007-03-07 02:02:26 +03:00
}
int pciehp_sysfs_disable_slot ( struct slot * p_slot )
{
2008-09-05 07:11:26 +04:00
struct controller * ctrl = p_slot - > ctrl ;
2007-03-07 02:02:26 +03:00
mutex_lock ( & p_slot - > lock ) ;
switch ( p_slot - > state ) {
case BLINKINGOFF_STATE :
cancel_delayed_work ( & p_slot - > work ) ;
2018-07-20 01:27:45 +03:00
case ON_STATE :
2007-03-07 02:02:26 +03:00
p_slot - > state = POWEROFF_STATE ;
mutex_unlock ( & p_slot - > lock ) ;
2018-07-20 01:27:40 +03:00
return pciehp_disable_slot ( p_slot ) ;
2007-03-07 02:02:26 +03:00
case POWEROFF_STATE :
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already in powering off state \n " ,
2008-10-21 03:41:38 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
case BLINKINGON_STATE :
2018-07-20 01:27:45 +03:00
case OFF_STATE :
2007-03-07 02:02:26 +03:00
case POWERON_STATE :
2016-09-08 23:19:58 +03:00
ctrl_info ( ctrl , " Slot(%s): Already disabled \n " ,
2008-10-21 03:41:38 +04:00
slot_name ( p_slot ) ) ;
2007-03-07 02:02:26 +03:00
break ;
default :
2016-09-08 23:19:58 +03:00
ctrl_err ( ctrl , " Slot(%s): Invalid state %#x \n " ,
slot_name ( p_slot ) , p_slot - > state ) ;
2007-03-07 02:02:26 +03:00
break ;
}
mutex_unlock ( & p_slot - > lock ) ;
2018-07-20 01:27:40 +03:00
return - ENODEV ;
2007-03-07 02:02:26 +03:00
}