5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
164 lines
4.1 KiB
C
164 lines
4.1 KiB
C
/*
|
|
* PlayStation 2 Trance Vibrator driver
|
|
*
|
|
* Copyright (C) 2006 Sam Hocevar <sam@zoy.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
/* Standard include files */
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/init.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/module.h>
|
|
#include <linux/usb.h>
|
|
|
|
/* Version Information */
|
|
#define DRIVER_VERSION "v1.1"
|
|
#define DRIVER_AUTHOR "Sam Hocevar, sam@zoy.org"
|
|
#define DRIVER_DESC "PlayStation 2 Trance Vibrator driver"
|
|
|
|
#define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */
|
|
#define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */
|
|
|
|
static const struct usb_device_id id_table[] = {
|
|
{ USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) },
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE (usb, id_table);
|
|
|
|
/* Driver-local specific stuff */
|
|
struct trancevibrator {
|
|
struct usb_device *udev;
|
|
unsigned int speed;
|
|
};
|
|
|
|
static ssize_t show_speed(struct device *dev, struct device_attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct usb_interface *intf = to_usb_interface(dev);
|
|
struct trancevibrator *tv = usb_get_intfdata(intf);
|
|
|
|
return sprintf(buf, "%d\n", tv->speed);
|
|
}
|
|
|
|
static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
|
|
const char *buf, size_t count)
|
|
{
|
|
struct usb_interface *intf = to_usb_interface(dev);
|
|
struct trancevibrator *tv = usb_get_intfdata(intf);
|
|
int temp, retval, old;
|
|
|
|
temp = simple_strtoul(buf, NULL, 10);
|
|
if (temp > 255)
|
|
temp = 255;
|
|
else if (temp < 0)
|
|
temp = 0;
|
|
old = tv->speed;
|
|
tv->speed = temp;
|
|
|
|
dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed);
|
|
|
|
/* Set speed */
|
|
retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0),
|
|
0x01, /* vendor request: set speed */
|
|
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
|
|
tv->speed, /* speed value */
|
|
0, NULL, 0, USB_CTRL_GET_TIMEOUT);
|
|
if (retval) {
|
|
tv->speed = old;
|
|
dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
|
|
return retval;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
static DEVICE_ATTR(speed, S_IWUGO | S_IRUGO, show_speed, set_speed);
|
|
|
|
static int tv_probe(struct usb_interface *interface,
|
|
const struct usb_device_id *id)
|
|
{
|
|
struct usb_device *udev = interface_to_usbdev(interface);
|
|
struct trancevibrator *dev;
|
|
int retval;
|
|
|
|
dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL);
|
|
if (dev == NULL) {
|
|
dev_err(&interface->dev, "Out of memory\n");
|
|
retval = -ENOMEM;
|
|
goto error;
|
|
}
|
|
|
|
dev->udev = usb_get_dev(udev);
|
|
usb_set_intfdata(interface, dev);
|
|
retval = device_create_file(&interface->dev, &dev_attr_speed);
|
|
if (retval)
|
|
goto error_create_file;
|
|
|
|
return 0;
|
|
|
|
error_create_file:
|
|
usb_put_dev(udev);
|
|
usb_set_intfdata(interface, NULL);
|
|
error:
|
|
kfree(dev);
|
|
return retval;
|
|
}
|
|
|
|
static void tv_disconnect(struct usb_interface *interface)
|
|
{
|
|
struct trancevibrator *dev;
|
|
|
|
dev = usb_get_intfdata (interface);
|
|
device_remove_file(&interface->dev, &dev_attr_speed);
|
|
usb_set_intfdata(interface, NULL);
|
|
usb_put_dev(dev->udev);
|
|
kfree(dev);
|
|
}
|
|
|
|
/* USB subsystem object */
|
|
static struct usb_driver tv_driver = {
|
|
.name = "trancevibrator",
|
|
.probe = tv_probe,
|
|
.disconnect = tv_disconnect,
|
|
.id_table = id_table,
|
|
};
|
|
|
|
static int __init tv_init(void)
|
|
{
|
|
int retval = usb_register(&tv_driver);
|
|
if (retval) {
|
|
err("usb_register failed. Error number %d", retval);
|
|
return retval;
|
|
}
|
|
|
|
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
|
|
DRIVER_DESC "\n");
|
|
return 0;
|
|
}
|
|
|
|
static void __exit tv_exit(void)
|
|
{
|
|
usb_deregister(&tv_driver);
|
|
}
|
|
|
|
module_init (tv_init);
|
|
module_exit (tv_exit);
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
MODULE_LICENSE("GPL");
|