From: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
To: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
Cc: "Brown, Len" <len.brown@intel.com>,
ACPI Developer <acpi-devel@lists.sourceforge.net>,
LHNS list <lhns-devel@lists.sourceforge.net>,
Linux IA64 <linux-ia64@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: PATCH-ACPI based CPU hotplug[0/6]-Core ACPI enhancement support
Date: Mon, 20 Sep 2004 09:29:47 -0700 [thread overview]
Message-ID: <20040920092947.B14208@unix-os.sc.intel.com> (raw)
In-Reply-To: <20040920092520.A14208@unix-os.sc.intel.com>; from anil.s.keshavamurthy@intel.com on Mon, Sep 20, 2004 at 09:25:20AM -0700
---
Name:acpi_core.patch
Status: Tested on 2.6.9-rc2
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Depends: None
Version: applies on 2.6.9-rc2
Description:
This patch provides core hotplug support in acpi by providing
acpi_bus_trim(), acpi_bus_remove() and acpi_pci_unbind()
which does exactly reverse of acpi_bus_scan(), acpi_bus_add()
and acpi_pci_bind().
---
linux-2.6.9-rc2-askeshav/drivers/acpi/acpi_ksyms.c | 3
linux-2.6.9-rc2-askeshav/drivers/acpi/bus.c | 4
linux-2.6.9-rc2-askeshav/drivers/acpi/pci_bind.c | 45 +++++++
linux-2.6.9-rc2-askeshav/drivers/acpi/pci_irq.c | 42 ++++++-
linux-2.6.9-rc2-askeshav/drivers/acpi/scan.c | 107 +++++++++++++++++--
linux-2.6.9-rc2-askeshav/include/acpi/acpi_bus.h | 9 +
linux-2.6.9-rc2-askeshav/include/acpi/acpi_drivers.h | 2
7 files changed, 194 insertions(+), 18 deletions(-)
diff -puN include/acpi/acpi_bus.h~acpi_core include/acpi/acpi_bus.h
--- linux-2.6.9-rc2/include/acpi/acpi_bus.h~acpi_core 2004-09-17 16:35:23.116378657 -0700
+++ linux-2.6.9-rc2-askeshav/include/acpi/acpi_bus.h 2004-09-17 16:35:23.233566156 -0700
@@ -104,6 +104,7 @@ typedef int (*acpi_op_suspend) (struct a
typedef int (*acpi_op_resume) (struct acpi_device *device, int state);
typedef int (*acpi_op_scan) (struct acpi_device *device);
typedef int (*acpi_op_bind) (struct acpi_device *device);
+typedef int (*acpi_op_unbind) (struct acpi_device *device);
struct acpi_device_ops {
acpi_op_add add;
@@ -115,6 +116,7 @@ struct acpi_device_ops {
acpi_op_resume resume;
acpi_op_scan scan;
acpi_op_bind bind;
+ acpi_op_unbind unbind;
};
struct acpi_driver {
@@ -313,7 +315,8 @@ extern struct subsystem acpi_subsys;
* External Functions
*/
-int acpi_bus_get_device(acpi_handle, struct acpi_device **device);
+int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
+void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context);
int acpi_bus_get_status (struct acpi_device *device);
int acpi_bus_get_power (acpi_handle handle, int *state);
int acpi_bus_set_power (acpi_handle handle, int state);
@@ -321,6 +324,10 @@ int acpi_bus_generate_event (struct acpi
int acpi_bus_receive_event (struct acpi_bus_event *event);
int acpi_bus_register_driver (struct acpi_driver *driver);
int acpi_bus_unregister_driver (struct acpi_driver *driver);
+int acpi_bus_scan (struct acpi_device *start);
+void acpi_bus_trim(struct acpi_device *start, int rmdevice);
+int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent, acpi_handle handle, int type);
+
int acpi_create_dir(struct acpi_device *);
void acpi_remove_dir(struct acpi_device *);
diff -puN drivers/acpi/acpi_ksyms.c~acpi_core drivers/acpi/acpi_ksyms.c
--- linux-2.6.9-rc2/drivers/acpi/acpi_ksyms.c~acpi_core 2004-09-17 16:35:23.123214595 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/acpi_ksyms.c 2004-09-17 16:35:23.233566156 -0700
@@ -135,6 +135,9 @@ EXPORT_SYMBOL(acpi_bus_generate_event);
EXPORT_SYMBOL(acpi_bus_receive_event);
EXPORT_SYMBOL(acpi_bus_register_driver);
EXPORT_SYMBOL(acpi_bus_unregister_driver);
+EXPORT_SYMBOL(acpi_bus_scan);
+EXPORT_SYMBOL(acpi_bus_trim);
+EXPORT_SYMBOL(acpi_bus_add);
#endif /*CONFIG_ACPI_BUS*/
diff -puN drivers/acpi/scan.c~acpi_core drivers/acpi/scan.c
--- linux-2.6.9-rc2/drivers/acpi/scan.c~acpi_core 2004-09-17 16:35:23.127120845 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/scan.c 2004-09-17 16:35:23.235519281 -0700
@@ -57,6 +57,7 @@ static void acpi_device_register(struct
INIT_LIST_HEAD(&device->children);
INIT_LIST_HEAD(&device->node);
INIT_LIST_HEAD(&device->g_list);
+ INIT_LIST_HEAD(&device->wakeup_list);
spin_lock(&acpi_device_lock);
if (device->parent) {
@@ -64,6 +65,8 @@ static void acpi_device_register(struct
list_add_tail(&device->g_list,&device->parent->g_list);
} else
list_add_tail(&device->g_list,&acpi_device_list);
+ if (device->wakeup.flags.valid)
+ list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list);
spin_unlock(&acpi_device_lock);
kobject_init(&device->kobj);
@@ -80,6 +83,18 @@ acpi_device_unregister (
struct acpi_device *device,
int type)
{
+ spin_lock(&acpi_device_lock);
+ if (device->parent) {
+ list_del(&device->node);
+ list_del(&device->g_list);
+ } else
+ list_del(&device->g_list);
+
+ list_del(&device->wakeup_list);
+
+ spin_unlock(&acpi_device_lock);
+
+ acpi_detach_data(device->handle, acpi_bus_data_handler);
kobject_unregister(&device->kobj);
return 0;
}
@@ -269,12 +284,6 @@ acpi_bus_get_wakeup_device_flags (
if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
device->wakeup.flags.run_wake = 1;
- /* TBD: lock */
- INIT_LIST_HEAD(&device->wakeup_list);
- spin_lock(&acpi_device_lock);
- list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
- spin_unlock(&acpi_device_lock);
-
end:
if (ACPI_FAILURE(status))
device->flags.wake_capable = 0;
@@ -315,7 +324,6 @@ acpi_bus_match (
return acpi_match_ids(device, driver->ids);
}
-
/**
* acpi_bus_driver_init
* --------------------
@@ -721,9 +729,10 @@ int acpi_device_set_context(struct acpi_
void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle, int type)
{
#ifdef CONFIG_ACPI_DEBUG_OUTPUT
+
char *type_string = NULL;
char name[80] = {'?','\0'};
- acpi_buffer buffer = {sizeof(name), name};
+ struct acpi_buffer buffer = {sizeof(name), name};
switch (type) {
case ACPI_BUS_TYPE_DEVICE:
@@ -760,7 +769,56 @@ void acpi_device_get_debug_info(struct a
#endif /*CONFIG_ACPI_DEBUG_OUTPUT*/
}
-static int
+
+int
+acpi_bus_remove (
+ struct acpi_device *dev,
+ int rmdevice)
+{
+ int result = 0;
+ struct acpi_driver *driver;
+
+ ACPI_FUNCTION_TRACE("acpi_bus_remove");
+
+ if (!dev)
+ return_VALUE(-EINVAL);
+
+ driver = dev->driver;
+
+ if ((driver) && (driver->ops.remove)) {
+
+ if (driver->ops.stop) {
+ result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
+ if (result)
+ return_VALUE(result);
+ }
+
+ result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
+ if (result) {
+ if (driver->ops.start)
+ driver->ops.start(dev);
+ return_VALUE(result);
+ }
+
+ atomic_dec(&dev->driver->references);
+ dev->driver = NULL;
+ acpi_driver_data(dev) = NULL;
+ }
+
+ if (!rmdevice)
+ return_VALUE(0);
+
+ if (dev->flags.bus_address) {
+ if ((dev->parent) && (dev->parent->ops.unbind))
+ dev->parent->ops.unbind(dev);
+ }
+
+ acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
+
+ return_VALUE(0);
+}
+
+int
acpi_bus_add (
struct acpi_device **child,
struct acpi_device *parent,
@@ -907,7 +965,7 @@ end:
-static int acpi_bus_scan (struct acpi_device *start)
+int acpi_bus_scan (struct acpi_device *start)
{
acpi_status status = AE_OK;
struct acpi_device *parent = NULL;
@@ -1009,6 +1067,35 @@ static int acpi_bus_scan (struct acpi_de
return_VALUE(0);
}
+void
+acpi_bus_trim(struct acpi_device *start,
+ int rmdevice)
+{
+ acpi_status status = AE_OK;
+ struct acpi_device *parent = NULL;
+ struct acpi_device *child = NULL;
+ acpi_handle phandle = 0;
+ acpi_handle chandle = 0;
+
+ parent = start;
+ phandle = start->handle;
+
+ /*
+ * NOTE: must be freed in a depth-first manner.
+ */
+ while (1) {
+ status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
+ chandle, &chandle);
+ if (ACPI_SUCCESS(status) && chandle != NULL) {
+ if (acpi_bus_get_device(chandle, &child) == 0)
+ acpi_bus_trim(child, 1);
+ } else {
+ /* this is a leaf */
+ acpi_bus_remove(parent, rmdevice);
+ break;
+ }
+ }
+}
static int
acpi_bus_scan_fixed (
diff -puN include/acpi/acpi_drivers.h~acpi_core include/acpi/acpi_drivers.h
--- linux-2.6.9-rc2/include/acpi/acpi_drivers.h~acpi_core 2004-09-17 16:35:23.132003657 -0700
+++ linux-2.6.9-rc2-askeshav/include/acpi/acpi_drivers.h 2004-09-17 16:35:23.236495844 -0700
@@ -61,12 +61,14 @@ int acpi_pci_link_get_irq (acpi_handle h
/* ACPI PCI Interrupt Routing (pci_irq.c) */
int acpi_pci_irq_add_prt (acpi_handle handle, int segment, int bus);
+void acpi_pci_irq_del_prt (int segment, int bus);
/* ACPI PCI Device Binding (pci_bind.c) */
struct pci_bus;
int acpi_pci_bind (struct acpi_device *device);
+int acpi_pci_unbind (struct acpi_device *device);
int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus);
/* Arch-defined function to add a bus to the system */
diff -puN drivers/acpi/pci_irq.c~acpi_core drivers/acpi/pci_irq.c
--- linux-2.6.9-rc2/drivers/acpi/pci_irq.c~acpi_core 2004-09-17 16:35:23.135909907 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/pci_irq.c 2004-09-17 16:35:23.237472406 -0700
@@ -43,7 +43,7 @@
ACPI_MODULE_NAME ("pci_irq")
struct acpi_prt_list acpi_prt;
-
+spinlock_t acpi_prt_lock = SPIN_LOCK_UNLOCKED;
/* --------------------------------------------------------------------------
PCI IRQ Routing Table (PRT) Support
@@ -68,18 +68,20 @@ acpi_pci_irq_find_prt_entry (
* Parse through all PRT entries looking for a match on the specified
* PCI device's segment, bus, device, and pin (don't care about func).
*
- * TBD: Acquire/release lock
*/
+ spin_lock(&acpi_prt_lock);
list_for_each(node, &acpi_prt.entries) {
entry = list_entry(node, struct acpi_prt_entry, node);
if ((segment == entry->id.segment)
&& (bus == entry->id.bus)
&& (device == entry->id.device)
&& (pin == entry->pin)) {
+ spin_unlock(&acpi_prt_lock);
return_PTR(entry);
}
}
+ spin_unlock(&acpi_prt_lock);
return_PTR(NULL);
}
@@ -141,14 +143,29 @@ acpi_pci_irq_add_entry (
entry->id.segment, entry->id.bus, entry->id.device,
('A' + entry->pin), prt->source, entry->link.index));
- /* TBD: Acquire/release lock */
+ spin_lock(&acpi_prt_lock);
list_add_tail(&entry->node, &acpi_prt.entries);
acpi_prt.count++;
+ spin_unlock(&acpi_prt_lock);
return_VALUE(0);
}
+static void
+acpi_pci_irq_del_entry (
+ int segment,
+ int bus,
+ struct acpi_prt_entry *entry)
+{
+ if (segment == entry->id.segment && bus == entry->id.bus){
+ acpi_prt.count--;
+ list_del(&entry->node);
+ kfree(entry);
+ }
+}
+
+
int
acpi_pci_irq_add_prt (
acpi_handle handle,
@@ -222,7 +239,26 @@ acpi_pci_irq_add_prt (
return_VALUE(0);
}
+void
+acpi_pci_irq_del_prt (int segment, int bus)
+{
+ struct list_head *node = NULL, *n = NULL;
+ struct acpi_prt_entry *entry = NULL;
+
+ if (!acpi_prt.count) {
+ return;
+ }
+ printk(KERN_DEBUG "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n",
+ segment, bus);
+ spin_lock(&acpi_prt_lock);
+ list_for_each_safe(node, n, &acpi_prt.entries) {
+ entry = list_entry(node, struct acpi_prt_entry, node);
+
+ acpi_pci_irq_del_entry(segment, bus, entry);
+ }
+ spin_unlock(&acpi_prt_lock);
+}
/* --------------------------------------------------------------------------
PCI Interrupt Routing Support
-------------------------------------------------------------------------- */
diff -puN drivers/acpi/pci_bind.c~acpi_core drivers/acpi/pci_bind.c
--- linux-2.6.9-rc2/drivers/acpi/pci_bind.c~acpi_core 2004-09-17 16:35:23.140792720 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/pci_bind.c 2004-09-17 16:35:23.238448968 -0700
@@ -214,6 +214,7 @@ acpi_pci_bind (
data->id.device, data->id.function));
data->bus = data->dev->subordinate;
device->ops.bind = acpi_pci_bind;
+ device->ops.unbind = acpi_pci_unbind;
}
/*
@@ -257,6 +258,49 @@ end:
return_VALUE(result);
}
+int acpi_pci_unbind(
+ struct acpi_device *device)
+{
+ int result = 0;
+ acpi_status status = AE_OK;
+ struct acpi_pci_data *data = NULL;
+ char pathname[ACPI_PATHNAME_MAX] = {0};
+ struct acpi_buffer buffer = {ACPI_PATHNAME_MAX, pathname};
+
+ ACPI_FUNCTION_TRACE("acpi_pci_unbind");
+
+ if (!device || !device->parent)
+ return_VALUE(-EINVAL);
+
+ acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
+ pathname));
+
+ status = acpi_get_data(device->handle, acpi_pci_data_handler, (void**)&data);
+ if (ACPI_FAILURE(status)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Unable to get data from device %s\n",
+ acpi_device_bid(device)));
+ result = -ENODEV;
+ goto end;
+ }
+
+ status = acpi_detach_data(device->handle, acpi_pci_data_handler);
+ if (ACPI_FAILURE(status)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Unable to detach data from device %s\n",
+ acpi_device_bid(device)));
+ result = -ENODEV;
+ goto end;
+ }
+ if (data->dev->subordinate) {
+ acpi_pci_irq_del_prt(data->id.segment, data->bus->number);
+ }
+ kfree(data);
+
+end:
+ return_VALUE(result);
+}
int
acpi_pci_bind_root (
@@ -283,6 +327,7 @@ acpi_pci_bind_root (
data->id = *id;
data->bus = bus;
device->ops.bind = acpi_pci_bind;
+ device->ops.unbind = acpi_pci_unbind;
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
diff -puN drivers/acpi/bus.c~acpi_core drivers/acpi/bus.c
--- linux-2.6.9-rc2/drivers/acpi/bus.c~acpi_core 2004-09-17 16:35:23.144698970 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/bus.c 2004-09-17 16:35:23.239425531 -0700
@@ -53,10 +53,6 @@ struct proc_dir_entry *acpi_root_dir;
Device Management
-------------------------------------------------------------------------- */
-extern void acpi_bus_data_handler (
- acpi_handle handle,
- u32 function,
- void *context);
int
acpi_bus_get_device (
acpi_handle handle,
_
next prev parent reply other threads:[~2004-09-20 16:32 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-20 16:25 PATCH-ACPI based CPU hotplug[0/6] Keshavamurthy Anil S
2004-09-20 16:29 ` Keshavamurthy Anil S [this message]
2004-09-20 16:34 ` PATCH-ACPI based CPU hotplug[1/6]-ACPI core enhancement support Keshavamurthy Anil S
[not found] ` <200409201326.44946.dtor_core@ameritech.net>
2004-09-20 19:01 ` [ACPI] " Keshavamurthy Anil S
2004-09-20 20:26 ` Bjorn Helgaas
2004-09-20 20:44 ` Keshavamurthy Anil S
2004-09-24 23:22 ` Keshavamurthy Anil S
2004-09-20 16:35 ` PATCH-ACPI based CPU hotplug[2/6]-ACPI Eject interface support Keshavamurthy Anil S
2004-09-20 18:33 ` [ACPI] " Dmitry Torokhov
2004-09-20 19:24 ` Keshavamurthy Anil S
2004-09-20 23:12 ` Dmitry Torokhov
2004-09-21 0:52 ` Alex Williamson
2004-09-21 1:20 ` Dmitry Torokhov
2004-09-21 1:25 ` Keshavamurthy Anil S
2004-09-21 1:41 ` Alex Williamson
2004-09-21 5:34 ` Dmitry Torokhov
2004-09-21 1:38 ` Keshavamurthy Anil S
2004-09-21 5:51 ` Dmitry Torokhov
2004-09-21 21:51 ` Keshavamurthy Anil S
2004-09-21 22:23 ` [Lhns-devel] " Russ Anderson
2004-09-22 3:10 ` Dmitry Torokhov
2004-09-24 23:28 ` Keshavamurthy Anil S
2004-09-27 6:12 ` Dmitry Torokhov
2004-09-27 16:53 ` Keshavamurthy Anil S
2004-09-27 18:09 ` Dmitry Torokhov
2004-09-22 4:17 ` Keiichiro Tokunaga
2004-09-22 16:59 ` Keshavamurthy Anil S
2004-09-20 16:38 ` PATCH-ACPI based CPU hotplug[3/6]-Mapping lsapic to cpu Keshavamurthy Anil S
2004-09-22 2:10 ` [ACPI] " Keiichiro Tokunaga
2004-09-23 6:55 ` Keshavamurthy Anil S
2004-09-22 13:15 ` Keiichiro Tokunaga
2004-09-22 13:23 ` Keiichiro Tokunaga
2004-09-22 14:52 ` Alex Williamson
2004-09-22 17:10 ` Keiichiro Tokunaga
2004-09-22 17:54 ` Keshavamurthy Anil S
2004-09-24 23:36 ` Keshavamurthy Anil S
2004-09-27 11:47 ` Keiichiro Tokunaga
2004-09-27 12:50 ` Keiichiro Tokunaga
2004-09-27 20:44 ` Keshavamurthy Anil S
2004-09-20 16:41 ` PATCH-ACPI based CPU hotplug[4/6]-Dynamic cpu register/unregister support Keshavamurthy Anil S
2004-09-22 8:34 ` [ACPI] " Keiichiro Tokunaga
2004-09-22 17:10 ` Keshavamurthy Anil S
2004-09-24 23:40 ` Keshavamurthy Anil S
2004-09-20 16:43 ` PATCH-ACPI based CPU hotplug[5/6]-ACPI processor driver extension Keshavamurthy Anil S
2004-09-22 9:57 ` [ACPI] " Keiichiro Tokunaga
2004-09-24 23:48 ` Keshavamurthy Anil S
2004-09-20 16:47 ` PATCH-ACPI based CPU hotplug[6/6]-ACPI Container driver Keshavamurthy Anil S
2004-09-23 16:23 ` [PATCH][0/4] NUMA node handling support for ACPI container driver Keiichiro Tokunaga
2004-09-23 16:31 ` [PATCH][1/4] Add unregister_node() to drivers/base/node.c Keiichiro Tokunaga
2004-09-23 16:43 ` [Lhns-devel] " Dave Hansen
2004-09-24 3:12 ` Keiichiro Tokunaga
2004-09-27 18:52 ` Keshavamurthy Anil S
2004-09-28 10:19 ` Keiichiro Tokunaga
2004-09-23 16:32 ` [PATCH][2/4] Add arch_register_node() for ia64 Keiichiro Tokunaga
2004-09-23 16:32 ` [PATCH][3/4] Add hotplug support to drivers/acpi/numa.c Keiichiro Tokunaga
2004-09-27 12:58 ` Keiichiro Tokunaga
2004-09-27 20:06 ` Keshavamurthy Anil S
2004-09-29 6:26 ` Keiichiro Tokunaga
2004-09-23 16:36 ` [PATCH][4/4] Add NUMA node handling to the container driver Keiichiro Tokunaga
2004-09-23 22:09 ` Mika Penttilä
2004-09-24 4:44 ` Keiichiro Tokunaga
2004-09-23 16:38 ` [PATCH][0/4] NUMA node handling support for ACPI " Keshavamurthy Anil S
2004-09-24 23:51 ` PATCH-ACPI based CPU hotplug[6/6]-ACPI Container driver Keshavamurthy Anil S
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040920092947.B14208@unix-os.sc.intel.com \
--to=anil.s.keshavamurthy@intel.com \
--cc=acpi-devel@lists.sourceforge.net \
--cc=len.brown@intel.com \
--cc=lhns-devel@lists.sourceforge.net \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox