1 From: Shaohua Li <shaohua.li@intel.com>
2 Subject: remove useless code
3 Patch-mainline: submitted 2008-08-28
4 References: fate#304731,bnc#401740
6 Bay driver is replaced by dock driver, remove it.
8 Signed-off-by: Shaohua Li <shaohua.li@intel.com>
9 Signed-off-by: Holger Macht <hmacht@suse.de>
12 --- linux-2.6.26.orig/drivers/acpi/bay.c 2008-07-13 23:51:29.000000000 +0200
13 +++ linux-2.6.26/drivers/acpi/bay.c 1970-01-01 01:00:00.000000000 +0100
16 - * bay.c - ACPI removable drive bay driver
18 - * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com>
20 - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 - * This program is free software; you can redistribute it and/or modify
23 - * it under the terms of the GNU General Public License as published by
24 - * the Free Software Foundation; either version 2 of the License, or (at
25 - * your option) any later version.
27 - * This program is distributed in the hope that it will be useful, but
28 - * WITHOUT ANY WARRANTY; without even the implied warranty of
29 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 - * General Public License for more details.
32 - * You should have received a copy of the GNU General Public License along
33 - * with this program; if not, write to the Free Software Foundation, Inc.,
34 - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
36 - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 -#include <linux/kernel.h>
39 -#include <linux/module.h>
40 -#include <linux/init.h>
41 -#include <linux/types.h>
42 -#include <linux/notifier.h>
43 -#include <acpi/acpi_bus.h>
44 -#include <acpi/acpi_drivers.h>
45 -#include <linux/seq_file.h>
46 -#include <asm/uaccess.h>
47 -#include <linux/platform_device.h>
49 -ACPI_MODULE_NAME("bay");
50 -MODULE_AUTHOR("Kristen Carlson Accardi");
51 -MODULE_DESCRIPTION("ACPI Removable Drive Bay Driver");
52 -MODULE_LICENSE("GPL");
53 -#define ACPI_BAY_CLASS "bay"
54 -#define ACPI_BAY_COMPONENT 0x10000000
55 -#define _COMPONENT ACPI_BAY_COMPONENT
56 -#define bay_dprintk(h,s) {\
57 - char prefix[80] = {'\0'};\
58 - struct acpi_buffer buffer = {sizeof(prefix), prefix};\
59 - acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
60 - printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); }
61 -static void bay_notify(acpi_handle handle, u32 event, void *data);
63 -static const struct acpi_device_id bay_device_ids[] = {
67 -MODULE_DEVICE_TABLE(acpi, bay_device_ids);
72 - struct list_head list;
73 - struct platform_device *pdev;
76 -static LIST_HEAD(drive_bays);
79 -/*****************************************************************************
80 - * Drive Bay functions *
81 - *****************************************************************************/
83 - * is_ejectable - see if a device is ejectable
84 - * @handle: acpi handle of the device
86 - * If an acpi object has a _EJ0 method, then it is ejectable
88 -static int is_ejectable(acpi_handle handle)
93 - status = acpi_get_handle(handle, "_EJ0", &tmp);
94 - if (ACPI_FAILURE(status))
100 - * bay_present - see if the bay device is present
101 - * @bay: the drive bay
103 - * execute the _STA method.
105 -static int bay_present(struct bay *bay)
107 - unsigned long long sta;
108 - acpi_status status;
111 - status = acpi_evaluate_integer(bay->handle, "_STA", NULL, &sta);
112 - if (ACPI_SUCCESS(status) && sta)
119 - * eject_device - respond to an eject request
120 - * @handle - the device to eject
122 - * Call this devices _EJ0 method.
124 -static void eject_device(acpi_handle handle)
126 - struct acpi_object_list arg_list;
127 - union acpi_object arg;
129 - bay_dprintk(handle, "Ejecting device");
131 - arg_list.count = 1;
132 - arg_list.pointer = &arg;
133 - arg.type = ACPI_TYPE_INTEGER;
134 - arg.integer.value = 1;
136 - if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0",
138 - pr_debug("Failed to evaluate _EJ0!\n");
142 - * show_present - read method for "present" file in sysfs
144 -static ssize_t show_present(struct device *dev,
145 - struct device_attribute *attr, char *buf)
147 - struct bay *bay = dev_get_drvdata(dev);
148 - return snprintf(buf, PAGE_SIZE, "%d\n", bay_present(bay));
151 -static DEVICE_ATTR(present, S_IRUGO, show_present, NULL);
154 - * write_eject - write method for "eject" file in sysfs
156 -static ssize_t write_eject(struct device *dev, struct device_attribute *attr,
157 - const char *buf, size_t count)
159 - struct bay *bay = dev_get_drvdata(dev);
164 - eject_device(bay->handle);
167 -static DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject);
170 - * is_ata - see if a device is an ata device
171 - * @handle: acpi handle of the device
173 - * If an acpi object has one of 4 ATA ACPI methods defined,
174 - * then it is an ATA device
176 -static int is_ata(acpi_handle handle)
180 - if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) ||
181 - (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) ||
182 - (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) ||
183 - (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp))))
190 - * parent_is_ata(acpi_handle handle)
193 -static int parent_is_ata(acpi_handle handle)
195 - acpi_handle phandle;
197 - if (acpi_get_parent(handle, &phandle))
200 - return is_ata(phandle);
204 - * is_ejectable_bay - see if a device is an ejectable drive bay
205 - * @handle: acpi handle of the device
207 - * If an acpi object is ejectable and has one of the ACPI ATA
208 - * methods defined, then we can safely call it an ejectable
211 -static int is_ejectable_bay(acpi_handle handle)
213 - if ((is_ata(handle) || parent_is_ata(handle)) && is_ejectable(handle))
220 - * eject_removable_drive - try to eject this drive
221 - * @dev : the device structure of the drive
223 - * If a device is a removable drive that requires an _EJ0 method
224 - * to be executed in order to safely remove from the system, do
225 - * it. ATM - always returns success
227 -int eject_removable_drive(struct device *dev)
229 - acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
232 - bay_dprintk(handle, "Got device handle");
233 - if (is_ejectable_bay(handle))
234 - eject_device(handle);
236 - printk("No acpi handle for device\n");
239 - /* should I return an error code? */
242 -EXPORT_SYMBOL_GPL(eject_removable_drive);
245 -static int acpi_bay_add_fs(struct bay *bay)
248 - struct device *dev = &bay->pdev->dev;
250 - ret = device_create_file(dev, &dev_attr_present);
253 - ret = device_create_file(dev, &dev_attr_eject);
255 - device_remove_file(dev, &dev_attr_present);
261 - bay_dprintk(bay->handle, "Error adding sysfs files\n");
265 -static void acpi_bay_remove_fs(struct bay *bay)
267 - struct device *dev = &bay->pdev->dev;
269 - /* cleanup sysfs */
270 - device_remove_file(dev, &dev_attr_present);
271 - device_remove_file(dev, &dev_attr_eject);
274 -static int bay_is_dock_device(acpi_handle handle)
276 - acpi_handle parent;
278 - acpi_get_parent(handle, &parent);
280 - /* if the device or it's parent is dependent on the
281 - * dock, then we are a dock device
283 - return (is_dock_device(handle) || is_dock_device(parent));
286 -static int bay_add(acpi_handle handle, int id)
288 - acpi_status status;
289 - struct bay *new_bay;
290 - struct platform_device *pdev;
291 - struct acpi_buffer nbuffer = {ACPI_ALLOCATE_BUFFER, NULL};
292 - acpi_get_name(handle, ACPI_FULL_PATHNAME, &nbuffer);
294 - bay_dprintk(handle, "Adding notify handler");
297 - * Initialize bay device structure
299 - new_bay = kzalloc(sizeof(*new_bay), GFP_ATOMIC);
300 - INIT_LIST_HEAD(&new_bay->list);
301 - new_bay->handle = handle;
302 - new_bay->name = (char *)nbuffer.pointer;
304 - /* initialize platform device stuff */
305 - pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0);
306 - if (IS_ERR(pdev)) {
307 - printk(KERN_ERR PREFIX "Error registering bay device\n");
310 - new_bay->pdev = pdev;
311 - platform_set_drvdata(pdev, new_bay);
314 - * we want the bay driver to be able to send uevents
316 - pdev->dev.uevent_suppress = 0;
318 - /* register for events on this device */
319 - status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
320 - bay_notify, new_bay);
321 - if (ACPI_FAILURE(status)) {
322 - printk(KERN_INFO PREFIX "Error installing bay notify handler\n");
323 - platform_device_unregister(new_bay->pdev);
327 - if (acpi_bay_add_fs(new_bay)) {
328 - acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
330 - platform_device_unregister(new_bay->pdev);
334 - /* if we are on a dock station, we should register for dock
337 - if (bay_is_dock_device(handle)) {
338 - bay_dprintk(handle, "Is dependent on dock\n");
339 - register_hotplug_dock_device(handle, bay_notify, new_bay);
341 - list_add(&new_bay->list, &drive_bays);
342 - printk(KERN_INFO PREFIX "Bay [%s] Added\n", new_bay->name);
346 - kfree(new_bay->name);
352 - * bay_notify - act upon an acpi bay notification
353 - * @handle: the bay handle
354 - * @event: the acpi event
355 - * @data: our driver data struct
358 -static void bay_notify(acpi_handle handle, u32 event, void *data)
360 - struct bay *bay_dev = (struct bay *)data;
361 - struct device *dev = &bay_dev->pdev->dev;
362 - char event_string[12];
363 - char *envp[] = { event_string, NULL };
365 - bay_dprintk(handle, "Bay event");
366 - sprintf(event_string, "BAY_EVENT=%d", event);
367 - kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
371 -find_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
373 - int *count = (int *)context;
376 - * there could be more than one ejectable bay.
377 - * so, just return AE_OK always so that every object
380 - if (is_ejectable_bay(handle)) {
381 - bay_dprintk(handle, "found ejectable bay");
382 - if (!bay_add(handle, *count))
388 -static int __init bay_init(void)
392 - INIT_LIST_HEAD(&drive_bays);
397 - /* look for dockable drive bays */
398 - acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
399 - ACPI_UINT32_MAX, find_bay, &bays, NULL);
407 -static void __exit bay_exit(void)
409 - struct bay *bay, *tmp;
411 - list_for_each_entry_safe(bay, tmp, &drive_bays, list) {
412 - if (is_dock_device(bay->handle))
413 - unregister_hotplug_dock_device(bay->handle);
414 - acpi_bay_remove_fs(bay);
415 - acpi_remove_notify_handler(bay->handle, ACPI_SYSTEM_NOTIFY,
417 - platform_device_unregister(bay->pdev);
423 -postcore_initcall(bay_init);
424 -module_exit(bay_exit);