1 From: Shaohua Li <shaohua.li@intel.com>
2 Subject: libata hotplug to align with dock driver
3 Patch-mainline: submitted 2008-08-28
4 References: fate#304731,bnc#401740
6 dock driver can handle ata(bay) hotplug now. dock driver already handles
7 _EJ0 and _STA, so remove them. Also libata doesn't need register
8 notification handler anymore.
10 Signed-off-by: Shaohua Li <shaohua.li@intel.com>
11 Signed-off-by: Holger Macht <hmacht@suse.de>
14 diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
15 index 4b395b1..f19f643 100644
16 --- a/drivers/acpi/dock.c
17 +++ b/drivers/acpi/dock.c
18 @@ -738,7 +738,8 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
20 case ACPI_NOTIFY_EJECT_REQUEST:
22 - if (immediate_undock || surprise_removal)
23 + if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
24 + || surprise_removal)
25 handle_eject_request(ds, event);
27 dock_event(ds, event, UNDOCK_EVENT);
28 diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
29 index 9330b79..97727be 100644
30 --- a/drivers/ata/libata-acpi.c
31 +++ b/drivers/ata/libata-acpi.c
32 @@ -120,21 +120,6 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap)
33 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
36 -static void ata_acpi_eject_device(acpi_handle handle)
38 - struct acpi_object_list arg_list;
39 - union acpi_object arg;
42 - arg_list.pointer = &arg;
43 - arg.type = ACPI_TYPE_INTEGER;
44 - arg.integer.value = 1;
46 - if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0",
48 - printk(KERN_ERR "Failed to evaluate _EJ0!\n");
51 /* @ap and @dev are the same as ata_acpi_handle_hotplug() */
52 static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
54 @@ -157,7 +142,6 @@ static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
55 * @ap: ATA port ACPI event occurred
56 * @dev: ATA device ACPI event occurred (can be NULL)
57 * @event: ACPI event which occurred
58 - * @is_dock_event: boolean indicating whether the event was a dock one
60 * All ACPI bay / device realted events end up in this function. If
61 * the event is port-wide @dev is NULL. If the event is specific to a
62 @@ -171,115 +155,58 @@ static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
63 * ACPI notify handler context. May sleep.
65 static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
66 - u32 event, int is_dock_event)
69 - char event_string[12];
70 - char *envp[] = { event_string, NULL };
71 struct ata_eh_info *ehi = &ap->link.eh_info;
72 - struct kobject *kobj = NULL;
75 - acpi_handle handle, tmphandle;
76 - unsigned long long sta;
82 - kobj = &dev->sdev->sdev_gendev.kobj;
84 handle = dev->acpi_handle;
86 - kobj = &ap->dev->kobj;
88 handle = ap->acpi_handle;
91 - status = acpi_get_handle(handle, "_EJ0", &tmphandle);
92 - if (ACPI_FAILURE(status))
93 - /* This device does not support hotplug */
96 - if (event == ACPI_NOTIFY_BUS_CHECK ||
97 - event == ACPI_NOTIFY_DEVICE_CHECK)
98 - status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
100 spin_lock_irqsave(ap->lock, flags);
103 + * When dock driver calls into the routine, it will always use
104 + * ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
105 + * ACPI_NOTIFY_EJECT_REQUEST for remove
108 case ACPI_NOTIFY_BUS_CHECK:
109 case ACPI_NOTIFY_DEVICE_CHECK:
110 ata_ehi_push_desc(ehi, "ACPI event");
112 - if (ACPI_FAILURE(status)) {
113 - ata_port_printk(ap, KERN_ERR,
114 - "acpi: failed to determine bay status (0x%x)\n",
120 - ata_ehi_hotplugged(ehi);
121 - ata_port_freeze(ap);
123 - /* The device has gone - unplug it */
124 - ata_acpi_detach_device(ap, dev);
127 + ata_ehi_hotplugged(ehi);
128 + ata_port_freeze(ap);
130 case ACPI_NOTIFY_EJECT_REQUEST:
131 ata_ehi_push_desc(ehi, "ACPI event");
133 - if (!is_dock_event)
136 - /* undock event - immediate unplug */
137 ata_acpi_detach_device(ap, dev);
142 - /* make sure kobj doesn't go away while ap->lock is released */
145 spin_unlock_irqrestore(ap->lock, flags);
149 ata_port_wait_eh(ap);
150 - ata_acpi_eject_device(handle);
153 - if (kobj && !is_dock_event) {
154 - sprintf(event_string, "BAY_EVENT=%d", event);
155 - kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
161 static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
163 struct ata_device *dev = data;
165 - ata_acpi_handle_hotplug(dev->link->ap, dev, event, 1);
166 + ata_acpi_handle_hotplug(dev->link->ap, dev, event);
169 static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
171 struct ata_port *ap = data;
173 - ata_acpi_handle_hotplug(ap, NULL, event, 1);
176 -static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data)
178 - struct ata_device *dev = data;
180 - ata_acpi_handle_hotplug(dev->link->ap, dev, event, 0);
183 -static void ata_acpi_ap_notify(acpi_handle handle, u32 event, void *data)
185 - struct ata_port *ap = data;
187 - ata_acpi_handle_hotplug(ap, NULL, event, 0);
188 + ata_acpi_handle_hotplug(ap, NULL, event);
192 @@ -315,9 +242,6 @@ void ata_acpi_associate(struct ata_host *host)
193 ata_acpi_associate_ide_port(ap);
195 if (ap->acpi_handle) {
196 - acpi_install_notify_handler(ap->acpi_handle,
197 - ACPI_SYSTEM_NOTIFY,
198 - ata_acpi_ap_notify, ap);
199 /* we might be on a docking station */
200 register_hotplug_dock_device(ap->acpi_handle,
201 ata_acpi_ap_notify_dock, ap);
202 @@ -327,9 +251,6 @@ void ata_acpi_associate(struct ata_host *host)
203 struct ata_device *dev = &ap->link.device[j];
205 if (dev->acpi_handle) {
206 - acpi_install_notify_handler(dev->acpi_handle,
207 - ACPI_SYSTEM_NOTIFY,
208 - ata_acpi_dev_notify, dev);
209 /* we might be on a docking station */
210 register_hotplug_dock_device(dev->acpi_handle,
211 ata_acpi_dev_notify_dock, dev);