diff options
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_core.c')
| -rw-r--r-- | drivers/pci/hotplug/acpiphp_core.c | 123 | 
1 files changed, 40 insertions, 83 deletions
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index efa9f2de51c..e291efcd02a 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c @@ -31,27 +31,26 @@   *   */ +#define pr_fmt(fmt) "acpiphp: " fmt +  #include <linux/init.h>  #include <linux/module.h>  #include <linux/moduleparam.h>  #include <linux/kernel.h>  #include <linux/pci.h> +#include <linux/pci-acpi.h>  #include <linux/pci_hotplug.h>  #include <linux/slab.h>  #include <linux/smp.h>  #include "acpiphp.h" -#define MY_NAME	"acpiphp" -  /* name size which is used for entries in pcihpfs */  #define SLOT_NAME_SIZE  21              /* {_SUN} */ -static int debug; -int acpiphp_debug; +bool acpiphp_disabled;  /* local variables */ -static int num_slots;  static struct acpiphp_attention_info *attention_info;  #define DRIVER_VERSION	"0.5" @@ -61,12 +60,8 @@ static struct acpiphp_attention_info *attention_info;  MODULE_AUTHOR(DRIVER_AUTHOR);  MODULE_DESCRIPTION(DRIVER_DESC);  MODULE_LICENSE("GPL"); -MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); -module_param(debug, bool, 0644); - -/* export the attention callback registration methods */ -EXPORT_SYMBOL_GPL(acpiphp_register_attention); -EXPORT_SYMBOL_GPL(acpiphp_unregister_attention); +MODULE_PARM_DESC(disable, "disable acpiphp driver"); +module_param_named(disable, acpiphp_disabled, bool, 0444);  static int enable_slot		(struct hotplug_slot *slot);  static int disable_slot		(struct hotplug_slot *slot); @@ -105,6 +100,7 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info)  	}  	return retval;  } +EXPORT_SYMBOL_GPL(acpiphp_register_attention);  /** @@ -112,7 +108,7 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info)   * @info: must match the pointer used to register   *   * Description: This is used to un-register a hardware specific acpi - * driver that manipulates the attention LED.  The pointer to the  + * driver that manipulates the attention LED.  The pointer to the   * info struct must be the same as the one used to set it.   */  int acpiphp_unregister_attention(struct acpiphp_attention_info *info) @@ -125,6 +121,7 @@ int acpiphp_unregister_attention(struct acpiphp_attention_info *info)  	}  	return retval;  } +EXPORT_SYMBOL_GPL(acpiphp_unregister_attention);  /** @@ -137,7 +134,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)  {  	struct slot *slot = hotplug_slot->private; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	/* enable the specified slot */  	return acpiphp_enable_slot(slot->acpi_slot); @@ -153,15 +150,11 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)  static int disable_slot(struct hotplug_slot *hotplug_slot)  {  	struct slot *slot = hotplug_slot->private; -	int retval; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	/* disable the specified slot */ -	retval = acpiphp_disable_slot(slot->acpi_slot); -	if (!retval) -		retval = acpiphp_eject_slot(slot->acpi_slot); -	return retval; +	return acpiphp_disable_slot(slot->acpi_slot);  } @@ -174,20 +167,21 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)   * was registered with us.  This allows hardware specific   * ACPI implementations to blink the light for us.   */ - static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) - { +static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) +{  	int retval = -ENODEV; -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); -  +	pr_debug("%s - physical_slot = %s\n", __func__, +		hotplug_slot_name(hotplug_slot)); +  	if (attention_info && try_module_get(attention_info->owner)) {  		retval = attention_info->set_attn(hotplug_slot, status);  		module_put(attention_info->owner);  	} else  		attention_info = NULL;  	return retval; - } -  +} +  /**   * get_power_status - get power status of a slot @@ -201,7 +195,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)  {  	struct slot *slot = hotplug_slot->private; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	*value = acpiphp_get_power_status(slot->acpi_slot); @@ -223,7 +217,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)  {  	int retval = -EINVAL; -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, +		hotplug_slot_name(hotplug_slot));  	if (attention_info && try_module_get(attention_info->owner)) {  		retval = attention_info->get_attn(hotplug_slot, value); @@ -246,7 +241,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)  {  	struct slot *slot = hotplug_slot->private; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	*value = acpiphp_get_latch_status(slot->acpi_slot); @@ -266,32 +261,13 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)  {  	struct slot *slot = hotplug_slot->private; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	*value = acpiphp_get_adapter_status(slot->acpi_slot);  	return 0;  } -static int __init init_acpi(void) -{ -	int retval; - -	/* initialize internal data structure etc. */ -	retval = acpiphp_glue_init(); - -	/* read initial number of slots */ -	if (!retval) { -		num_slots = acpiphp_get_num_slots(); -		if (num_slots == 0) { -			acpiphp_glue_exit(); -			retval = -ENODEV; -		} -	} - -	return retval; -} -  /**   * release_slot - free up the memory used by a slot   * @hotplug_slot: slot to free @@ -300,14 +276,15 @@ static void release_slot(struct hotplug_slot *hotplug_slot)  {  	struct slot *slot = hotplug_slot->private; -	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); +	pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));  	kfree(slot->hotplug_slot);  	kfree(slot);  }  /* callback routine to initialize 'struct slot' for each slot */ -int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) +int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot, +				  unsigned int sun)  {  	struct slot *slot;  	int retval = -ENOMEM; @@ -334,20 +311,19 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)  	slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);  	acpiphp_slot->slot = slot; -	snprintf(name, SLOT_NAME_SIZE, "%llu", slot->acpi_slot->sun); +	slot->sun = sun; +	snprintf(name, SLOT_NAME_SIZE, "%u", sun); -	retval = pci_hp_register(slot->hotplug_slot, -					acpiphp_slot->bridge->pci_bus, -					acpiphp_slot->device, -					name); +	retval = pci_hp_register(slot->hotplug_slot, acpiphp_slot->bus, +				 acpiphp_slot->device, name);  	if (retval == -EBUSY)  		goto error_hpslot;  	if (retval) { -		err("pci_hp_register failed with error %d\n", retval); +		pr_err("pci_hp_register failed with error %d\n", retval);  		goto error_hpslot; - 	} +	} -	info("Slot [%s] registered\n", slot_name(slot)); +	pr_info("Slot [%s] registered\n", slot_name(slot));  	return 0;  error_hpslot: @@ -364,36 +340,17 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)  	struct slot *slot = acpiphp_slot->slot;  	int retval = 0; -	info("Slot [%s] unregistered\n", slot_name(slot)); +	pr_info("Slot [%s] unregistered\n", slot_name(slot));  	retval = pci_hp_deregister(slot->hotplug_slot);  	if (retval) -		err("pci_hp_deregister failed with error %d\n", retval); -} - - -static int __init acpiphp_init(void) -{ -	info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); - -	if (acpi_pci_disabled) -		return 0; - -	acpiphp_debug = debug; - -	/* read all the ACPI info from the system */ -	return init_acpi(); +		pr_err("pci_hp_deregister failed with error %d\n", retval);  } -static void __exit acpiphp_exit(void) +void __init acpiphp_init(void)  { -	if (acpi_pci_disabled) -		return; - -	/* deallocate internal data structures etc. */ -	acpiphp_glue_exit(); +	pr_info(DRIVER_DESC " version: " DRIVER_VERSION "%s\n", +		acpiphp_disabled ? ", disabled by user; please report a bug" +				 : "");  } - -module_init(acpiphp_init); -module_exit(acpiphp_exit);  | 
