* [PATCH 2/7] acpiphp - remove init_slots()
@ 2006-01-20 10:08 MUNEDA Takahiro
2006-01-20 10:25 ` [Pcihpd-discuss] " Rolf Eike Beer
0 siblings, 1 reply; 3+ messages in thread
From: MUNEDA Takahiro @ 2006-01-20 10:08 UTC (permalink / raw)
To: greg, pavel, kristen.c.accardi
Cc: pcihpd-discuss, linux-acpi, len.brown, muneda.takahiro
This patch removes get_slot_from_id(), because we don't need
to manage acpiphp_slot by id. Now, this function is useless.
This patch also removes init_slots() calling from acpiphp_init().
acpiphp registers hotplug slots when it has found them.
Signed-off-by: MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>
drivers/pci/hotplug/acpiphp.h | 2
drivers/pci/hotplug/acpiphp_core.c | 98 ++++++++++++++++---------------------
drivers/pci/hotplug/acpiphp_glue.c | 20 -------
3 files changed, 45 insertions(+), 75 deletions(-)
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp.h
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp.h
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp.h
@@ -201,12 +201,12 @@ struct acpiphp_attention_info
/* acpiphp_core.c */
extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
+extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot);
/* acpiphp_glue.c */
extern int acpiphp_glue_init (void);
extern void acpiphp_glue_exit (void);
extern int acpiphp_get_num_slots (void);
-extern struct acpiphp_slot *get_slot_from_id (int id);
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_core.c
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp_core.c
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_core.c
@@ -341,63 +341,55 @@ static void release_slot(struct hotplug_
kfree(slot);
}
-/**
- * init_slots - initialize 'struct slot' structures for each slot
- *
- */
-static int __init init_slots(void)
+/* callback routine to initialize 'struct slot' for each slot */
+int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
{
struct slot *slot;
int retval = -ENOMEM;
- int i;
- for (i = 0; i < num_slots; ++i) {
- slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
- if (!slot)
- goto error;
- memset(slot, 0, sizeof(struct slot));
-
- slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
- if (!slot->hotplug_slot)
- goto error_slot;
- memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
-
- slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
- if (!slot->hotplug_slot->info)
- goto error_hpslot;
- memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info));
-
- slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
- if (!slot->hotplug_slot->name)
- goto error_info;
-
- slot->number = i;
-
- slot->hotplug_slot->private = slot;
- slot->hotplug_slot->release = &release_slot;
- slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
-
- slot->acpi_slot = get_slot_from_id(i);
- slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
- slot->hotplug_slot->info->attention_status = 0;
- slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
- slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
- slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
- slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
-
- make_slot_name(slot);
-
- retval = pci_hp_register(slot->hotplug_slot);
- if (retval) {
- err("pci_hp_register failed with error %d\n", retval);
- goto error_name;
- }
-
- /* add slot to our internal list */
- list_add(&slot->slot_list, &slot_list);
- info("Slot [%s] registered\n", slot->hotplug_slot->name);
+ slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
+ if (!slot)
+ goto error;
+ memset(slot, 0, sizeof(struct slot));
+
+ slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+ if (!slot->hotplug_slot)
+ goto error_slot;
+ memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
+
+ slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ if (!slot->hotplug_slot->info)
+ goto error_hpslot;
+ memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info));
+
+ slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!slot->hotplug_slot->name)
+ goto error_info;
+
+ slot->hotplug_slot->private = slot;
+ slot->hotplug_slot->release = &release_slot;
+ slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
+
+ slot->acpi_slot = acpiphp_slot;
+ slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
+ slot->hotplug_slot->info->attention_status = 0;
+ slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
+ slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
+ slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
+ slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
+
+ make_slot_name(slot);
+
+ retval = pci_hp_register(slot->hotplug_slot);
+ if (retval) {
+ err("pci_hp_register failed with error %d\n", retval);
+ goto error_name;
}
+ /* add slot to our internal list */
+ list_add(&slot->slot_list, &slot_list);
+ info("Slot [%s] registered\n", slot->hotplug_slot->name);
+
return 0;
error_name:
kfree(slot->hotplug_slot->name);
@@ -436,10 +428,8 @@ static int __init acpiphp_init(void)
/* read all the ACPI info from the system */
retval = init_acpi();
- if (retval)
- return retval;
- return init_slots();
+ return retval;
}
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_glue.c
@@ -1373,26 +1373,6 @@ static int acpiphp_for_each_slot(acpiphp
}
#endif
-/* search matching slot from id */
-struct acpiphp_slot *get_slot_from_id(int id)
-{
- struct list_head *node;
- struct acpiphp_bridge *bridge;
- struct acpiphp_slot *slot;
-
- list_for_each (node, &bridge_list) {
- bridge = (struct acpiphp_bridge *)node;
- for (slot = bridge->slots; slot; slot = slot->next)
- if (slot->id == id)
- return slot;
- }
-
- /* should never happen! */
- err("%s: no object for id %d\n", __FUNCTION__, id);
- WARN_ON(1);
- return NULL;
-}
-
/**
* acpiphp_enable_slot - power on slot
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Pcihpd-discuss] [PATCH 2/7] acpiphp - remove init_slots()
2006-01-20 10:08 [PATCH 2/7] acpiphp - remove init_slots() MUNEDA Takahiro
@ 2006-01-20 10:25 ` Rolf Eike Beer
2006-01-20 11:25 ` MUNEDA Takahiro
0 siblings, 1 reply; 3+ messages in thread
From: Rolf Eike Beer @ 2006-01-20 10:25 UTC (permalink / raw)
To: pcihpd-discuss
Cc: MUNEDA Takahiro, greg, pavel, kristen.c.accardi, linux-acpi,
len.brown
[-- Attachment #1: Type: text/plain, Size: 222 bytes --]
MUNEDA Takahiro wrote:
>+ slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
>+ if (!slot)
>+ goto error;
>+ memset(slot, 0, sizeof(struct slot));
Use kzalloc() instead of kmalloc() and memset(). Use sizeof(*slot).
Eike
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Pcihpd-discuss] [PATCH 2/7] acpiphp - remove init_slots()
2006-01-20 10:25 ` [Pcihpd-discuss] " Rolf Eike Beer
@ 2006-01-20 11:25 ` MUNEDA Takahiro
0 siblings, 0 replies; 3+ messages in thread
From: MUNEDA Takahiro @ 2006-01-20 11:25 UTC (permalink / raw)
To: Rolf Eike Beer, greg, pavel, kristen.c.accardi
Cc: pcihpd-discuss, MUNEDA Takahiro, linux-acpi, len.brown
Hi,
At Fri, 20 Jan 2006 11:25:59 +0100,
Rolf Eike Beer <eike-hotplug@sf-tec.de> wrote:
>
> [1 <text/plain; iso-8859-1 (7bit)>]
> MUNEDA Takahiro wrote:
>
> >+ slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
> >+ if (!slot)
> >+ goto error;
> >+ memset(slot, 0, sizeof(struct slot));
>
> Use kzalloc() instead of kmalloc() and memset(). Use sizeof(*slot).
Thanks for your comments.
Here is an updated patch.
The patches 1,3,4,5,6,7 aren't changed.
Thanks,
MUNE
This patch removes get_slot_from_id(), because we don't need
to manage acpiphp_slot by id. Now, this function is useless.
This patch also removes init_slots() calling from acpiphp_init().
acpiphp registers hotplug slots when it has found them.
Signed-off-by: MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>
drivers/pci/hotplug/acpiphp.h | 2
drivers/pci/hotplug/acpiphp_core.c | 96 ++++++++++++++++---------------------
drivers/pci/hotplug/acpiphp_glue.c | 20 -------
3 files changed, 43 insertions(+), 75 deletions(-)
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp.h
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp.h
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp.h
@@ -201,12 +201,12 @@ struct acpiphp_attention_info
/* acpiphp_core.c */
extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
+extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot);
/* acpiphp_glue.c */
extern int acpiphp_glue_init (void);
extern void acpiphp_glue_exit (void);
extern int acpiphp_get_num_slots (void);
-extern struct acpiphp_slot *get_slot_from_id (int id);
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_core.c
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp_core.c
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_core.c
@@ -341,63 +341,53 @@ static void release_slot(struct hotplug_
kfree(slot);
}
-/**
- * init_slots - initialize 'struct slot' structures for each slot
- *
- */
-static int __init init_slots(void)
+/* callback routine to initialize 'struct slot' for each slot */
+int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
{
struct slot *slot;
int retval = -ENOMEM;
- int i;
- for (i = 0; i < num_slots; ++i) {
- slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
- if (!slot)
- goto error;
- memset(slot, 0, sizeof(struct slot));
-
- slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
- if (!slot->hotplug_slot)
- goto error_slot;
- memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
-
- slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
- if (!slot->hotplug_slot->info)
- goto error_hpslot;
- memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info));
-
- slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
- if (!slot->hotplug_slot->name)
- goto error_info;
-
- slot->number = i;
-
- slot->hotplug_slot->private = slot;
- slot->hotplug_slot->release = &release_slot;
- slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
-
- slot->acpi_slot = get_slot_from_id(i);
- slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
- slot->hotplug_slot->info->attention_status = 0;
- slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
- slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
- slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
- slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
-
- make_slot_name(slot);
-
- retval = pci_hp_register(slot->hotplug_slot);
- if (retval) {
- err("pci_hp_register failed with error %d\n", retval);
- goto error_name;
- }
-
- /* add slot to our internal list */
- list_add(&slot->slot_list, &slot_list);
- info("Slot [%s] registered\n", slot->hotplug_slot->name);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ if (!slot)
+ goto error;
+
+ slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
+ if (!slot->hotplug_slot)
+ goto error_slot;
+
+ slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info),
+ GFP_KERNEL);
+ if (!slot->hotplug_slot->info)
+ goto error_hpslot;
+
+ slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!slot->hotplug_slot->name)
+ goto error_info;
+
+ slot->hotplug_slot->private = slot;
+ slot->hotplug_slot->release = &release_slot;
+ slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
+
+ slot->acpi_slot = acpiphp_slot;
+ slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
+ slot->hotplug_slot->info->attention_status = 0;
+ slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
+ slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
+ slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
+ slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
+
+ make_slot_name(slot);
+
+ retval = pci_hp_register(slot->hotplug_slot);
+ if (retval) {
+ err("pci_hp_register failed with error %d\n", retval);
+ goto error_name;
}
+ /* add slot to our internal list */
+ list_add(&slot->slot_list, &slot_list);
+ info("Slot [%s] registered\n", slot->hotplug_slot->name);
+
return 0;
error_name:
kfree(slot->hotplug_slot->name);
@@ -436,10 +426,8 @@ static int __init acpiphp_init(void)
/* read all the ACPI info from the system */
retval = init_acpi();
- if (retval)
- return retval;
- return init_slots();
+ return retval;
}
Index: linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux-2.6.16-rc1.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux-2.6.16-rc1/drivers/pci/hotplug/acpiphp_glue.c
@@ -1373,26 +1373,6 @@ static int acpiphp_for_each_slot(acpiphp
}
#endif
-/* search matching slot from id */
-struct acpiphp_slot *get_slot_from_id(int id)
-{
- struct list_head *node;
- struct acpiphp_bridge *bridge;
- struct acpiphp_slot *slot;
-
- list_for_each (node, &bridge_list) {
- bridge = (struct acpiphp_bridge *)node;
- for (slot = bridge->slots; slot; slot = slot->next)
- if (slot->id == id)
- return slot;
- }
-
- /* should never happen! */
- err("%s: no object for id %d\n", __FUNCTION__, id);
- WARN_ON(1);
- return NULL;
-}
-
/**
* acpiphp_enable_slot - power on slot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-20 11:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-20 10:08 [PATCH 2/7] acpiphp - remove init_slots() MUNEDA Takahiro
2006-01-20 10:25 ` [Pcihpd-discuss] " Rolf Eike Beer
2006-01-20 11:25 ` MUNEDA Takahiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox