From e2009eeeb6bc9ff58e35cfddc49b8019cca8ad58 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 14 Dec 2004 18:48:19 -0800 Subject: [PATCH] add class_device to miscdevice Currently misc_register() throws away the return from class_simple_device_add(). This makes it impossible to get to the class_device of the directories in /sys/class/misc and, for example, thus impossible to add attributes to those directories. Attached patch adds a class_device structure to the miscdevice structure and assigns to it the value returned from class_simple_device_add() in misc_register(), thus caching the value and allowing us to f.e. later call class_device_create_file(). We need this for inotify, but I can see plenty of other misc. devices wanting this and consider it missing but required functionality. Add the class_device structure to miscdevice so that we can add sysfs attributes to /sys/class/misc/foo Signed-Off-By: Robert Love Signed-off-by: Greg Kroah-Hartman --- include/linux/miscdevice.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 209f6ffbd588..56fe7347f921 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -2,6 +2,7 @@ #define _LINUX_MISCDEVICE_H #include #include +#include #define PSMOUSE_MINOR 1 #define MS_BUSMOUSE_MINOR 2 @@ -32,13 +33,13 @@ struct device; -struct miscdevice -{ +struct miscdevice { int minor; const char *name; struct file_operations *fops; struct list_head list; struct device *dev; + struct class_device *class; char devfs_name[64]; }; -- cgit v1.2.3 From 2957bf8bfeedfdf42052ab131baf1422dd0ac024 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 14 Dec 2004 18:49:05 -0800 Subject: [PATCH] misc: remove device.h #include from miscdevice.h Signed-off-by: Greg Kroah-Hartman --- include/linux/miscdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 56fe7347f921..14ceebfc1efa 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -2,7 +2,6 @@ #define _LINUX_MISCDEVICE_H #include #include -#include #define PSMOUSE_MINOR 1 #define MS_BUSMOUSE_MINOR 2 @@ -32,6 +31,7 @@ #define HPET_MINOR 228 struct device; +struct class_device; struct miscdevice { int minor; -- cgit v1.2.3 From f55af026106141633c3e17e99a1303f9083d91cc Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 15 Dec 2004 00:31:49 -0800 Subject: [PATCH] USB: usb_dev->ep[] not usb_dev->epmaxpacket (1/15) This starts updating the usbcore interface to use endpoints in places it previously used pipes or other representations of the endpoint. - add new arrays of "struct usb_host_endpoint" pointers, matching current config and altsetting - get rid of the two epmaxpacket[] arrays; they duplicate information that's now readily accessible from the usb_host_endpoint. - resolve a FIXME by removing a function that only existed because the usb_host_endpoint wasn't readily accessible. It also removes most of an old rant about pipes, trimming it down so only the important bits remain. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- include/linux/usb.h | 73 +++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'include') diff --git a/include/linux/usb.h b/include/linux/usb.h index 18ee0751a32b..d2498cba7104 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -224,11 +224,6 @@ struct usb_host_config { int extralen; }; -// FIXME remove; exported only for drivers/usb/misc/auserwald.c -// prefer usb_device->epnum[0..31] -extern struct usb_endpoint_descriptor * - usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum); - int __usb_get_extra_descriptor(char *buffer, unsigned size, unsigned char type, void **ptr); #define usb_get_extra_descriptor(ifpoint,type,ptr)\ @@ -311,17 +306,19 @@ struct usb_device { struct semaphore serialize; unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ - int epmaxpacketin[16]; /* INput endpoint specific maximums */ - int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ struct usb_device *parent; /* our hub, unless we're the root */ struct usb_bus *bus; /* Bus we're part of */ + struct usb_host_endpoint ep0; struct device dev; /* Generic device interface */ struct usb_device_descriptor descriptor;/* Descriptor */ struct usb_host_config *config; /* All of the configs */ + struct usb_host_config *actconfig;/* the active configuration */ + struct usb_host_endpoint *ep_in[16]; + struct usb_host_endpoint *ep_out[16]; char **rawdescriptors; /* Raw descriptors for each config */ @@ -360,6 +357,8 @@ extern int usb_reset_device(struct usb_device *dev); extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); +/*-------------------------------------------------------------------------*/ + /* for drivers using iso endpoints */ extern int usb_get_current_frame_number (struct usb_device *usb_dev); @@ -1040,55 +1039,35 @@ void usb_sg_wait (struct usb_sg_request *io); /* -------------------------------------------------------------------------- */ /* - * Calling this entity a "pipe" is glorifying it. A USB pipe - * is something embarrassingly simple: it basically consists - * of the following information: - * - device number (7 bits) - * - endpoint number (4 bits) - * - current Data0/1 state (1 bit) [Historical; now gone] - * - direction (1 bit) - * - speed (1 bit) [Historical and specific to USB 1.1; now gone.] - * - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.] - * - pipe type (2 bits: control, interrupt, bulk, isochronous) + * For various legacy reasons, Linux has a small cookie that's paired with + * a struct usb_device to identify an endpoint queue. Queue characteristics + * are defined by the endpoint's descriptor. This cookie is called a "pipe", + * an unsigned int encoded as: * - * That's 18 bits. Really. Nothing more. And the USB people have - * documented these eighteen bits as some kind of glorious - * virtual data structure. - * - * Let's not fall in that trap. We'll just encode it as a simple - * unsigned int. The encoding is: - * - * - max size: bits 0-1 [Historical; now gone.] * - direction: bit 7 (0 = Host-to-Device [Out], * 1 = Device-to-Host [In] ... * like endpoint bEndpointAddress) - * - device: bits 8-14 ... bit positions known to uhci-hcd + * - device address: bits 8-14 ... bit positions known to uhci-hcd * - endpoint: bits 15-18 ... bit positions known to uhci-hcd - * - Data0/1: bit 19 [Historical; now gone. ] - * - lowspeed: bit 26 [Historical; now gone. ] * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, * 10 = control, 11 = bulk) * - * Why? Because it's arbitrary, and whatever encoding we select is really - * up to us. This one happens to share a lot of bit positions with the UHCI - * specification, so that much of the uhci driver can just mask the bits - * appropriately. + * Given the device address and endpoint descriptor, pipes are redundant. */ /* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */ +/* (yet ... they're the values used by usbfs) */ #define PIPE_ISOCHRONOUS 0 #define PIPE_INTERRUPT 1 #define PIPE_CONTROL 2 #define PIPE_BULK 3 -#define usb_maxpacket(dev, pipe, out) (out \ - ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \ - : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] ) - #define usb_pipein(pipe) ((pipe) & USB_DIR_IN) #define usb_pipeout(pipe) (!usb_pipein(pipe)) + #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) + #define usb_pipetype(pipe) (((pipe) >> 30) & 3) #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) #define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) @@ -1116,6 +1095,28 @@ static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int en #define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) #define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) +/*-------------------------------------------------------------------------*/ + +static inline __u16 +usb_maxpacket(struct usb_device *udev, int pipe, int is_out) +{ + struct usb_host_endpoint *ep; + unsigned epnum = usb_pipeendpoint(pipe); + + if (is_out) { + WARN_ON(usb_pipein(pipe)); + ep = udev->ep_out[epnum]; + } else { + WARN_ON(usb_pipeout(pipe)); + ep = udev->ep_in[epnum]; + } + if (!ep) + return 0; + + /* NOTE: only 0x07ff bits are for packet size... */ + return ep->desc.wMaxPacketSize; +} + /* -------------------------------------------------------------------------- */ #ifdef DEBUG -- cgit v1.2.3 From ee3de3ecb8621fb9660b78d10a3ccbc2e624f7a8 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 15 Dec 2004 00:35:03 -0800 Subject: [PATCH] USB: HCD/usb_bus interface cleanup (9/15) This changes the usbcore interfaces provided to HCDs: - Remove usb_device->hcpriv and it allocation/deallocation hooks - Replace struct hcd_dev with more appropriate per-endpoint state - Update HCD apis to use usb_host_endpoint in key places Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.h | 20 ++++++-------------- include/linux/usb.h | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 12a2b9f80321..978e06dc5795 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -66,7 +66,6 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */ const char *description; /* "ehci-hcd" etc */ struct timer_list rh_timer; /* drives root hub */ - struct list_head dev_list; /* devices on this bus */ /* * hardware info/state @@ -113,14 +112,6 @@ static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd) } -struct hcd_dev { /* usb_device.hcpriv points to this */ - struct list_head dev_list; /* on this hcd */ - struct list_head urb_list; /* pending on this dev */ - - /* per-configuration HC/HCD state, such as QH or ED */ - void *ep[32]; -}; - // urb.hcpriv is really hardware-specific struct hcd_timeout { /* timeouts we allocate */ @@ -136,8 +127,6 @@ struct hcd_timeout { /* timeouts we allocate */ */ struct usb_operations { - int (*allocate)(struct usb_device *); - int (*deallocate)(struct usb_device *); int (*get_frame_number) (struct usb_device *usb_dev); int (*submit_urb) (struct urb *urb, int mem_flags); int (*unlink_urb) (struct urb *urb, int status); @@ -149,7 +138,8 @@ struct usb_operations { void (*buffer_free)(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); - void (*disable)(struct usb_device *udev, int bEndpointAddress); + void (*disable)(struct usb_device *udev, + struct usb_host_endpoint *ep); /* global suspend/resume of bus */ int (*hub_suspend)(struct usb_bus *); @@ -200,13 +190,15 @@ struct hc_driver { struct usb_hcd *(*hcd_alloc) (void); /* manage i/o requests, device state */ - int (*urb_enqueue) (struct usb_hcd *hcd, struct urb *urb, + int (*urb_enqueue) (struct usb_hcd *hcd, + struct usb_host_endpoint *ep, + struct urb *urb, int mem_flags); int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); /* hw synch, freeing endpoint resources that urb_dequeue can't */ void (*endpoint_disable)(struct usb_hcd *hcd, - struct hcd_dev *dev, int bEndpointAddress); + struct usb_host_endpoint *ep); /* root hub support */ int (*hub_status_data) (struct usb_hcd *hcd, char *buf); diff --git a/include/linux/usb.h b/include/linux/usb.h index d2498cba7104..dd698c12b7ce 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -40,9 +40,22 @@ struct usb_driver; * Devices may also have class-specific or vendor-specific descriptors. */ -/* host-side wrapper for parsed endpoint descriptors */ +/** + * struct usb_host_endpoint - host-side endpoint descriptor and queue + * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder + * @urb_list: urbs queued to this endpoint; maintained by usbcore + * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH) + * with one or more transfer descriptors (TDs) per urb + * @extra: descriptors following this endpoint in the configuration + * @extralen: how many bytes of "extra" are valid + * + * USB requests are always queued to a given endpoint, identified by a + * descriptor within an active interface in a given USB configuration. + */ struct usb_host_endpoint { struct usb_endpoint_descriptor desc; + struct list_head urb_list; + void *hcpriv; unsigned char *extra; /* Extra descriptors */ int extralen; @@ -325,8 +338,6 @@ struct usb_device { int have_langid; /* whether string_langid is valid yet */ int string_langid; /* language ID for strings */ - void *hcpriv; /* Host Controller private data */ - struct list_head filelist; struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ -- cgit v1.2.3 From b5592e8dfa83f45df7c0d1ac81c55b4f6bbadad2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 15 Dec 2004 21:16:18 -0800 Subject: debugfs: add debugfs debugfs is a filesystem that is just for debug data. Start moving stuff out of proc and sysfs now :) Signed-off-by: Greg Kroah-Hartman --- Documentation/DocBook/kernel-api.tmpl | 9 + fs/Makefile | 1 + fs/debugfs/Makefile | 4 + fs/debugfs/file.c | 262 ++++++++++++++++++++++++++++ fs/debugfs/inode.c | 315 ++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 90 ++++++++++ lib/Kconfig.debug | 10 ++ 7 files changed, 691 insertions(+) create mode 100644 fs/debugfs/Makefile create mode 100644 fs/debugfs/file.c create mode 100644 fs/debugfs/inode.c create mode 100644 include/linux/debugfs.h (limited to 'include') diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl index ef66fdda129f..97a30ce957ad 100644 --- a/Documentation/DocBook/kernel-api.tmpl +++ b/Documentation/DocBook/kernel-api.tmpl @@ -105,6 +105,15 @@ KAO --> + + The debugfs filesystem + + debugfs interface +!Efs/debugfs/inode.c +!Efs/debugfs/file.c + + + The Linux VFS The Directory Cache diff --git a/fs/Makefile b/fs/Makefile index 1ae846ab2dbb..8a8fde8af294 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -94,3 +94,4 @@ obj-$(CONFIG_AFS_FS) += afs/ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ +obj-$(CONFIG_DEBUG_FS) += debugfs/ diff --git a/fs/debugfs/Makefile b/fs/debugfs/Makefile new file mode 100644 index 000000000000..840c45696668 --- /dev/null +++ b/fs/debugfs/Makefile @@ -0,0 +1,4 @@ +debugfs-objs := inode.o file.o + +obj-$(CONFIG_DEBUG_FS) += debugfs.o + diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c new file mode 100644 index 000000000000..1e105f916fc0 --- /dev/null +++ b/fs/debugfs/file.c @@ -0,0 +1,262 @@ +/* + * file.c - part of debugfs, a tiny little debug file system + * + * Copyright (C) 2004 Greg Kroah-Hartman + * Copyright (C) 2004 IBM Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * debugfs is for people to use instead of /proc or /sys. + * See Documentation/DocBook/kernel-api for more details. + * + */ + +#include +#include +#include +#include +#include + +static ssize_t default_read_file(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + return 0; +} + +static ssize_t default_write_file(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + return count; +} + +static int default_open(struct inode *inode, struct file *file) +{ + if (inode->u.generic_ip) + file->private_data = inode->u.generic_ip; + + return 0; +} + +struct file_operations debugfs_file_operations = { + .read = default_read_file, + .write = default_write_file, + .open = default_open, +}; + +#define simple_type(type, format, temptype, strtolfn) \ +static ssize_t read_file_##type(struct file *file, char __user *user_buf, \ + size_t count, loff_t *ppos) \ +{ \ + char buf[32]; \ + type *val = file->private_data; \ + \ + snprintf(buf, sizeof(buf), format, *val); \ + return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));\ +} \ +static ssize_t write_file_##type(struct file *file, const char __user *user_buf,\ + size_t count, loff_t *ppos) \ +{ \ + char *endp; \ + char buf[32]; \ + int buf_size; \ + type *val = file->private_data; \ + temptype tmp; \ + \ + memset(buf, 0x00, sizeof(buf)); \ + buf_size = min(count, (sizeof(buf)-1)); \ + if (copy_from_user(buf, user_buf, buf_size)) \ + return -EFAULT; \ + \ + tmp = strtolfn(buf, &endp, 0); \ + if ((endp == buf) || ((type)tmp != tmp)) \ + return -EINVAL; \ + *val = tmp; \ + return count; \ +} \ +static struct file_operations fops_##type = { \ + .read = read_file_##type, \ + .write = write_file_##type, \ + .open = default_open, \ +}; +simple_type(u8, "%c", unsigned long, simple_strtoul); +simple_type(u16, "%hi", unsigned long, simple_strtoul); +simple_type(u32, "%i", unsigned long, simple_strtoul); + +/** + * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + * + * This function creates a file in debugfs with the given name that + * contains the value of the variable @value. If the @mode variable is so + * set, it can be read from, and written to. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_u8(const char *name, mode_t mode, + struct dentry *parent, u8 *value) +{ + return debugfs_create_file(name, mode, parent, value, &fops_u8); +} +EXPORT_SYMBOL_GPL(debugfs_create_u8); + +/** + * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + * + * This function creates a file in debugfs with the given name that + * contains the value of the variable @value. If the @mode variable is so + * set, it can be read from, and written to. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_u16(const char *name, mode_t mode, + struct dentry *parent, u16 *value) +{ + return debugfs_create_file(name, mode, parent, value, &fops_u16); +} +EXPORT_SYMBOL_GPL(debugfs_create_u16); + +/** + * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + * + * This function creates a file in debugfs with the given name that + * contains the value of the variable @value. If the @mode variable is so + * set, it can be read from, and written to. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_u32(const char *name, mode_t mode, + struct dentry *parent, u32 *value) +{ + return debugfs_create_file(name, mode, parent, value, &fops_u32); +} +EXPORT_SYMBOL_GPL(debugfs_create_u32); + +static ssize_t read_file_bool(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + char buf[3]; + u32 *val = file->private_data; + + if (val) + buf[0] = 'Y'; + else + buf[0] = 'N'; + buf[1] = '\n'; + buf[2] = 0x00; + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); +} + +static ssize_t write_file_bool(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + char buf[32]; + int buf_size; + u32 *val = file->private_data; + + buf_size = min(count, (sizeof(buf)-1)); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + switch (buf[0]) { + case 'y': + case 'Y': + case '1': + *val = 1; + break; + case 'n': + case 'N': + case '0': + *val = 0; + break; + } + + return count; +} + +static struct file_operations fops_bool = { + .read = read_file_bool, + .write = write_file_bool, + .open = default_open, +}; + +/** + * debugfs_create_bool - create a file in the debugfs filesystem that is used to read and write a boolean value. + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + * + * This function creates a file in debugfs with the given name that + * contains the value of the variable @value. If the @mode variable is so + * set, it can be read from, and written to. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_bool(const char *name, mode_t mode, + struct dentry *parent, u32 *value) +{ + return debugfs_create_file(name, mode, parent, value, &fops_bool); +} +EXPORT_SYMBOL_GPL(debugfs_create_bool); + diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c new file mode 100644 index 000000000000..887864a12486 --- /dev/null +++ b/fs/debugfs/inode.c @@ -0,0 +1,315 @@ +/* + * file.c - part of debugfs, a tiny little debug file system + * + * Copyright (C) 2004 Greg Kroah-Hartman + * Copyright (C) 2004 IBM Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * debugfs is for people to use instead of /proc or /sys. + * See Documentation/DocBook/kernel-api for more details. + * + */ + +/* uncomment to get debug messages from the debug filesystem, ah the irony. */ +/* #define DEBUG */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBUGFS_MAGIC 0x64626720 + +/* declared over in file.c */ +extern struct file_operations debugfs_file_operations; + +static struct vfsmount *debugfs_mount; +static int debugfs_mount_count; + +static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev) +{ + struct inode *inode = new_inode(sb); + + if (inode) { + inode->i_mode = mode; + inode->i_uid = 0; + inode->i_gid = 0; + inode->i_blksize = PAGE_CACHE_SIZE; + inode->i_blocks = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + switch (mode & S_IFMT) { + default: + init_special_inode(inode, mode, dev); + break; + case S_IFREG: + inode->i_fop = &debugfs_file_operations; + break; + case S_IFDIR: + inode->i_op = &simple_dir_inode_operations; + inode->i_fop = &simple_dir_operations; + + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inode->i_nlink++; + break; + } + } + return inode; +} + +/* SMP-safe */ +static int debugfs_mknod(struct inode *dir, struct dentry *dentry, + int mode, dev_t dev) +{ + struct inode *inode = debugfs_get_inode(dir->i_sb, mode, dev); + int error = -EPERM; + + if (dentry->d_inode) + return -EEXIST; + + if (inode) { + d_instantiate(dentry, inode); + dget(dentry); + error = 0; + } + return error; +} + +static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +{ + int res; + + mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; + res = debugfs_mknod(dir, dentry, mode, 0); + if (!res) + dir->i_nlink++; + return res; +} + +static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode) +{ + mode = (mode & S_IALLUGO) | S_IFREG; + return debugfs_mknod(dir, dentry, mode, 0); +} + +static inline int debugfs_positive(struct dentry *dentry) +{ + return dentry->d_inode && !d_unhashed(dentry); +} + +static int debug_fill_super(struct super_block *sb, void *data, int silent) +{ + static struct tree_descr debug_files[] = {{""}}; + + return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files); +} + +static struct dentry * get_dentry(struct dentry *parent, const char *name) +{ + struct qstr qstr; + + qstr.name = name; + qstr.len = strlen(name); + qstr.hash = full_name_hash(name,qstr.len); + return lookup_hash(&qstr,parent); +} + +static struct super_block *debug_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, + void *data) +{ + return get_sb_single(fs_type, flags, data, debug_fill_super); +} + +static struct file_system_type debug_fs_type = { + .owner = THIS_MODULE, + .name = "debugfs", + .get_sb = debug_get_sb, + .kill_sb = kill_litter_super, +}; + +static int debugfs_create_by_name(const char *name, mode_t mode, + struct dentry *parent, + struct dentry **dentry) +{ + int error = 0; + + /* If the parent is not specified, we create it in the root. + * We need the root dentry to do this, which is in the super + * block. A pointer to that is in the struct vfsmount that we + * have around. + */ + if (!parent ) { + if (debugfs_mount && debugfs_mount->mnt_sb) { + parent = debugfs_mount->mnt_sb->s_root; + } + } + if (!parent) { + pr_debug("debugfs: Ah! can not find a parent!\n"); + return -EFAULT; + } + + *dentry = NULL; + down(&parent->d_inode->i_sem); + *dentry = get_dentry (parent, name); + if (!IS_ERR(dentry)) { + if ((mode & S_IFMT) == S_IFDIR) + error = debugfs_mkdir(parent->d_inode, *dentry, mode); + else + error = debugfs_create(parent->d_inode, *dentry, mode); + } else + error = PTR_ERR(dentry); + up(&parent->d_inode->i_sem); + + return error; +} + +/** + * debugfs_create_file - create a file in the debugfs filesystem + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the debugfs filesystem. + * @data: a pointer to something that the caller will want to get to later + * on. The inode.u.generic_ip pointer will point to this value on + * the open() call. + * @fops: a pointer to a struct file_operations that should be used for + * this file. + * + * This is the basic "create a file" function for debugfs. It allows for a + * wide range of flexibility in createing a file, or a directory (if you + * want to create a directory, the debugfs_create_dir() function is + * recommended to be used instead.) + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_file(const char *name, mode_t mode, + struct dentry *parent, void *data, + struct file_operations *fops) +{ + struct dentry *dentry = NULL; + int error; + + pr_debug("debugfs: creating file '%s'\n",name); + + error = simple_pin_fs("debugfs", &debugfs_mount, &debugfs_mount_count); + if (error) + goto exit; + + error = debugfs_create_by_name(name, mode, parent, &dentry); + if (error) { + dentry = NULL; + goto exit; + } + + if (dentry->d_inode) { + if (data) + dentry->d_inode->u.generic_ip = data; + if (fops) + dentry->d_inode->i_fop = fops; + } +exit: + return dentry; +} +EXPORT_SYMBOL_GPL(debugfs_create_file); + +/** + * debugfs_create_dir - create a directory in the debugfs filesystem + * + * @name: a pointer to a string containing the name of the directory to + * create. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * directory will be created in the root of the debugfs filesystem. + * + * This function creates a directory in debugfs with the given name. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) +{ + return debugfs_create_file(name, + S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, + parent, NULL, NULL); +} +EXPORT_SYMBOL_GPL(debugfs_create_dir); + +/** + * debugfs_remove - removes a file or directory from the debugfs filesystem + * + * @dentry: a pointer to a the dentry of the file or directory to be + * removed. + * + * This function removes a file or directory in debugfs that was previously + * created with a call to another debugfs function (like + * debufs_create_file() or variants thereof.) + * + * This function is required to be called in order for the file to be + * removed, no automatic cleanup of files will happen when a module is + * removed, you are responsible here. + */ +void debugfs_remove(struct dentry *dentry) +{ + struct dentry *parent; + + if (!dentry) + return; + + parent = dentry->d_parent; + if (!parent || !parent->d_inode) + return; + + down(&parent->d_inode->i_sem); + if (debugfs_positive(dentry)) { + if (dentry->d_inode) { + if (S_ISDIR(dentry->d_inode->i_mode)) + simple_rmdir(parent->d_inode, dentry); + else + simple_unlink(parent->d_inode, dentry); + dput(dentry); + } + } + up(&parent->d_inode->i_sem); + simple_release_fs(&debugfs_mount, &debugfs_mount_count); +} +EXPORT_SYMBOL_GPL(debugfs_remove); + +static int __init debugfs_init(void) +{ + return register_filesystem(&debug_fs_type); +} + +static void __exit debugfs_exit(void) +{ + simple_release_fs(&debugfs_mount, &debugfs_mount_count); + unregister_filesystem(&debug_fs_type); +} + +core_initcall(debugfs_init); +module_exit(debugfs_exit); +MODULE_LICENSE("GPL"); + diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h new file mode 100644 index 000000000000..05042df44f5f --- /dev/null +++ b/include/linux/debugfs.h @@ -0,0 +1,90 @@ +/* + * debugfs.h - a tiny little debug file system + * + * Copyright (C) 2004 Greg Kroah-Hartman + * Copyright (C) 2004 IBM Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * debugfs is for people to use instead of /proc or /sys. + * See Documentation/DocBook/kernel-api for more details. + */ + +#ifndef _DEBUGFS_H_ +#define _DEBUGFS_H_ + +#if defined(CONFIG_DEBUG_FS) +struct dentry *debugfs_create_file(const char *name, mode_t mode, + struct dentry *parent, void *data, + struct file_operations *fops); + +struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); + +void debugfs_remove(struct dentry *dentry); + +struct dentry *debugfs_create_u8(const char *name, mode_t mode, + struct dentry *parent, u8 *value); +struct dentry *debugfs_create_u16(const char *name, mode_t mode, + struct dentry *parent, u16 *value); +struct dentry *debugfs_create_u32(const char *name, mode_t mode, + struct dentry *parent, u32 *value); +struct dentry *debugfs_create_bool(const char *name, mode_t mode, + struct dentry *parent, u32 *value); + +#else +/* + * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled + * so users have a chance to detect if there was a real error or not. We don't + * want to duplicate the design decision mistakes of procfs and devfs again. + */ + +static inline struct dentry *debugfs_create_file(const char *name, mode_t mode, + struct dentry *parent, + void *data, + struct file_operations *fops) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct dentry *debugfs_create_dir(const char *name, + struct dentry *parent) +{ + return ERR_PTR(-ENODEV); +} + +static inline void debugfs_remove(struct dentry *dentry) +{ } + +static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode, + struct dentry *parent, + u8 *value) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode, + struct dentry *parent, + u8 *value) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode, + struct dentry *parent, + u8 *value) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode, + struct dentry *parent, + u8 *value) +{ + return EFF_PTR(-ENODEV); +} + +#endif + +#endif diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d9da4ec792b4..8f06b18e20fb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -107,6 +107,16 @@ config DEBUG_INFO If you're truly short on disk space or don't expect to report any bugs back to the UML developers, say N, otherwise say Y. +config DEBUG_FS + bool "Debug Filesystem" + depends on DEBUG_KERNEL + help + debugfs is a virtual file system that kernel developers use to put + debugging files into. Enable this option to be able to read and + write to these files. + + If unsure, say N. + if !X86_64 config FRAME_POINTER bool "Compile the kernel with frame pointers" -- cgit v1.2.3 From 99de2bf455d72859de5c6dbf60f5183787b65440 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 16 Dec 2004 21:32:32 -0800 Subject: [PATCH] I2C: i2c-nforce2 supports the nForce3 250Gb One more PCI ID for the i2c-nforce2 driver, this time for the nForce3 250Gb variant. Tested, works. (Also cleans up a duplicate define in pci_ids.h.) Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-nforce2.c | 3 +++ include/linux/pci_ids.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index cc7ab3143f93..2cf9a75badd8 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -28,6 +28,7 @@ nForce2 MCP 0064 nForce2 Ultra 400 MCP 0084 nForce3 Pro150 MCP 00D4 + nForce3 250Gb MCP 00E4 This driver supports the 2 SMBuses that are included in the MCP2 of the nForce2 chipset. @@ -296,6 +297,8 @@ static struct pci_device_id nforce2_ids[] = { PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0 } }; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index affb193a43e6..38bf9f395629 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -1097,7 +1097,6 @@ #define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 #define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 #define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da -#define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 #define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 #define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 #define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 @@ -1105,6 +1104,7 @@ #define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df #define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 +#define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 #define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee -- cgit v1.2.3 From 1cb341665379c3784605ac5c0297ce332da16161 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Thu, 16 Dec 2004 22:01:35 -0800 Subject: [PATCH] PCI: Cleanup PCI power states > > > > This is step 0 before adding type-safety to PCI layer... It introduces > > > > constants and uses them to clean driver up. I'd like this to go in > > > > now, so that I can convert drivers during 2.6.10... Please apply, Okay, here it is, slightly expanded version. It actually makes use of newly defined type for type-checking purposes; still no code changes. From: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci.c | 8 ++++---- include/linux/pci.h | 14 +++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 646c7e338be3..579ec9db3bf7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -229,7 +229,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res) /** * pci_set_power_state - Set the power state of a PCI device * @dev: PCI device to be suspended - * @state: Power state we're entering + * @state: PCI power state (D0, D1, D2, D3hot, D3cold) we're entering * * Transition a device to a new power state, using the Power Management * Capabilities in the device's config space. @@ -242,7 +242,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res) */ int -pci_set_power_state(struct pci_dev *dev, int state) +pci_set_power_state(struct pci_dev *dev, pci_power_t state) { int pm; u16 pmcsr, pmc; @@ -354,7 +354,7 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) { int err; - pci_set_power_state(dev, 0); + pci_set_power_state(dev, PCI_D0); if ((err = pcibios_enable_device(dev, bars)) < 0) return err; return 0; @@ -428,7 +428,7 @@ pci_disable_device(struct pci_dev *dev) * 0 if operation is successful. * */ -int pci_enable_wake(struct pci_dev *dev, u32 state, int enable) +int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { int pm; u16 value; diff --git a/include/linux/pci.h b/include/linux/pci.h index 6e0973f334b1..f45a3d6a82c6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -480,6 +480,14 @@ enum pci_mmap_state { #define DEVICE_COUNT_COMPATIBLE 4 #define DEVICE_COUNT_RESOURCE 12 +typedef int __bitwise pci_power_t; + +#define PCI_D0 ((pci_power_t __force) 0) +#define PCI_D1 ((pci_power_t __force) 1) +#define PCI_D2 ((pci_power_t __force) 2) +#define PCI_D3hot ((pci_power_t __force) 3) +#define PCI_D3cold ((pci_power_t __force) 4) + /* * The pci_dev structure is used to describe PCI devices. */ @@ -508,7 +516,7 @@ struct pci_dev { this if your device has broken DMA or supports 64-bit transfers. */ - u32 current_state; /* Current operating state. In ACPI-speak, + pci_power_t current_state; /* Current operating state. In ACPI-speak, this is D0-D3, D0 being fully functional, and D3 being off. */ @@ -797,8 +805,8 @@ void pci_remove_rom(struct pci_dev *pdev); /* Power management related routines */ int pci_save_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev); -int pci_set_power_state(struct pci_dev *dev, int state); -int pci_enable_wake(struct pci_dev *dev, u32 state, int enable); +int pci_set_power_state(struct pci_dev *dev, pci_power_t state); +int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources(struct pci_bus *bus); -- cgit v1.2.3 From 9c57f57c50cdd8acff4005cb88d8b57adeb350d7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 16 Dec 2004 22:02:40 -0800 Subject: [PATCH] PCI: fix up function calls for CONFIG_PCI=N Signed-off-by: Greg Kroah-Hartman --- include/linux/pci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/pci.h b/include/linux/pci.h index f45a3d6a82c6..fe2b98de55ca 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -933,8 +933,8 @@ static inline const struct pci_device_id *pci_match_device(const struct pci_devi /* Power management related routines */ static inline int pci_save_state(struct pci_dev *dev) { return 0; } static inline int pci_restore_state(struct pci_dev *dev) { return 0; } -static inline int pci_set_power_state(struct pci_dev *dev, int state) { return 0; } -static inline int pci_enable_wake(struct pci_dev *dev, u32 state, int enable) { return 0; } +static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } +static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } #define isa_bridge ((struct pci_dev *)NULL) -- cgit v1.2.3 From b1cbc1086d663905c0e5775f3f5f28239f6c505e Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 16 Dec 2004 22:11:24 -0800 Subject: [PATCH] Driver Core: Add platform_get_resource_byname & platform_get_resource_byirq Adds the ability to find a resource or irq on a platform device by its resource name. This patch also tweaks how resource names get set. Before, resources names were set to pdev->dev.bus_id, now that only happens if the resource name has not been previous set. All of this allows us to find a resource without assuming what order the resources are in. Signed-off-by: Kumar Gala Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 40 +++++++++++++++++++++++++++++++++++++++- include/linux/device.h | 2 ++ 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 04451da003a6..351820713114 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -57,6 +57,41 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) return r ? r->start : 0; } +/** + * platform_get_resource_byname - get a resource for a device by name + * @dev: platform device + * @type: resource type + * @name: resource name + */ +struct resource * +platform_get_resource_byname(struct platform_device *dev, unsigned int type, + char *name) +{ + int i; + + for (i = 0; i < dev->num_resources; i++) { + struct resource *r = &dev->resource[i]; + + if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| + IORESOURCE_IRQ|IORESOURCE_DMA)) == type) + if (!strcmp(r->name, name)) + return r; + } + return NULL; +} + +/** + * platform_get_irq - get an IRQ for a device + * @dev: platform device + * @name: IRQ name + */ +int platform_get_irq_byname(struct platform_device *dev, char *name) +{ + struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); + + return r ? r->start : 0; +} + /** * platform_add_devices - add a numbers of platform devices * @devs: array of platform devices to add @@ -103,7 +138,8 @@ int platform_device_register(struct platform_device * pdev) for (i = 0; i < pdev->num_resources; i++) { struct resource *p, *r = &pdev->resource[i]; - r->name = pdev->dev.bus_id; + if (r->name == NULL) + r->name = pdev->dev.bus_id; p = NULL; if (r->flags & IORESOURCE_MEM) @@ -308,3 +344,5 @@ EXPORT_SYMBOL_GPL(platform_device_register_simple); EXPORT_SYMBOL_GPL(platform_device_unregister); EXPORT_SYMBOL_GPL(platform_get_irq); EXPORT_SYMBOL_GPL(platform_get_resource); +EXPORT_SYMBOL_GPL(platform_get_irq_byname); +EXPORT_SYMBOL_GPL(platform_get_resource_byname); diff --git a/include/linux/device.h b/include/linux/device.h index c64cec37dd69..d885723a2c3a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -382,6 +382,8 @@ extern struct device platform_bus; extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); extern int platform_get_irq(struct platform_device *, unsigned int); +extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, char *); +extern int platform_get_irq_byname(struct platform_device *, char *); extern int platform_add_devices(struct platform_device **, int); extern struct platform_device *platform_device_register_simple(char *, unsigned int, struct resource *, unsigned int); -- cgit v1.2.3 From b9efd2edd9c2523c6eac512c442197b87178d717 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 19 Dec 2004 23:43:59 -0800 Subject: USB: convert the idVendor, idProduct, bcdDevice and bcdUSB fields to __le16 These fields are in the struct usb_device_descriptor, and now we keep the native (on-the-wire mode) format of these fields. Any driver using these fields needs to convert it to cpu endian before using them. All USB drivers in the kernel tree have been fixed up to work properly with this change. All out-of-the USB kernel drivers are on their own... Signed-off-by: Greg Kroah-Hartman --- drivers/char/watchdog/pcwd_usb.c | 6 --- drivers/isdn/hisax/hfc_usb.c | 7 ++-- drivers/isdn/hisax/st5481_init.c | 3 +- drivers/media/dvb/dibusb/dvb-dibusb.c | 12 +++--- drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 6 +-- drivers/media/dvb/ttusb-dec/ttusb_dec.c | 8 ++-- drivers/net/irda/irda-usb.c | 4 +- drivers/net/irda/stir4200.c | 4 +- drivers/usb/atm/speedtch.c | 11 +++--- drivers/usb/class/audio.c | 3 +- drivers/usb/class/usb-midi.c | 26 +++++++------ drivers/usb/class/usb-midi.h | 4 +- drivers/usb/class/usblp.c | 19 ++++----- drivers/usb/core/devices.c | 10 +++-- drivers/usb/core/hcd.c | 16 ++++---- drivers/usb/core/hub.c | 2 +- drivers/usb/core/message.c | 7 +--- drivers/usb/core/otg_whitelist.h | 16 ++++---- drivers/usb/core/sysfs.c | 26 ++++++++++--- drivers/usb/core/usb.c | 22 +++++------ drivers/usb/host/hc_crisv10.c | 8 ++-- drivers/usb/image/microtek.c | 4 +- drivers/usb/input/aiptek.c | 6 +-- drivers/usb/input/ati_remote.c | 17 +++----- drivers/usb/input/hid-core.c | 8 ++-- drivers/usb/input/hid-ff.c | 4 +- drivers/usb/input/hid-input.c | 6 +-- drivers/usb/input/hid-lgff.c | 4 +- drivers/usb/input/hiddev.c | 6 +-- drivers/usb/input/kbtab.c | 6 +-- drivers/usb/input/mtouchusb.c | 6 +-- drivers/usb/input/powermate.c | 13 ++++--- drivers/usb/input/touchkitusb.c | 6 +-- drivers/usb/input/usbkbd.c | 6 +-- drivers/usb/input/usbmouse.c | 6 +-- drivers/usb/input/wacom.c | 6 +-- drivers/usb/input/xpad.c | 10 ++--- drivers/usb/media/dabusb.c | 9 +++-- drivers/usb/media/ibmcam.c | 21 +++------- drivers/usb/media/konicawc.c | 8 ++-- drivers/usb/media/ov511.c | 6 +-- drivers/usb/media/se401.c | 22 +++++------ drivers/usb/media/sn9c102_core.c | 4 +- drivers/usb/media/sn9c102_tas5110c1b.c | 6 +-- drivers/usb/media/sn9c102_tas5130d1b.c | 4 +- drivers/usb/media/stv680.c | 3 +- drivers/usb/media/ultracam.c | 8 +--- drivers/usb/media/vicam.c | 6 --- drivers/usb/media/w9968cf.c | 8 ++-- drivers/usb/misc/auerswald.c | 9 ++--- drivers/usb/misc/emi26.c | 8 ++-- drivers/usb/misc/emi62.c | 6 +-- drivers/usb/misc/legousbtower.c | 7 ---- drivers/usb/misc/usblcd.c | 15 +++++--- drivers/usb/misc/usbtest.c | 10 ++--- drivers/usb/misc/uss720.c | 3 +- drivers/usb/net/catc.c | 5 ++- drivers/usb/net/kaweth.c | 8 ++-- drivers/usb/serial/belkin_sa.c | 4 +- drivers/usb/serial/io_edgeport.c | 4 +- drivers/usb/serial/io_ti.c | 4 +- drivers/usb/serial/keyspan.c | 12 +++--- drivers/usb/serial/keyspan_pda.c | 6 +-- drivers/usb/serial/kobil_sct.c | 2 +- drivers/usb/serial/mct_u232.c | 9 +++-- drivers/usb/serial/ti_usb_3410_5052.c | 5 ++- drivers/usb/serial/usb-serial.c | 14 +++---- drivers/usb/serial/usb-serial.h | 4 -- drivers/usb/serial/visor.c | 4 +- drivers/usb/storage/scsiglue.c | 2 +- drivers/usb/storage/transport.c | 2 +- drivers/usb/storage/usb.c | 20 +++++----- include/linux/usb_ch9.h | 10 ++--- sound/usb/usbaudio.c | 47 +++++++++++++---------- sound/usb/usbmidi.c | 6 +-- sound/usb/usbmixer.c | 6 +-- sound/usb/usx2y/usX2Yhwdep.c | 4 +- sound/usb/usx2y/usbusx2y.c | 11 +++--- sound/usb/usx2y/usbusx2yaudio.c | 4 +- 79 files changed, 343 insertions(+), 347 deletions(-) (limited to 'include') diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index cdfe0db28784..a41a42606540 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c @@ -571,12 +571,6 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi char fw_ver_str[20]; unsigned char option_switches, dummy; - /* See if the device offered us matches what we can accept */ - if ((udev->descriptor.idVendor != USB_PCWD_VENDOR_ID) || - (udev->descriptor.idProduct != USB_PCWD_PRODUCT_ID)) { - return -ENODEV; - } - cards_found++; if (cards_found > 1) { printk(KERN_ERR PFX "This driver only supports 1 device\n"); diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index 4490c883f755..4fed45b5295a 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c @@ -1360,9 +1360,10 @@ static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id // usb_show_device_descriptor(&dev->descriptor); // usb_show_interface_descriptor(&iface->desc); vend_idx=0xffff; - for(i=0;vdata[i].vendor;i++) - { - if(dev->descriptor.idVendor==vdata[i].vendor && dev->descriptor.idProduct==vdata[i].prod_id) vend_idx=i; + for(i=0;vdata[i].vendor;i++) { + if (le16_to_cpu(dev->descriptor.idVendor) == vdata[i].vendor && + le16_to_cpu(dev->descriptor.idProduct) == vdata[i].prod_id) + vend_idx = i; } diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c index 92676bd60db6..2a34859f4096 100644 --- a/drivers/isdn/hisax/st5481_init.c +++ b/drivers/isdn/hisax/st5481_init.c @@ -67,7 +67,8 @@ static int probe_st5481(struct usb_interface *intf, int retval, i; printk(KERN_INFO "st541: found adapter VendorId %04x, ProductId %04x, LEDs %d\n", - dev->descriptor.idVendor, dev->descriptor.idProduct, + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct), number_of_leds); adapter = kmalloc(sizeof(struct st5481_adapter), GFP_KERNEL); diff --git a/drivers/media/dvb/dibusb/dvb-dibusb.c b/drivers/media/dvb/dibusb/dvb-dibusb.c index e4237a94bbd2..bb511205afef 100644 --- a/drivers/media/dvb/dibusb/dvb-dibusb.c +++ b/drivers/media/dvb/dibusb/dvb-dibusb.c @@ -602,8 +602,8 @@ static void frontend_init(struct usb_dibusb* dib) if (dib->fe == NULL) { printk("dvb-dibusb: A frontend driver was not found for device %04x/%04x\n", - dib->udev->descriptor.idVendor, - dib->udev->descriptor.idProduct); + le16_to_cpu(dib->udev->descriptor.idVendor), + le16_to_cpu(dib->udev->descriptor.idProduct)); } else { if (dvb_register_frontend(dib->adapter, dib->fe)) { printk("dvb-dibusb: Frontend registration failed!\n"); @@ -917,11 +917,11 @@ static int dibusb_probe(struct usb_interface *intf, int ret = -ENOMEM,i,cold=0; for (i = 0; i < DIBUSB_SUPPORTED_DEVICES; i++) - if (dibusb_devices[i].cold_product_id == udev->descriptor.idProduct || - dibusb_devices[i].warm_product_id == udev->descriptor.idProduct) { + if (dibusb_devices[i].cold_product_id == le16_to_cpu(udev->descriptor.idProduct) || + dibusb_devices[i].warm_product_id == le16_to_cpu(udev->descriptor.idProduct)) { dibdev = &dibusb_devices[i]; - cold = dibdev->cold_product_id == udev->descriptor.idProduct; + cold = dibdev->cold_product_id == le16_to_cpu(udev->descriptor.idProduct); if (cold) info("found a '%s' in cold state, will try to load a firmware",dibdev->name); @@ -931,7 +931,7 @@ static int dibusb_probe(struct usb_interface *intf, if (dibdev == NULL) { err("something went very wrong, " - "unknown product ID: %.4x",udev->descriptor.idProduct); + "unknown product ID: %.4x",le16_to_cpu(udev->descriptor.idProduct)); return -ENODEV; } diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 91a00d99f2ab..0485faa51b4d 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1348,7 +1348,7 @@ static struct tda8083_config ttusb_novas_grundig_29504_491_config = { static void frontend_init(struct ttusb* ttusb) { - switch(ttusb->dev->descriptor.idProduct) { + switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6(tsa5059) // try the ALPS BSRU6 first ttusb->fe = stv0299_attach(&alps_bsru6_config, &ttusb->i2c_adap); @@ -1381,8 +1381,8 @@ static void frontend_init(struct ttusb* ttusb) if (ttusb->fe == NULL) { printk("dvb-ttusb-budget: A frontend driver was not found for device %04x/%04x\n", - ttusb->dev->descriptor.idVendor, - ttusb->dev->descriptor.idProduct); + le16_to_cpu(ttusb->dev->descriptor.idVendor), + le16_to_cpu(ttusb->dev->descriptor.idProduct)); } else { if (dvb_register_frontend(ttusb->adapter, ttusb->fe)) { printk("dvb-ttusb-budget: Frontend registration failed!\n"); diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index b51a96141392..297af50de132 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -1447,7 +1447,7 @@ static int ttusb_dec_probe(struct usb_interface *intf, memset(dec, 0, sizeof(struct ttusb_dec)); - switch (id->idProduct) { + switch (le16_to_cpu(id->idProduct)) { case 0x1006: ttusb_dec_set_model(dec, TTUSB_DEC3000S); break; @@ -1471,7 +1471,7 @@ static int ttusb_dec_probe(struct usb_interface *intf, ttusb_dec_init_dvb(dec); dec->adapter->priv = dec; - switch (id->idProduct) { + switch (le16_to_cpu(id->idProduct)) { case 0x1006: dec->fe = ttusbdecfe_dvbs_attach(&fe_config); break; @@ -1484,8 +1484,8 @@ static int ttusb_dec_probe(struct usb_interface *intf, if (dec->fe == NULL) { printk("dvb-ttusb-dec: A frontend driver was not found for device %04x/%04x\n", - dec->udev->descriptor.idVendor, - dec->udev->descriptor.idProduct); + le16_to_cpu(dec->udev->descriptor.idVendor), + le16_to_cpu(dec->udev->descriptor.idProduct)); } else { if (dvb_register_frontend(dec->adapter, dec->fe)) { printk("budget-ci: Frontend registration failed!\n"); diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 84292c0e0464..2073919d7de1 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1360,8 +1360,8 @@ static int irda_usb_probe(struct usb_interface *intf, * Jean II */ MESSAGE("IRDA-USB found at address %d, Vendor: %x, Product: %x\n", - dev->devnum, dev->descriptor.idVendor, - dev->descriptor.idProduct); + dev->devnum, le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); net = alloc_irdadev(sizeof(*self)); if (!net) diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index f80a19e83a14..4bbd29cb1822 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c @@ -1072,8 +1072,8 @@ static int stir_probe(struct usb_interface *intf, printk(KERN_INFO "SigmaTel STIr4200 IRDA/USB found at address %d, " "Vendor: %x, Product: %x\n", - dev->devnum, dev->descriptor.idVendor, - dev->descriptor.idProduct); + dev->devnum, le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&stir->qos); diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index f17e576d12ec..3d5516e41953 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c @@ -594,7 +594,7 @@ static int speedtch_find_firmware(struct speedtch_instance_data const struct firmware **fw_p) { char buf[24]; - const u16 bcdDevice = instance->u.usb_dev->descriptor.bcdDevice; + const u16 bcdDevice = le16_to_cpu(instance->u.usb_dev->descriptor.bcdDevice); const u8 major_revision = bcdDevice >> 8; const u8 minor_revision = bcdDevice & 0xff; @@ -737,11 +737,12 @@ static int speedtch_usb_probe(struct usb_interface *intf, int ret, i; char buf7[SIZE_7]; - dbg("speedtch_usb_probe: trying device with vendor=0x%x, product=0x%x, ifnum %d", dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum); + dbg("speedtch_usb_probe: trying device with vendor=0x%x, product=0x%x, ifnum %d", + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct), ifnum); - if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) || - (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) || - (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1)) + if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) || + (ifnum != 1)) return -ENODEV; dbg("speedtch_usb_probe: device accepted"); diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c index 675b5ffa30c8..de86287fd394 100644 --- a/drivers/usb/class/audio.c +++ b/drivers/usb/class/audio.c @@ -2971,7 +2971,8 @@ static void usb_audio_parsestreaming(struct usb_audio_state *s, unsigned char *b } format = (fmt[5] == 2) ? (AFMT_U16_LE | AFMT_U8) : (AFMT_S16_LE | AFMT_S8); /* Dallas DS4201 workaround */ - if (dev->descriptor.idVendor == 0x04fa && dev->descriptor.idProduct == 0x4201) + if (le16_to_cpu(dev->descriptor.idVendor) == 0x04fa && + le16_to_cpu(dev->descriptor.idProduct) == 0x4201) format = (AFMT_S16_LE | AFMT_S8); fmt = find_csinterface_descriptor(buffer, buflen, NULL, FORMAT_TYPE, asifout, i); if (!fmt) { diff --git a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c index 1dc952e9bc81..dd7cbd35a0a7 100644 --- a/drivers/usb/class/usb-midi.c +++ b/drivers/usb/class/usb-midi.c @@ -1306,8 +1306,8 @@ static struct usb_midi_device *parse_descriptor( struct usb_device *d, unsigned return NULL; } u->deviceName = NULL; - u->idVendor = d->descriptor.idVendor; - u->idProduct = d->descriptor.idProduct; + u->idVendor = le16_to_cpu(d->descriptor.idVendor); + u->idProduct = le16_to_cpu(d->descriptor.idProduct); u->interface = ifnum; u->altSetting = altSetting; u->in[0].endpoint = -1; @@ -1661,11 +1661,11 @@ static int alloc_usb_midi_device( struct usb_device *d, struct usb_midi_state *s } /* Failsafe */ if ( !u->deviceName[0] ) { - if ( d->descriptor.idVendor == USB_VENDOR_ID_ROLAND ) { + if (le16_to_cpu(d->descriptor.idVendor) == USB_VENDOR_ID_ROLAND ) { strcpy(u->deviceName, "Unknown Roland"); - } else if ( d->descriptor.idVendor == USB_VENDOR_ID_STEINBERG ) { + } else if (le16_to_cpu(d->descriptor.idVendor) == USB_VENDOR_ID_STEINBERG ) { strcpy(u->deviceName, "Unknown Steinberg"); - } else if ( d->descriptor.idVendor == USB_VENDOR_ID_YAMAHA ) { + } else if (le16_to_cpu(d->descriptor.idVendor) == USB_VENDOR_ID_YAMAHA ) { strcpy(u->deviceName, "Unknown Yamaha"); } else { strcpy(u->deviceName, "Unknown"); @@ -1782,7 +1782,7 @@ static int detect_yamaha_device( struct usb_device *d, int alts=-1; int ret; - if (d->descriptor.idVendor != USB_VENDOR_ID_YAMAHA) { + if (le16_to_cpu(d->descriptor.idVendor) != USB_VENDOR_ID_YAMAHA) { return -EINVAL; } @@ -1799,7 +1799,8 @@ static int detect_yamaha_device( struct usb_device *d, } printk(KERN_INFO "usb-midi: Found YAMAHA USB-MIDI device on dev %04x:%04x, iface %d\n", - d->descriptor.idVendor, d->descriptor.idProduct, ifnum); + le16_to_cpu(d->descriptor.idVendor), + le16_to_cpu(d->descriptor.idProduct), ifnum); i = d->actconfig - d->config; buffer = d->rawdescriptors[i]; @@ -1833,8 +1834,8 @@ static int detect_vendor_specific_device( struct usb_device *d, unsigned int ifn for ( i=0; idescriptor.idVendor != u->idVendor || - d->descriptor.idProduct != u->idProduct || + if ( le16_to_cpu(d->descriptor.idVendor) != u->idVendor || + le16_to_cpu(d->descriptor.idProduct) != u->idProduct || ifnum != u->interface ) continue; @@ -1875,7 +1876,8 @@ static int detect_midi_subclass(struct usb_device *d, } printk(KERN_INFO "usb-midi: Found MIDISTREAMING on dev %04x:%04x, iface %d\n", - d->descriptor.idVendor, d->descriptor.idProduct, ifnum); + le16_to_cpu(d->descriptor.idVendor), + le16_to_cpu(d->descriptor.idProduct), ifnum); /* From USB Spec v2.0, Section 9.5. @@ -1915,8 +1917,8 @@ static int detect_by_hand(struct usb_device *d, unsigned int ifnum, struct usb_m { struct usb_midi_device u; - if ( d->descriptor.idVendor != uvendor || - d->descriptor.idProduct != uproduct || + if ( le16_to_cpu(d->descriptor.idVendor) != uvendor || + le16_to_cpu(d->descriptor.idProduct) != uproduct || ifnum != uinterface ) { return -EINVAL; } diff --git a/drivers/usb/class/usb-midi.h b/drivers/usb/class/usb-midi.h index 0e6eac11602a..358cdef8492e 100644 --- a/drivers/usb/class/usb-midi.h +++ b/drivers/usb/class/usb-midi.h @@ -63,8 +63,8 @@ struct usb_midi_endpoint { struct usb_midi_device { char *deviceName; - int idVendor; - int idProduct; + u16 idVendor; + u16 idProduct; int interface; int altSetting; /* -1: auto detect */ diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 3bde7c622b12..a775f94ff11b 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -527,7 +527,7 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, case IOCNR_HP_SET_CHANNEL: if (_IOC_DIR(cmd) != _IOC_WRITE || - usblp->dev->descriptor.idVendor != 0x03F0 || + le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 || usblp->quirks & USBLP_QUIRK_BIDIR) { retval = -EINVAL; goto done; @@ -574,8 +574,8 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, goto done; } - twoints[0] = usblp->dev->descriptor.idVendor; - twoints[1] = usblp->dev->descriptor.idProduct; + twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor); + twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct); if (copy_to_user((void __user *)arg, (unsigned char *)twoints, sizeof(twoints))) { @@ -910,15 +910,15 @@ static int usblp_probe(struct usb_interface *intf, /* Lookup quirks for this printer. */ usblp->quirks = usblp_quirks( - dev->descriptor.idVendor, - dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); /* Analyze and pick initial alternate settings and endpoints. */ protocol = usblp_select_alts(usblp); if (protocol < 0) { dbg("incompatible printer-class device 0x%4.4X/0x%4.4X", - dev->descriptor.idVendor, - dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); goto abort; } @@ -938,8 +938,9 @@ static int usblp_probe(struct usb_interface *intf, usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum, usblp->ifnum, usblp->protocol[usblp->current_protocol].alt_setting, - usblp->current_protocol, usblp->dev->descriptor.idVendor, - usblp->dev->descriptor.idProduct); + usblp->current_protocol, + le16_to_cpu(usblp->dev->descriptor.idVendor), + le16_to_cpu(usblp->dev->descriptor.idProduct)); usb_set_intfdata (intf, usblp); diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 50009ed51e8d..0485f15faed4 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -335,10 +335,13 @@ static char *usb_dump_config ( */ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb_device_descriptor *desc) { + u16 bcdUSB = le16_to_cpu(desc->bcdUSB); + u16 bcdDevice = le16_to_cpu(desc->bcdDevice); + if (start > end) return start; start += sprintf (start, format_device1, - desc->bcdUSB >> 8, desc->bcdUSB & 0xff, + bcdUSB >> 8, bcdUSB & 0xff, desc->bDeviceClass, class_decode (desc->bDeviceClass), desc->bDeviceSubClass, @@ -348,8 +351,9 @@ static char *usb_dump_device_descriptor(char *start, char *end, const struct usb if (start > end) return start; start += sprintf(start, format_device2, - desc->idVendor, desc->idProduct, - desc->bcdDevice >> 8, desc->bcdDevice & 0xff); + le16_to_cpu(desc->idVendor), + le16_to_cpu(desc->idProduct), + bcdDevice >> 8, bcdDevice & 0xff); return start; } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 59f76c95a05e..174d5491fb48 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -120,16 +120,16 @@ DECLARE_WAIT_QUEUE_HEAD(usb_kill_urb_queue); static const u8 usb2_rh_dev_descriptor [18] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ - 0x00, 0x02, /* __u16 bcdUSB; v2.0 */ + 0x00, 0x02, /* __le16 bcdUSB; v2.0 */ 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ - 0x00, 0x00, /* __u16 idVendor; */ - 0x00, 0x00, /* __u16 idProduct; */ - KERNEL_VER, KERNEL_REL, /* __u16 bcdDevice */ + 0x00, 0x00, /* __le16 idVendor; */ + 0x00, 0x00, /* __le16 idProduct; */ + KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 0x03, /* __u8 iManufacturer; */ 0x02, /* __u8 iProduct; */ @@ -143,16 +143,16 @@ static const u8 usb2_rh_dev_descriptor [18] = { static const u8 usb11_rh_dev_descriptor [18] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ - 0x10, 0x01, /* __u16 bcdUSB; v1.1 */ + 0x10, 0x01, /* __le16 bcdUSB; v1.1 */ 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ - 0x00, 0x00, /* __u16 idVendor; */ - 0x00, 0x00, /* __u16 idProduct; */ - KERNEL_VER, KERNEL_REL, /* __u16 bcdDevice */ + 0x00, 0x00, /* __le16 idVendor; */ + 0x00, 0x00, /* __le16 idProduct; */ + KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ 0x03, /* __u8 iManufacturer; */ 0x02, /* __u8 iProduct; */ diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 92429a1f583b..74334bf74195 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2494,7 +2494,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, } /* check for devices running slower than they could */ - if (udev->descriptor.bcdUSB >= 0x0200 + if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200 && udev->speed == USB_SPEED_FULL && highspeed_hubs != 0) check_highspeed (hub, udev, port1); diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index ce8efa53d0a0..caa984566153 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -796,13 +796,8 @@ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) return -ENOMEM; ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); - if (ret >= 0) { - le16_to_cpus(&desc->bcdUSB); - le16_to_cpus(&desc->idVendor); - le16_to_cpus(&desc->idProduct); - le16_to_cpus(&desc->bcdDevice); + if (ret >= 0) memcpy(&dev->descriptor, desc, size); - } kfree(desc); return ret; } diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h index 8bf4e811112f..627a5a2fc9cf 100644 --- a/drivers/usb/core/otg_whitelist.h +++ b/drivers/usb/core/otg_whitelist.h @@ -55,8 +55,8 @@ static int is_targeted(struct usb_device *dev) return 1; /* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ - if (dev->descriptor.idVendor == 0x1a0a - && dev->descriptor.idProduct == 0xbadd) + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a && + le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) return 0; /* NOTE: can't use usb_match_id() since interface caches @@ -64,21 +64,21 @@ static int is_targeted(struct usb_device *dev) */ for (id = whitelist_table; id->match_flags; id++) { if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && - id->idVendor != dev->descriptor.idVendor) + id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && - id->idProduct != dev->descriptor.idProduct) + id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) continue; /* No need to test id->bcdDevice_lo != 0, since 0 is never greater than any unsigned number. */ if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && - (id->bcdDevice_lo > dev->descriptor.bcdDevice)) + (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && - (id->bcdDevice_hi < dev->descriptor.bcdDevice)) + (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && @@ -101,8 +101,8 @@ static int is_targeted(struct usb_device *dev) /* OTG MESSAGE: report errors here, customize to match your product */ dev_err(&dev->dev, "device v%04x p%04x is not supported\n", - dev->descriptor.idVendor, - dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); #ifdef CONFIG_USB_OTG_WHITELIST return 0; #else diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index bae974d587ae..ce71f7af7478 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -149,10 +149,11 @@ static ssize_t show_version (struct device *dev, char *buf) { struct usb_device *udev; + u16 bcdUSB; - udev = to_usb_device (dev); - return sprintf (buf, "%2x.%02x\n", udev->descriptor.bcdUSB >> 8, - udev->descriptor.bcdUSB & 0xff); + udev = to_usb_device(dev); + bcdUSB = le16_to_cpu(udev->descriptor.bcdUSB); + return sprintf(buf, "%2x.%02x\n", bcdUSB >> 8, bcdUSB & 0xff); } static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); @@ -167,6 +168,22 @@ show_maxchild (struct device *dev, char *buf) static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL); /* Descriptor fields */ +#define usb_descriptor_attr_le16(field, format_string) \ +static ssize_t \ +show_##field (struct device *dev, char *buf) \ +{ \ + struct usb_device *udev; \ + \ + udev = to_usb_device (dev); \ + return sprintf (buf, format_string, \ + le16_to_cpu(udev->descriptor.field)); \ +} \ +static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); + +usb_descriptor_attr_le16(idVendor, "%04x\n") +usb_descriptor_attr_le16(idProduct, "%04x\n") +usb_descriptor_attr_le16(bcdDevice, "%04x\n") + #define usb_descriptor_attr(field, format_string) \ static ssize_t \ show_##field (struct device *dev, char *buf) \ @@ -178,9 +195,6 @@ show_##field (struct device *dev, char *buf) \ } \ static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); -usb_descriptor_attr (idVendor, "%04x\n") -usb_descriptor_attr (idProduct, "%04x\n") -usb_descriptor_attr (bcdDevice, "%04x\n") usb_descriptor_attr (bDeviceClass, "%02x\n") usb_descriptor_attr (bDeviceSubClass, "%02x\n") usb_descriptor_attr (bDeviceProtocol, "%02x\n") diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 9071d453a0b0..c0fb59274a4a 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -423,21 +423,21 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) id->driver_info; id++) { if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && - id->idVendor != dev->descriptor.idVendor) + id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && - id->idProduct != dev->descriptor.idProduct) + id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) continue; /* No need to test id->bcdDevice_lo != 0, since 0 is never greater than any unsigned number. */ if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && - (id->bcdDevice_lo > dev->descriptor.bcdDevice)) + (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && - (id->bcdDevice_hi < dev->descriptor.bcdDevice)) + (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) continue; if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && @@ -588,9 +588,9 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, "PRODUCT=%x/%x/%x", - usb_dev->descriptor.idVendor, - usb_dev->descriptor.idProduct, - usb_dev->descriptor.bcdDevice)) + le16_to_cpu(usb_dev->descriptor.idVendor), + le16_to_cpu(usb_dev->descriptor.idProduct), + le16_to_cpu(usb_dev->descriptor.bcdDevice))) return -ENOMEM; /* class-based driver binding models */ @@ -959,12 +959,12 @@ static struct usb_device *match_device(struct usb_device *dev, int child; dev_dbg(&dev->dev, "check for vendor %04x, product %04x ...\n", - dev->descriptor.idVendor, - dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); /* see if this device matches */ - if ((dev->descriptor.idVendor == vendor_id) && - (dev->descriptor.idProduct == product_id)) { + if ((vendor_id == le16_to_cpu(dev->descriptor.idVendor)) && + (product_id == le16_to_cpu(dev->descriptor.idProduct))) { dev_dbg (&dev->dev, "matched this device!\n"); ret_dev = usb_get_dev(dev); goto exit; diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 63a20144cb97..ac265542715c 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -113,17 +113,17 @@ static __u8 root_hub_dev_des[] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ - 0x00, /* __u16 bcdUSB; v1.0 */ + 0x00, /* __le16 bcdUSB; v1.0 */ 0x01, 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x00, /* __u8 bDeviceProtocol; */ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ - 0x00, /* __u16 idVendor; */ + 0x00, /* __le16 idVendor; */ 0x00, - 0x00, /* __u16 idProduct; */ + 0x00, /* __le16 idProduct; */ 0x00, - 0x00, /* __u16 bcdDevice; */ + 0x00, /* __le16 bcdDevice; */ 0x00, 0x00, /* __u8 iManufacturer; */ 0x02, /* __u8 iProduct; */ diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 2a18c35629eb..fe32608b4347 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -715,8 +715,8 @@ static int mts_usb_probe(struct usb_interface *intf, MTS_DEBUG( "usb-device descriptor at %x\n", (int)dev ); MTS_DEBUG( "product id = 0x%x, vendor id = 0x%x\n", - (int)dev->descriptor.idProduct, - (int)dev->descriptor.idVendor ); + le16_to_cpu(dev->descriptor.idProduct), + le16_to_cpu(dev->descriptor.idVendor) ); MTS_DEBUG_GOT_HERE(); diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index 67a5b70a6daf..a2a037fe791f 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c @@ -2137,9 +2137,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) aiptek->inputdev.name = "Aiptek"; aiptek->inputdev.phys = aiptek->features.usbPath; aiptek->inputdev.id.bustype = BUS_USB; - aiptek->inputdev.id.vendor = usbdev->descriptor.idVendor; - aiptek->inputdev.id.product = usbdev->descriptor.idProduct; - aiptek->inputdev.id.version = usbdev->descriptor.bcdDevice; + aiptek->inputdev.id.vendor = le16_to_cpu(usbdev->descriptor.idVendor); + aiptek->inputdev.id.product = le16_to_cpu(usbdev->descriptor.idProduct); + aiptek->inputdev.id.version = le16_to_cpu(usbdev->descriptor.bcdDevice); aiptek->usbdev = usbdev; aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index f491d76a8ff1..e1ece1113bc5 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -672,9 +672,9 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) idev->phys = ati_remote->phys; idev->id.bustype = BUS_USB; - idev->id.vendor = ati_remote->udev->descriptor.idVendor; - idev->id.product = ati_remote->udev->descriptor.idProduct; - idev->id.version = ati_remote->udev->descriptor.bcdDevice; + idev->id.vendor = le16_to_cpu(ati_remote->udev->descriptor.idVendor); + idev->id.product = le16_to_cpu(ati_remote->udev->descriptor.idProduct); + idev->id.version = le16_to_cpu(ati_remote->udev->descriptor.bcdDevice); } static int ati_remote_initialize(struct ati_remote *ati_remote) @@ -729,13 +729,6 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de char path[64]; char *buf = NULL; - /* See if the offered device matches what we can accept */ - if ((udev->descriptor.idVendor != ATI_REMOTE_VENDOR_ID) || - ( (udev->descriptor.idProduct != ATI_REMOTE_PRODUCT_ID) && - (udev->descriptor.idProduct != LOLA_REMOTE_PRODUCT_ID) && - (udev->descriptor.idProduct != MEDION_REMOTE_PRODUCT_ID) )) - return -ENODEV; - /* Allocate and clear an ati_remote struct */ if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL))) return -ENOMEM; @@ -803,8 +796,8 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de if (!strlen(ati_remote->name)) sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", - ati_remote->udev->descriptor.idVendor, - ati_remote->udev->descriptor.idProduct); + le16_to_cpu(ati_remote->udev->descriptor.idVendor), + le16_to_cpu(ati_remote->udev->descriptor.idProduct)); /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ retval = ati_remote_initialize(ati_remote); diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b8b69e074002..f09a789d18a6 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1599,8 +1599,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) int n; for (n = 0; hid_blacklist[n].idVendor; n++) - if ((hid_blacklist[n].idVendor == dev->descriptor.idVendor) && - (hid_blacklist[n].idProduct == dev->descriptor.idProduct)) + if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && + (hid_blacklist[n].idProduct == le16_to_cpu(dev->descriptor.idProduct))) quirks = hid_blacklist[n].quirks; if (quirks & HID_QUIRK_IGNORE) @@ -1724,7 +1724,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) } else if (usb_string(dev, dev->descriptor.iProduct, buf, 128) > 0) { snprintf(hid->name, 128, "%s", buf); } else - snprintf(hid->name, 128, "%04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct); + snprintf(hid->name, 128, "%04x:%04x", + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); usb_make_path(dev, buf, 64); snprintf(hid->phys, 64, "%s/input%d", buf, diff --git a/drivers/usb/input/hid-ff.c b/drivers/usb/input/hid-ff.c index b43463b4b0ff..f978680b9c0a 100644 --- a/drivers/usb/input/hid-ff.c +++ b/drivers/usb/input/hid-ff.c @@ -82,8 +82,8 @@ int hid_ff_init(struct hid_device* hid) { struct hid_ff_initializer *init; - init = hid_get_ff_init(hid->dev->descriptor.idVendor, - hid->dev->descriptor.idProduct); + init = hid_get_ff_init(le16_to_cpu(hid->dev->descriptor.idVendor), + le16_to_cpu(hid->dev->descriptor.idProduct)); if (!init) { dbg("hid_ff_init could not find initializer"); diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 042c6d48034d..72fe8d490310 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c @@ -593,9 +593,9 @@ int hidinput_connect(struct hid_device *hid) hidinput->input.phys = hid->phys; hidinput->input.uniq = hid->uniq; hidinput->input.id.bustype = BUS_USB; - hidinput->input.id.vendor = dev->descriptor.idVendor; - hidinput->input.id.product = dev->descriptor.idProduct; - hidinput->input.id.version = dev->descriptor.bcdDevice; + hidinput->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + hidinput->input.id.product = le16_to_cpu(dev->descriptor.idProduct); + hidinput->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice); hidinput->input.dev = &hid->intf->dev; } diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index fa8be80dac0b..b86f822e2968 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c @@ -251,8 +251,8 @@ static void hid_lgff_input_init(struct hid_device* hid) { struct device_type* dev = devices; signed short* ff; - u16 idVendor = hid->dev->descriptor.idVendor; - u16 idProduct = hid->dev->descriptor.idProduct; + u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); + u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 44e466d196b4..bf9a693a6f5a 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -423,9 +423,9 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd dinfo.busnum = dev->bus->busnum; dinfo.devnum = dev->devnum; dinfo.ifnum = hid->ifnum; - dinfo.vendor = dev->descriptor.idVendor; - dinfo.product = dev->descriptor.idProduct; - dinfo.version = dev->descriptor.bcdDevice; + dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); + dinfo.product = le16_to_cpu(dev->descriptor.idProduct); + dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); dinfo.num_applications = hid->maxapplication; if (copy_to_user(user_arg, &dinfo, sizeof(dinfo))) return -EFAULT; diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index 2e4c0d246030..a68c5b4e7b37 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c @@ -175,9 +175,9 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i kbtab->dev.name = "KB Gear Tablet"; kbtab->dev.phys = kbtab->phys; kbtab->dev.id.bustype = BUS_USB; - kbtab->dev.id.vendor = dev->descriptor.idVendor; - kbtab->dev.id.product = dev->descriptor.idProduct; - kbtab->dev.id.version = dev->descriptor.bcdDevice; + kbtab->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + kbtab->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); + kbtab->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); kbtab->dev.dev = &intf->dev; kbtab->usbdev = dev; diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index 9dcfd7e2ffbf..f0e75c939a48 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c @@ -223,9 +223,9 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i mtouch->input.name = mtouch->name; mtouch->input.phys = mtouch->phys; mtouch->input.id.bustype = BUS_USB; - mtouch->input.id.vendor = udev->descriptor.idVendor; - mtouch->input.id.product = udev->descriptor.idProduct; - mtouch->input.id.version = udev->descriptor.bcdDevice; + mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); + mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); mtouch->input.dev = &intf->dev; mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index 01384f523e15..6e77750b44a4 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c @@ -375,12 +375,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i return -EIO; /* failure */ } - switch (udev->descriptor.idProduct) { + switch (le16_to_cpu(udev->descriptor.idProduct)) { case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; default: - pm->input.name = pm_name_soundknob; - printk(KERN_WARNING "powermate: unknown product id %04x\n", udev->descriptor.idProduct); + pm->input.name = pm_name_soundknob; + printk(KERN_WARNING "powermate: unknown product id %04x\n", + le16_to_cpu(udev->descriptor.idProduct)); } pm->input.private = pm; @@ -389,9 +390,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); pm->input.id.bustype = BUS_USB; - pm->input.id.vendor = udev->descriptor.idVendor; - pm->input.id.product = udev->descriptor.idProduct; - pm->input.id.version = udev->descriptor.bcdDevice; + pm->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + pm->input.id.product = le16_to_cpu(udev->descriptor.idProduct); + pm->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); pm->input.event = powermate_input_event; pm->input.dev = &intf->dev; diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 65dd5be4eb99..734e1114aafb 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c @@ -211,9 +211,9 @@ static int touchkit_probe(struct usb_interface *intf, touchkit->input.name = touchkit->name; touchkit->input.phys = touchkit->phys; touchkit->input.id.bustype = BUS_USB; - touchkit->input.id.vendor = udev->descriptor.idVendor; - touchkit->input.id.product = udev->descriptor.idProduct; - touchkit->input.id.version = udev->descriptor.bcdDevice; + touchkit->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + touchkit->input.id.product = le16_to_cpu(udev->descriptor.idProduct); + touchkit->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); touchkit->input.dev = &intf->dev; touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 1700f405b00b..148d81e03480 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c @@ -296,9 +296,9 @@ static int usb_kbd_probe(struct usb_interface *iface, kbd->dev.name = kbd->name; kbd->dev.phys = kbd->phys; kbd->dev.id.bustype = BUS_USB; - kbd->dev.id.vendor = dev->descriptor.idVendor; - kbd->dev.id.product = dev->descriptor.idProduct; - kbd->dev.id.version = dev->descriptor.bcdDevice; + kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); + kbd->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); kbd->dev.dev = &iface->dev; if (!(buf = kmalloc(63, GFP_KERNEL))) { diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 8c7381b74499..54b247cfd312 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c @@ -180,9 +180,9 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ mouse->dev.name = mouse->name; mouse->dev.phys = mouse->phys; mouse->dev.id.bustype = BUS_USB; - mouse->dev.id.vendor = dev->descriptor.idVendor; - mouse->dev.id.product = dev->descriptor.idProduct; - mouse->dev.id.version = dev->descriptor.bcdDevice; + mouse->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + mouse->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); + mouse->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); mouse->dev.dev = &intf->dev; if (!(buf = kmalloc(63, GFP_KERNEL))) { diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index 471d1bf68bf0..f2f34392f855 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c @@ -692,9 +692,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i wacom->dev.name = wacom->features->name; wacom->dev.phys = wacom->phys; wacom->dev.id.bustype = BUS_USB; - wacom->dev.id.vendor = dev->descriptor.idVendor; - wacom->dev.id.product = dev->descriptor.idProduct; - wacom->dev.id.version = dev->descriptor.bcdDevice; + wacom->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + wacom->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); + wacom->dev.id.version = le16_to_cpu(dev->descriptor.bcdDevice); wacom->dev.dev = &intf->dev; wacom->usbdev = dev; diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index c5fa87edb667..d65edb22e545 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c @@ -226,8 +226,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id int i; for (i = 0; xpad_device[i].idVendor; i++) { - if ((udev->descriptor.idVendor == xpad_device[i].idVendor) && - (udev->descriptor.idProduct == xpad_device[i].idProduct)) + if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && + (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) break; } @@ -264,9 +264,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->udev = udev; xpad->dev.id.bustype = BUS_USB; - xpad->dev.id.vendor = udev->descriptor.idVendor; - xpad->dev.id.product = udev->descriptor.idProduct; - xpad->dev.id.version = udev->descriptor.bcdDevice; + xpad->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); + xpad->dev.id.product = le16_to_cpu(udev->descriptor.idProduct); + xpad->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); xpad->dev.dev = &intf->dev; xpad->dev.private = xpad; xpad->dev.name = xpad_device[i].name; diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c index 73f826d7d3d1..8823297d2191 100644 --- a/drivers/usb/media/dabusb.c +++ b/drivers/usb/media/dabusb.c @@ -724,13 +724,16 @@ static int dabusb_probe (struct usb_interface *intf, pdabusb_t s; dbg("dabusb: probe: vendor id 0x%x, device id 0x%x ifnum:%d", - usbdev->descriptor.idVendor, usbdev->descriptor.idProduct, intf->altsetting->desc.bInterfaceNumber); + le16_to_cpu(usbdev->descriptor.idVendor), + le16_to_cpu(usbdev->descriptor.idProduct), + intf->altsetting->desc.bInterfaceNumber); /* We don't handle multiple configurations */ if (usbdev->descriptor.bNumConfigurations != 1) return -ENODEV; - if (intf->altsetting->desc.bInterfaceNumber != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999) + if (intf->altsetting->desc.bInterfaceNumber != _DABUSB_IF && + le16_to_cpu(usbdev->descriptor.idProduct) == 0x9999) return -ENODEV; @@ -746,7 +749,7 @@ static int dabusb_probe (struct usb_interface *intf, err("reset_configuration failed"); goto reject; } - if (usbdev->descriptor.idProduct == 0x2131) { + if (le16_to_cpu(usbdev->descriptor.idProduct) == 0x2131) { dabusb_loadmem (s, NULL); goto reject; } diff --git a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c index 277d65b383f0..b4b1f59061bd 100644 --- a/drivers/usb/media/ibmcam.c +++ b/drivers/usb/media/ibmcam.c @@ -3659,17 +3659,8 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - /* Is it an IBM camera? */ - if (dev->descriptor.idVendor != IBMCAM_VENDOR_ID) - return -ENODEV; - if ((dev->descriptor.idProduct != IBMCAM_PRODUCT_ID) && - (dev->descriptor.idProduct != VEO_800C_PRODUCT_ID) && - (dev->descriptor.idProduct != VEO_800D_PRODUCT_ID) && - (dev->descriptor.idProduct != NETCAM_PRODUCT_ID)) - return -ENODEV; - /* Check the version/revision */ - switch (dev->descriptor.bcdDevice) { + switch (le16_to_cpu(dev->descriptor.bcdDevice)) { case 0x0002: if (ifnum != 2) return -ENODEV; @@ -3678,8 +3669,8 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * case 0x030A: if (ifnum != 0) return -ENODEV; - if ((dev->descriptor.idProduct == NETCAM_PRODUCT_ID) || - (dev->descriptor.idProduct == VEO_800D_PRODUCT_ID)) + if ((le16_to_cpu(dev->descriptor.idProduct) == NETCAM_PRODUCT_ID) || + (le16_to_cpu(dev->descriptor.idProduct) == VEO_800D_PRODUCT_ID)) model = IBMCAM_MODEL_4; else model = IBMCAM_MODEL_2; @@ -3691,14 +3682,14 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * break; default: err("IBM camera with revision 0x%04x is not supported.", - dev->descriptor.bcdDevice); + le16_to_cpu(dev->descriptor.bcdDevice)); return -ENODEV; } /* Print detailed info on what we found so far */ do { char *brand = NULL; - switch (dev->descriptor.idProduct) { + switch (le16_to_cpu(dev->descriptor.idProduct)) { case NETCAM_PRODUCT_ID: brand = "IBM NetCamera"; break; @@ -3714,7 +3705,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * break; } info("%s USB camera found (model %d, rev. 0x%04x)", - brand, model, dev->descriptor.bcdDevice); + brand, model, le16_to_cpu(dev->descriptor.bcdDevice)); } while (0); /* Validate found interface: must have one ISO endpoint */ diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c index aca3093c2b87..c7b427db989d 100644 --- a/drivers/usb/media/konicawc.c +++ b/drivers/usb/media/konicawc.c @@ -732,7 +732,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - info("Konica Webcam (rev. 0x%04x)", dev->descriptor.bcdDevice); + info("Konica Webcam (rev. 0x%04x)", le16_to_cpu(dev->descriptor.bcdDevice)); RESTRICT_TO_RANGE(speed, 0, MAX_SPEED); /* Validate found interface: must have one ISO endpoint */ @@ -846,9 +846,9 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id cam->input.evbit[0] = BIT(EV_KEY); cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); cam->input.id.bustype = BUS_USB; - cam->input.id.vendor = dev->descriptor.idVendor; - cam->input.id.product = dev->descriptor.idProduct; - cam->input.id.version = dev->descriptor.bcdDevice; + cam->input.id.vendor = le16_to_cpu(dev->descriptor.idVendor); + cam->input.id.product = le16_to_cpu(dev->descriptor.idProduct); + cam->input.id.version = le16_to_cpu(dev->descriptor.bcdDevice); input_register_device(&cam->input); usb_make_path(dev, cam->input_physname, 56); diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 8bd791d1df3e..8e122ba44417 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -5825,7 +5825,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) ov->auto_gain = autogain; ov->auto_exp = autoexp; - switch (dev->descriptor.idProduct) { + switch (le16_to_cpu(dev->descriptor.idProduct)) { case PROD_OV511: ov->bridge = BRG_OV511; ov->bclass = BCL_OV511; @@ -5843,13 +5843,13 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) ov->bclass = BCL_OV518; break; case PROD_ME2CAM: - if (dev->descriptor.idVendor != VEND_MATTEL) + if (le16_to_cpu(dev->descriptor.idVendor) != VEND_MATTEL) goto error; ov->bridge = BRG_OV511PLUS; ov->bclass = BCL_OV511; break; default: - err("Unknown product ID 0x%04x", dev->descriptor.idProduct); + err("Unknown product ID 0x%04x", le16_to_cpu(dev->descriptor.idProduct)); goto error; } diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c index ae4b3576ea32..6761806bc86f 100644 --- a/drivers/usb/media/se401.c +++ b/drivers/usb/media/se401.c @@ -1315,20 +1315,20 @@ static int se401_probe(struct usb_interface *intf, interface = &intf->cur_altsetting->desc; /* Is it an se401? */ - if (dev->descriptor.idVendor == 0x03e8 && - dev->descriptor.idProduct == 0x0004) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 && + le16_to_cpu(dev->descriptor.idProduct) == 0x0004) { camera_name="Endpoints/Aox SE401"; - } else if (dev->descriptor.idVendor == 0x0471 && - dev->descriptor.idProduct == 0x030b) { + } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 && + le16_to_cpu(dev->descriptor.idProduct) == 0x030b) { camera_name="Philips PCVC665K"; - } else if (dev->descriptor.idVendor == 0x047d && - dev->descriptor.idProduct == 0x5001) { + } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && + le16_to_cpu(dev->descriptor.idProduct) == 0x5001) { camera_name="Kensington VideoCAM 67014"; - } else if (dev->descriptor.idVendor == 0x047d && - dev->descriptor.idProduct == 0x5002) { + } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && + le16_to_cpu(dev->descriptor.idProduct) == 0x5002) { camera_name="Kensington VideoCAM 6701(5/7)"; - } else if (dev->descriptor.idVendor == 0x047d && - dev->descriptor.idProduct == 0x5003) { + } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d && + le16_to_cpu(dev->descriptor.idProduct) == 0x5003) { camera_name="Kensington VideoCAM 67016"; button=0; } else @@ -1354,7 +1354,7 @@ static int se401_probe(struct usb_interface *intf, se401->iface = interface->bInterfaceNumber; se401->camera_name = camera_name; - info("firmware version: %02x", dev->descriptor.bcdDevice & 255); + info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255); if (se401_init(se401, button)) { kfree(se401); diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index 87efdf7e0710..0da1baa0ea09 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c @@ -2496,8 +2496,8 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]); for (i = 0; i < n-1; i++) - if (udev->descriptor.idVendor==sn9c102_id_table[i].idVendor && - udev->descriptor.idProduct==sn9c102_id_table[i].idProduct) + if (le16_to_cpu(udev->descriptor.idVendor) == sn9c102_id_table[i].idVendor && + le16_to_cpu(udev->descriptor.idProduct) == sn9c102_id_table[i].idProduct) break; if (i == n-1) return -ENODEV; diff --git a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/usb/media/sn9c102_tas5110c1b.c index 72234fee25dc..14a8bdd147a5 100644 --- a/drivers/usb/media/sn9c102_tas5110c1b.c +++ b/drivers/usb/media/sn9c102_tas5110c1b.c @@ -165,9 +165,9 @@ int sn9c102_probe_tas5110c1b(struct sn9c102_device* cam) sn9c102_attach_sensor(cam, &tas5110c1b); /* Sensor detection is based on USB pid/vid */ - if (tas5110c1b.usbdev->descriptor.idProduct != 0x6001 && - tas5110c1b.usbdev->descriptor.idProduct != 0x6005 && - tas5110c1b.usbdev->descriptor.idProduct != 0x60ab) + if (le16_to_cpu(tas5110c1b.usbdev->descriptor.idProduct) != 0x6001 && + le16_to_cpu(tas5110c1b.usbdev->descriptor.idProduct) != 0x6005 && + le16_to_cpu(tas5110c1b.usbdev->descriptor.idProduct) != 0x60ab) return -ENODEV; return 0; diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/usb/media/sn9c102_tas5130d1b.c index cfd8331582a3..6bb23e16be3e 100644 --- a/drivers/usb/media/sn9c102_tas5130d1b.c +++ b/drivers/usb/media/sn9c102_tas5130d1b.c @@ -180,8 +180,8 @@ int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam) sn9c102_attach_sensor(cam, &tas5130d1b); /* Sensor detection is based on USB pid/vid */ - if (tas5130d1b.usbdev->descriptor.idProduct != 0x6025 && - tas5130d1b.usbdev->descriptor.idProduct != 0x60aa) + if (le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x6025 && + le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x60aa) return -ENODEV; return 0; diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c index b8e798345595..ae455c8e3702 100644 --- a/drivers/usb/media/stv680.c +++ b/drivers/usb/media/stv680.c @@ -1371,7 +1371,8 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id interface = &intf->altsetting[0]; /* Is it a STV680? */ - if ((dev->descriptor.idVendor == USB_PENCAM_VENDOR_ID) && (dev->descriptor.idProduct == USB_PENCAM_PRODUCT_ID)) { + if ((le16_to_cpu(dev->descriptor.idVendor) == USB_PENCAM_VENDOR_ID) && + (le16_to_cpu(dev->descriptor.idProduct) == USB_PENCAM_PRODUCT_ID)) { camera_name = "STV0680"; PDEBUG (0, "STV(i): STV0680 camera found."); } else { diff --git a/drivers/usb/media/ultracam.c b/drivers/usb/media/ultracam.c index 84f38839c491..b503332e792a 100644 --- a/drivers/usb/media/ultracam.c +++ b/drivers/usb/media/ultracam.c @@ -524,12 +524,8 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id if (dev->descriptor.bNumConfigurations != 1) return -ENODEV; - /* Is it an IBM camera? */ - if ((dev->descriptor.idVendor != ULTRACAM_VENDOR_ID) || - (dev->descriptor.idProduct != ULTRACAM_PRODUCT_ID)) - return -ENODEV; - - info("IBM Ultra camera found (rev. 0x%04x)", dev->descriptor.bcdDevice); + info("IBM Ultra camera found (rev. 0x%04x)", + le16_to_cpu(dev->descriptor.bcdDevice)); /* Validate found interface: must have one ISO endpoint */ nas = intf->num_altsetting; diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c index 411608f1b76f..908ff5b7a9d6 100644 --- a/drivers/usb/media/vicam.c +++ b/drivers/usb/media/vicam.c @@ -1281,12 +1281,6 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id) const struct usb_endpoint_descriptor *endpoint; struct vicam_camera *cam; - /* See if the device offered us matches what we can accept */ - if ((dev->descriptor.idVendor != USB_VICAM_VENDOR_ID) || - (dev->descriptor.idProduct != USB_VICAM_PRODUCT_ID)) { - return -ENODEV; - } - printk(KERN_INFO "ViCam based webcam connected\n"); interface = intf->cur_altsetting; diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 6604a30d5398..689e79e4bcee 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -3516,11 +3516,11 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) u8 sc = 0; /* number of simultaneous cameras */ static unsigned short dev_nr = 0; /* we are handling device number n */ - if (udev->descriptor.idVendor == winbond_id_table[0].idVendor && - udev->descriptor.idProduct == winbond_id_table[0].idProduct) + if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[0].idVendor && + le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */ - else if (udev->descriptor.idVendor == winbond_id_table[1].idVendor && - udev->descriptor.idProduct == winbond_id_table[1].idProduct) + else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor && + le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct) mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */ else return -ENODEV; diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index deba0ccab673..61fd957379e7 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -1931,11 +1931,8 @@ static int auerswald_probe (struct usb_interface *intf, int ret; dbg ("probe: vendor id 0x%x, device id 0x%x", - usbdev->descriptor.idVendor, usbdev->descriptor.idProduct); - - /* See if the device offered us matches that we can accept */ - if (usbdev->descriptor.idVendor != ID_AUERSWALD) - return -ENODEV; + le16_to_cpu(usbdev->descriptor.idVendor), + le16_to_cpu(usbdev->descriptor.idProduct)); /* we use only the first -and only- interface */ if (intf->altsetting->desc.bInterfaceNumber != 0) @@ -1969,7 +1966,7 @@ static int auerswald_probe (struct usb_interface *intf, cp->dtindex = intf->minor; /* Get the usb version of the device */ - cp->version = cp->usbdev->descriptor.bcdDevice; + cp->version = le16_to_cpu(cp->usbdev->descriptor.bcdDevice); dbg ("Version is %X", cp->version); /* allow some time to settle the device */ diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index cd37e011c463..66920ab9faf6 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -213,11 +213,9 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i struct usb_device *dev = interface_to_usbdev(intf); info("%s start", __FUNCTION__); - - if((dev->descriptor.idVendor == EMI26_VENDOR_ID) && (dev->descriptor.idProduct == EMI26_PRODUCT_ID)) { - emi26_load_firmware(dev); - } - + + emi26_load_firmware(dev); + /* do not return the driver context, let real audio driver do that */ return -EIO; } diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 5c5cb41844a5..189986af2ac7 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -255,10 +255,8 @@ static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *i info("%s start", __FUNCTION__); - if((dev->descriptor.idVendor == EMI62_VENDOR_ID) && (dev->descriptor.idProduct == EMI62_PRODUCT_ID)) { - emi62_load_firmware(dev); - } - + emi62_load_firmware(dev); + /* do not return the driver context, let real audio driver do that */ return -EIO; } diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index e83e91148970..e1e121791754 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -859,13 +859,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device info ("udev is NULL."); } - /* See if the device offered us matches what we can accept */ - if ((udev->descriptor.idVendor != LEGO_USB_TOWER_VENDOR_ID) || - (udev->descriptor.idProduct != LEGO_USB_TOWER_PRODUCT_ID)) { - return -ENODEV; - } - - /* allocate memory for our device state and intialize it */ dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 9ff010f1a93b..da8a43830a82 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c @@ -74,7 +74,7 @@ ioctl_lcd(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct lcd_usb_data *lcd = &lcd_instance; - int i; + u16 bcdDevice; char buf[30]; /* Sanity check to make sure lcd is connected, powered, etc */ @@ -85,9 +85,12 @@ ioctl_lcd(struct inode *inode, struct file *file, unsigned int cmd, switch (cmd) { case IOCTL_GET_HARD_VERSION: - i = (lcd->lcd_dev)->descriptor.bcdDevice; - sprintf(buf,"%1d%1d.%1d%1d",(i & 0xF000)>>12,(i & 0xF00)>>8, - (i & 0xF0)>>4,(i & 0xF)); + bcdDevice = le16_to_cpu((lcd->lcd_dev)->descriptor.bcdDevice); + sprintf(buf,"%1d%1d.%1d%1d", + (bcdDevice & 0xF000)>>12, + (bcdDevice & 0xF00)>>8, + (bcdDevice & 0xF0)>>4, + (bcdDevice & 0xF)); if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) return -EFAULT; break; @@ -258,7 +261,7 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id) int i; int retval; - if (dev->descriptor.idProduct != 0x0001 ) { + if (le16_to_cpu(dev->descriptor.idProduct) != 0x0001) { warn(KERN_INFO "USBLCD model not supported."); return -ENODEV; } @@ -268,7 +271,7 @@ static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id) return -ENODEV; } - i = dev->descriptor.bcdDevice; + i = le16_to_cpu(dev->descriptor.bcdDevice); info("USBLCD Version %1d%1d.%1d%1d found at address %d", (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF), diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 083f192c26a7..b2633048ae03 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -636,7 +636,7 @@ static int ch9_postconfig (struct usbtest_dev *dev) } /* and sometimes [9.2.6.6] speed dependent descriptors */ - if (udev->descriptor.bcdUSB == 0x0200) { /* pre-swapped */ + if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) { struct usb_qualifier_descriptor *d = NULL; /* device qualifier [9.6.2] */ @@ -1842,13 +1842,13 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) /* specify devices by module parameters? */ if (id->match_flags == 0) { /* vendor match required, product match optional */ - if (!vendor || udev->descriptor.idVendor != (u16)vendor) + if (!vendor || le16_to_cpu(udev->descriptor.idVendor) != (u16)vendor) return -ENODEV; - if (product && udev->descriptor.idProduct != (u16)product) + if (product && le16_to_cpu(udev->descriptor.idProduct) != (u16)product) return -ENODEV; dbg ("matched module params, vend=0x%04x prod=0x%04x", - udev->descriptor.idVendor, - udev->descriptor.idProduct); + le16_to_cpu(udev->descriptor.idVendor), + le16_to_cpu(udev->descriptor.idProduct)); } #endif diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 8b22320d5ea6..de91f8bafe62 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c @@ -544,7 +544,8 @@ static int uss720_probe(struct usb_interface *intf, int i; printk(KERN_DEBUG "uss720: probe: vendor id 0x%x, device id 0x%x\n", - usbdev->descriptor.idVendor, usbdev->descriptor.idProduct); + le16_to_cpu(usbdev->descriptor.idVendor), + le16_to_cpu(usbdev->descriptor.idProduct)); /* our known interfaces have 3 alternate settings */ if (intf->num_altsetting != 3) diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c index c825ef78c111..af883ae40d65 100644 --- a/drivers/usb/net/catc.c +++ b/drivers/usb/net/catc.c @@ -800,8 +800,9 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id } /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ - if (usbdev->descriptor.idVendor == 0x0423 && usbdev->descriptor.idProduct == 0xa && - catc->usbdev->descriptor.bcdDevice == 0x0130 ) { + if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 && + le16_to_cpu(usbdev->descriptor.idProduct) == 0xa && + le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) { dbg("Testing for f5u011"); catc->is_f5u011 = 1; atomic_set(&catc->recq_sz, 0); diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index 1d16b0c57244..4970df8e7716 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c @@ -903,9 +903,9 @@ static int kaweth_probe( kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", dev->devnum, - (int)dev->descriptor.idVendor, - (int)dev->descriptor.idProduct, - (int)dev->descriptor.bcdDevice); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct), + le16_to_cpu(dev->descriptor.bcdDevice)); kaweth_dbg("Device at %p", dev); @@ -933,7 +933,7 @@ static int kaweth_probe( * downloaded. Don't try to do it again, or we'll hang the device. */ - if (dev->descriptor.bcdDevice >> 8) { + if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { kaweth_info("Firmware present in device."); } else { /* Download the firmware */ diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 75dd41d98f86..a16502e474fe 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -181,8 +181,8 @@ static int belkin_sa_startup (struct usb_serial *serial) priv->last_lsr = 0; priv->last_msr = 0; /* see comments at top of file */ - priv->bad_flow_control = (dev->descriptor.bcdDevice <= 0x0206) ? 1 : 0; - info("bcdDevice: %04x, bfc: %d", dev->descriptor.bcdDevice, priv->bad_flow_control); + priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0; + info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control); init_waitqueue_head(&serial->port[0]->write_wait); usb_set_serial_port_data(serial->port[0], priv); diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 010160ed1f40..b194420025ef 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -659,7 +659,7 @@ static void get_product_info(struct edgeport_serial *edge_serial) memset (product_info, 0, sizeof(struct edgeport_product_info)); - product_info->ProductId = (__u16)(edge_serial->serial->dev->descriptor.idProduct & ~ION_DEVICE_ID_80251_NETCHIP); + product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP); product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts; product_info->ProdInfoVer = 0; @@ -675,7 +675,7 @@ static void get_product_info(struct edgeport_serial *edge_serial) memcpy(product_info->ManufactureDescDate, edge_serial->manuf_descriptor.DescDate, sizeof(edge_serial->manuf_descriptor.DescDate)); // check if this is 2nd generation hardware - if (edge_serial->serial->dev->descriptor.idProduct & ION_DEVICE_ID_80251_NETCHIP) { + if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ION_DEVICE_ID_80251_NETCHIP) { product_info->FirmwareMajorVersion = OperationalCodeImageVersion_GEN2.MajorVersion; product_info->FirmwareMinorVersion = OperationalCodeImageVersion_GEN2.MinorVersion; product_info->FirmwareBuildNumber = cpu_to_le16(OperationalCodeImageVersion_GEN2.BuildNumber); diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index bd86f7e7c357..b9846a5ae636 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -1342,9 +1342,9 @@ static int TIDownloadFirmware (struct edgeport_serial *serial) if (status) return status; - if (serial->serial->dev->descriptor.idVendor != USB_VENDOR_ID_ION) { + if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) != USB_VENDOR_ID_ION) { dbg ("%s - VID = 0x%x", __FUNCTION__, - serial->serial->dev->descriptor.idVendor); + le16_to_cpu(serial->serial->dev->descriptor.idVendor)); serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; goto StayInBootMode; } diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 9c7467b7e763..637c058f2ec4 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -1174,16 +1174,16 @@ static int keyspan_fake_startup (struct usb_serial *serial) char *fw_name; dbg("Keyspan startup version %04x product %04x", - serial->dev->descriptor.bcdDevice, - serial->dev->descriptor.idProduct); + le16_to_cpu(serial->dev->descriptor.bcdDevice), + le16_to_cpu(serial->dev->descriptor.idProduct)); - if ((serial->dev->descriptor.bcdDevice & 0x8000) != 0x8000) { + if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) { dbg("Firmware already loaded. Quitting."); return(1); } /* Select firmware image on the basis of idProduct */ - switch (serial->dev->descriptor.idProduct) { + switch (le16_to_cpu(serial->dev->descriptor.idProduct)) { case keyspan_usa28_pre_product_id: record = &keyspan_usa28_firmware[0]; fw_name = "USA28"; @@ -2248,10 +2248,10 @@ static int keyspan_startup (struct usb_serial *serial) dbg("%s", __FUNCTION__); for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) - if (d_details->product_id == serial->dev->descriptor.idProduct) + if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct)) break; if (d_details == NULL) { - dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __FUNCTION__, serial->dev->descriptor.idProduct); + dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __FUNCTION__, le16_to_cpu(serial->dev->descriptor.idProduct)); return 1; } diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 2f45c60bd25c..eaa290bbf40d 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -713,12 +713,12 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial) response = ezusb_set_reset(serial, 1); #ifdef KEYSPAN - if (serial->dev->descriptor.idVendor == KEYSPAN_VENDOR_ID) + if (le16_to_cpu(serial->dev->descriptor.idVendor) == KEYSPAN_VENDOR_ID) record = &keyspan_pda_firmware[0]; #endif #ifdef XIRCOM - if ((serial->dev->descriptor.idVendor == XIRCOM_VENDOR_ID) || - (serial->dev->descriptor.idVendor == ENTREGRA_VENDOR_ID)) + if ((le16_to_cpu(serial->dev->descriptor.idVendor) == XIRCOM_VENDOR_ID) || + (le16_to_cpu(serial->dev->descriptor.idVendor) == ENTREGRA_VENDOR_ID)) record = &xircom_pgs_firmware[0]; #endif if (record == NULL) { diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index a37b28d134ce..10d5cd1377a5 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -155,7 +155,7 @@ static int kobil_startup (struct usb_serial *serial) priv->filled = 0; priv->cur_pos = 0; - priv->device_type = serial->product; + priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); priv->line_state = 0; switch (priv->device_type){ diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 119b0956813c..a61fecf5cdd1 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -173,9 +173,10 @@ struct mct_u232_private { * we do not know how to support. We ignore them for the moment. * XXX Rate-limit the error message, it's user triggerable. */ -static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) { - if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID - || serial->dev->descriptor.idProduct == MCT_U232_BELKIN_F5U109_PID) { +static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) +{ + if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID + || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { switch (value) { case B300: return 0x01; case B600: return 0x02; /* this one not tested */ @@ -403,7 +404,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) * it seems to be able to accept only 16 bytes (and that's what * SniffUSB says too...) */ - if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID) + if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID) port->bulk_out_size = 16; /* Do a defined restart: the normal serial device seems to diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 0493f78ccc52..dc18427cf4e4 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -407,7 +407,10 @@ static int ti_startup(struct usb_serial *serial) int i; - dbg("%s - product 0x%4X, num configurations %d, configuration value %d", __FUNCTION__, dev->descriptor.idProduct, dev->descriptor.bNumConfigurations, dev->actconfig->desc.bConfigurationValue); + dbg("%s - product 0x%4X, num configurations %d, configuration value %d", + __FUNCTION__, le16_to_cpu(dev->descriptor.idProduct), + dev->descriptor.bNumConfigurations, + dev->actconfig->desc.bConfigurationValue); /* create device structure */ tdev = kmalloc(sizeof(struct ti_device), GFP_KERNEL); diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 11638a14449b..cc28224926c7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -721,7 +721,9 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int if (serial->type->owner) length += sprintf (page+length, " module:%s", module_name(serial->type->owner)); length += sprintf (page+length, " name:\"%s\"", serial->type->name); - length += sprintf (page+length, " vendor:%04x product:%04x", serial->vendor, serial->product); + length += sprintf (page+length, " vendor:%04x product:%04x", + le16_to_cpu(serial->dev->descriptor.idVendor), + le16_to_cpu(serial->dev->descriptor.idProduct)); length += sprintf (page+length, " num_ports:%d", serial->num_ports); length += sprintf (page+length, " port:%d", i - serial->minor + 1); @@ -834,8 +836,6 @@ static struct usb_serial * create_serial (struct usb_device *dev, serial->dev = usb_get_dev(dev); serial->type = type; serial->interface = interface; - serial->vendor = dev->descriptor.idVendor; - serial->product = dev->descriptor.idProduct; kref_init(&serial->kref); return serial; @@ -959,10 +959,10 @@ int usb_serial_probe(struct usb_interface *interface, #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE) /* BEGIN HORRIBLE HACK FOR PL2303 */ /* this is needed due to the looney way its endpoints are set up */ - if (((dev->descriptor.idVendor == PL2303_VENDOR_ID) && - (dev->descriptor.idProduct == PL2303_PRODUCT_ID)) || - ((dev->descriptor.idVendor == ATEN_VENDOR_ID) && - (dev->descriptor.idProduct == ATEN_PRODUCT_ID))) { + if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && + (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) || + ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && + (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID))) { if (interface != dev->actconfig->interface[0]) { /* check out the endpoints of the other interface*/ iface_desc = dev->actconfig->interface[0]->cur_altsetting; diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h index 1daf0752feed..d1f0c4057fa6 100644 --- a/drivers/usb/serial/usb-serial.h +++ b/drivers/usb/serial/usb-serial.h @@ -148,8 +148,6 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void * @num_interrupt_out: number of interrupt out endpoints we have * @num_bulk_in: number of bulk in endpoints we have * @num_bulk_out: number of bulk out endpoints we have - * @vendor: vendor id of this device - * @product: product id of this device * @port: array of struct usb_serial_port structures for the different ports. * @private: place to put any driver specific information that is needed. The * usb-serial driver is required to manage this data, the usb-serial core @@ -167,8 +165,6 @@ struct usb_serial { char num_interrupt_out; char num_bulk_in; char num_bulk_out; - __u16 vendor; - __u16 product; struct usb_serial_port * port[MAX_NUM_PORTS]; struct kref kref; void * private; diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index d5b5cdd9ef2a..5148bbb8542a 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -926,8 +926,8 @@ static int treo_attach (struct usb_serial *serial) /* Only do this endpoint hack for the Handspring devices with * interrupt in endpoints, which for now are the Treo devices. */ - if (!((serial->dev->descriptor.idVendor == HANDSPRING_VENDOR_ID) || - (serial->dev->descriptor.idVendor == KYOCERA_VENDOR_ID)) || + if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) || + (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) || (serial->num_interrupt_in == 0)) goto generic_startup; diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 64e185fcf994..714e8328c841 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -118,7 +118,7 @@ static int slave_configure(struct scsi_device *sdev) * works okay and that's what Windows does. But we'll be * conservative; people can always use the sysfs interface to * increase max_sectors. */ - if (us->pusb_dev->descriptor.idVendor == USB_VENDOR_ID_GENESYS && + if (le16_to_cpu(us->pusb_dev->descriptor.idVendor) == USB_VENDOR_ID_GENESYS && sdev->request_queue->max_sectors > 64) blk_queue_max_sectors(sdev->request_queue, 64); diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index d12ef5e20a8d..ddc1e3bcf845 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -994,7 +994,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) /* Genesys Logic interface chips need a 100us delay between the * command phase and the data phase. Some devices need a little * more than that, probably because of clock rate inaccuracies. */ - if (us->pusb_dev->descriptor.idVendor == USB_VENDOR_ID_GENESYS) + if (le16_to_cpu(us->pusb_dev->descriptor.idVendor) == USB_VENDOR_ID_GENESYS) udelay(110); if (transfer_length) { diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index cfa0ebfcfae4..0a8c42a0a8bf 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -263,16 +263,17 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, available from the device."). */ memset(data+8,0,28); } else { + u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); memcpy(data+8, us->unusual_dev->vendorName, strlen(us->unusual_dev->vendorName) > 8 ? 8 : strlen(us->unusual_dev->vendorName)); memcpy(data+16, us->unusual_dev->productName, strlen(us->unusual_dev->productName) > 16 ? 16 : strlen(us->unusual_dev->productName)); - data[32] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>12) & 0x0F); - data[33] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>8) & 0x0F); - data[34] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice>>4) & 0x0F); - data[35] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice) & 0x0F); + data[32] = 0x30 + ((bcdDevice>>12) & 0x0F); + data[33] = 0x30 + ((bcdDevice>>8) & 0x0F); + data[34] = 0x30 + ((bcdDevice>>4) & 0x0F); + data[35] = 0x30 + ((bcdDevice) & 0x0F); } usb_stor_set_xfer_buf(data, data_len, us->srb); @@ -436,9 +437,9 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) us->pusb_intf = intf; us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; US_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", - us->pusb_dev->descriptor.idVendor, - us->pusb_dev->descriptor.idProduct, - us->pusb_dev->descriptor.bcdDevice); + le16_to_cpu(us->pusb_dev->descriptor.idVendor), + le16_to_cpu(us->pusb_dev->descriptor.idProduct), + le16_to_cpu(us->pusb_dev->descriptor.bcdDevice)); US_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", intf->cur_altsetting->desc.bInterfaceSubClass, intf->cur_altsetting->desc.bInterfaceProtocol); @@ -507,8 +508,9 @@ static void get_device_info(struct us_data *us, int id_index) " has %s in unusual_devs.h\n" " Please send a copy of this message to " "\n", - ddesc->idVendor, ddesc->idProduct, - ddesc->bcdDevice, + le16_to_cpu(ddesc->idVendor), + le16_to_cpu(ddesc->idProduct), + le16_to_cpu(ddesc->bcdDevice), idesc->bInterfaceSubClass, idesc->bInterfaceProtocol, msgs[msg]); diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h index c1aa8d8f67ce..e796edb6515a 100644 --- a/include/linux/usb_ch9.h +++ b/include/linux/usb_ch9.h @@ -156,14 +156,14 @@ struct usb_device_descriptor { __u8 bLength; __u8 bDescriptorType; - __u16 bcdUSB; + __le16 bcdUSB; __u8 bDeviceClass; __u8 bDeviceSubClass; __u8 bDeviceProtocol; __u8 bMaxPacketSize0; - __u16 idVendor; - __u16 idProduct; - __u16 bcdDevice; + __le16 idVendor; + __le16 idProduct; + __le16 bcdDevice; __u8 iManufacturer; __u8 iProduct; __u8 iSerialNumber; @@ -297,7 +297,7 @@ struct usb_qualifier_descriptor { __u8 bLength; __u8 bDescriptorType; - __u16 bcdUSB; + __le16 bcdUSB; __u8 bDeviceClass; __u8 bDeviceSubClass; __u8 bDeviceProtocol; diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 37ec3346c3be..9160f5c44948 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -2176,13 +2176,13 @@ static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audiofor static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp) { /* M-Audio */ - if (dev->descriptor.idVendor == 0x0763) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763) { /* Quattro: captured data only */ - if (dev->descriptor.idProduct == 0x2001 && + if (le16_to_cpu(dev->descriptor.idProduct) == 0x2001 && fp->endpoint & USB_DIR_IN) return 1; /* Audiophile USB */ - if (dev->descriptor.idProduct == 0x2003) + if (le16_to_cpu(dev->descriptor.idProduct) == 0x2003) return 1; } return 0; @@ -2246,7 +2246,8 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat break; case USB_AUDIO_FORMAT_PCM8: /* Dallas DS4201 workaround */ - if (dev->descriptor.idVendor == 0x04fa && dev->descriptor.idProduct == 0x4201) + if (le16_to_cpu(dev->descriptor.idVendor) == 0x04fa && + le16_to_cpu(dev->descriptor.idProduct) == 0x4201) pcm_format = SNDRV_PCM_FORMAT_S8; else pcm_format = SNDRV_PCM_FORMAT_U8; @@ -2414,7 +2415,8 @@ static int parse_audio_format(struct usb_device *dev, struct audioformat *fp, /* extigy apparently supports sample rates other than 48k * but not in ordinary way. so we enable only 48k atm. */ - if (dev->descriptor.idVendor == 0x041e && dev->descriptor.idProduct == 0x3000) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && + le16_to_cpu(dev->descriptor.idProduct) == 0x3000) { if (fmt[3] == USB_FORMAT_TYPE_I && stream == SNDRV_PCM_STREAM_PLAYBACK && fp->rates != SNDRV_PCM_RATE_48000) @@ -2517,8 +2519,8 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) /* some quirks for attributes here */ /* workaround for AudioTrak Optoplay */ - if (dev->descriptor.idVendor == 0x0a92 && - dev->descriptor.idProduct == 0x0053) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x0a92 && + le16_to_cpu(dev->descriptor.idProduct) == 0x0053) { /* Optoplay sets the sample rate attribute although * it seems not supporting it in fact. */ @@ -2526,8 +2528,8 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) } /* workaround for M-Audio Audiophile USB */ - if (dev->descriptor.idVendor == 0x0763 && - dev->descriptor.idProduct == 0x2003) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763 && + le16_to_cpu(dev->descriptor.idProduct) == 0x2003) { /* doesn't set the sample rate attribute, but supports it */ fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; } @@ -2536,11 +2538,11 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) * plantronics headset and Griffin iMic have set adaptive-in * although it's really not... */ - if ((dev->descriptor.idVendor == 0x047f && - dev->descriptor.idProduct == 0x0ca1) || + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x047f && + le16_to_cpu(dev->descriptor.idProduct) == 0x0ca1) || /* Griffin iMic (note that there is an older model 77d:223) */ - (dev->descriptor.idVendor == 0x077d && - dev->descriptor.idProduct == 0x07af)) { + (le16_to_cpu(dev->descriptor.idVendor) == 0x077d && + le16_to_cpu(dev->descriptor.idProduct) == 0x07af)) { fp->ep_attr &= ~EP_ATTR_MASK; if (stream == SNDRV_PCM_STREAM_PLAYBACK) fp->ep_attr |= EP_ATTR_ADAPTIVE; @@ -2788,7 +2790,7 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &ua25_ep }; - if (chip->dev->descriptor.idProduct == 0x002b) + if (le16_to_cpu(chip->dev->descriptor.idProduct) == 0x002b) return snd_usb_create_midi_interface(chip, iface, &ua700_quirk); else @@ -3000,7 +3002,9 @@ static void proc_audio_usbid_read(snd_info_entry_t *entry, snd_info_buffer_t *bu { snd_usb_audio_t *chip = entry->private_data; if (! chip->shutdown) - snd_iprintf(buffer, "%04x:%04x\n", chip->dev->descriptor.idVendor, chip->dev->descriptor.idProduct); + snd_iprintf(buffer, "%04x:%04x\n", + le16_to_cpu(chip->dev->descriptor.idVendor), + le16_to_cpu(chip->dev->descriptor.idProduct)); } static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) @@ -3081,7 +3085,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, strcpy(card->driver, "USB-Audio"); sprintf(component, "USB%04x:%04x", - dev->descriptor.idVendor, dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); snd_component_add(card, component); /* retrieve the device string as shortname */ @@ -3093,7 +3098,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, card->shortname, sizeof(card->shortname)) <= 0) { /* no name available from anywhere, so use ID */ sprintf(card->shortname, "USB Device %#04x:%#04x", - dev->descriptor.idVendor, dev->descriptor.idProduct); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); } } @@ -3160,7 +3166,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev, /* SB Extigy needs special boot-up sequence */ /* if more models come, this will go to the quirk list. */ - if (dev->descriptor.idVendor == 0x041e && dev->descriptor.idProduct == 0x3000) { + if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && + le16_to_cpu(dev->descriptor.idProduct) == 0x3000) { if (snd_usb_extigy_boot_quirk(dev, intf) < 0) goto __err_val; config = dev->actconfig; @@ -3194,8 +3201,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev, } for (i = 0; i < SNDRV_CARDS; i++) if (enable[i] && ! usb_chip[i] && - (vid[i] == -1 || vid[i] == dev->descriptor.idVendor) && - (pid[i] == -1 || pid[i] == dev->descriptor.idProduct)) { + (vid[i] == -1 || vid[i] == le16_to_cpu(dev->descriptor.idVendor)) && + (pid[i] == -1 || pid[i] == le16_to_cpu(dev->descriptor.idProduct))) { if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { goto __error; } diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 7851da413358..ea90667b057b 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c @@ -521,7 +521,7 @@ static struct usb_endpoint_descriptor* snd_usbmidi_get_int_epd(snd_usb_midi_t* u struct usb_host_interface *hostif; struct usb_interface_descriptor* intfd; - if (umidi->chip->dev->descriptor.idVendor != 0x0582) + if (le16_to_cpu(umidi->chip->dev->descriptor.idVendor) != 0x0582) return NULL; intf = umidi->iface; if (!intf || intf->num_altsetting != 2) @@ -839,8 +839,8 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, /* TODO: read port name from jack descriptor */ name_format = "%s MIDI %d"; - vendor = umidi->chip->dev->descriptor.idVendor; - product = umidi->chip->dev->descriptor.idProduct; + vendor = le16_to_cpu(umidi->chip->dev->descriptor.idVendor); + product = le16_to_cpu(umidi->chip->dev->descriptor.idProduct); for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) { if (snd_usbmidi_port_names[i].vendor == vendor && snd_usbmidi_port_names[i].product == product && diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 1d0aa0332403..141aadcda849 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c @@ -1490,12 +1490,12 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) state.buffer = hostif->extra; state.buflen = hostif->extralen; state.ctrlif = ctrlif; - state.vendor = dev->idVendor; - state.product = dev->idProduct; + state.vendor = le16_to_cpu(dev->idVendor); + state.product = le16_to_cpu(dev->idProduct); /* check the mapping table */ for (map = usbmix_ctl_maps; map->vendor; map++) { - if (map->vendor == dev->idVendor && map->product == dev->idProduct) { + if (map->vendor == le16_to_cpu(dev->idVendor) && map->product == le16_to_cpu(dev->idProduct)) { state.map = map->map; chip->ignore_ctl_error = map->ignore_ctl_error; break; diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index e6717f3e1bfc..ece291715287 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -133,7 +133,7 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i }; int id = -1; - switch (((usX2Ydev_t*)hw->private_data)->chip.dev->descriptor.idProduct) { + switch (le16_to_cpu(((usX2Ydev_t*)hw->private_data)->chip.dev->descriptor.idProduct)) { case USB_ID_US122: id = USX2Y_TYPE_122; break; @@ -185,7 +185,7 @@ static int usX2Y_create_usbmidi(snd_card_t* card ) }; struct usb_device *dev = usX2Y(card)->chip.dev; struct usb_interface *iface = usb_ifnum_to_if(dev, 0); - snd_usb_audio_quirk_t *quirk = dev->descriptor.idProduct == USB_ID_US428 ? &quirk_2 : &quirk_1; + snd_usb_audio_quirk_t *quirk = le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? &quirk_2 : &quirk_1; snd_printdd("usX2Y_create_usbmidi \n"); return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 82ecbf6025b0..f6aec1d6e1d6 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -331,7 +331,8 @@ static snd_card_t* usX2Y_create_card(struct usb_device* device) sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", card->shortname, - device->descriptor.idVendor, device->descriptor.idProduct, + le16_to_cpu(device->descriptor.idVendor), + le16_to_cpu(device->descriptor.idProduct), 0,//us428(card)->usbmidi.ifnum, usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum ); @@ -344,10 +345,10 @@ static void* usX2Y_usb_probe(struct usb_device* device, struct usb_interface *in { int err; snd_card_t* card; - if (device->descriptor.idVendor != 0x1604 || - (device->descriptor.idProduct != USB_ID_US122 && - device->descriptor.idProduct != USB_ID_US224 && - device->descriptor.idProduct != USB_ID_US428) || + if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || + (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && + le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && + le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428) || !(card = usX2Y_create_card(device))) return NULL; if ((err = usX2Y_hwdep_new(card, device)) < 0 || diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 758900618901..85d6c5273417 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -1023,10 +1023,10 @@ int usX2Y_audio_create(snd_card_t* card) if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8))) return err; - if (usX2Y(card)->chip.dev->descriptor.idProduct == USB_ID_US428) + if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) == USB_ID_US428) if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA))) return err; - if (usX2Y(card)->chip.dev->descriptor.idProduct != USB_ID_US122) + if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) != USB_ID_US122) err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122. return err; } -- cgit v1.2.3 From 46624aa39077c1d8a7d05550e81c4f0674ead48e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 Dec 2004 00:17:10 -0800 Subject: USB: change wTotalLength field in struct usb_config_descriptor to be __le16 Another step in the quest to get all USB data structures to be native endian. Signed-off-by: Greg Kroah-Hartman --- arch/mips/au1000/common/usbdev.c | 4 ++-- drivers/usb/class/audio.c | 2 +- drivers/usb/class/usb-midi.c | 4 ++-- drivers/usb/core/config.c | 2 +- drivers/usb/core/devio.c | 2 +- drivers/usb/core/hcd.c | 4 ++-- drivers/usb/core/hub.c | 8 ++++---- drivers/usb/core/inode.c | 2 +- drivers/usb/host/hc_crisv10.c | 2 +- drivers/usb/misc/usbtest.c | 5 ++--- include/linux/usb_ch9.h | 2 +- sound/usb/usbaudio.c | 7 ++++--- sound/usb/usbmidi.c | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/arch/mips/au1000/common/usbdev.c b/arch/mips/au1000/common/usbdev.c index a73a31655c57..0db5b1c3efd4 100644 --- a/arch/mips/au1000/common/usbdev.c +++ b/arch/mips/au1000/common/usbdev.c @@ -766,7 +766,7 @@ do_get_descriptor(struct usb_dev* dev, struct usb_ctrlrequest* setup) dev->conf_desc), 0); } else { - int len = dev->conf_desc->wTotalLength; + int len = le16_to_cpu(dev->conf_desc->wTotalLength); dbg("sending whole config desc," " size=%d, our size=%d", desc_len, len); desc_len = desc_len > len ? len : desc_len; @@ -1407,7 +1407,7 @@ usbdev_init(struct usb_device_descriptor* dev_desc, /* * initialize the full config descriptor */ - usbdev.full_conf_desc = fcd = kmalloc(config_desc->wTotalLength, + usbdev.full_conf_desc = fcd = kmalloc(le16_to_cpu(config_desc->wTotalLength), ALLOC_FLAGS); if (!fcd) { err("failed to alloc full config descriptor"); diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c index de86287fd394..e388a3c920c8 100644 --- a/drivers/usb/class/audio.c +++ b/drivers/usb/class/audio.c @@ -3801,7 +3801,7 @@ static int usb_audio_probe(struct usb_interface *intf, * find which configuration number is active */ buffer = dev->rawdescriptors[dev->actconfig - dev->config]; - buflen = dev->actconfig->desc.wTotalLength; + buflen = le16_to_cpu(dev->actconfig->desc.wTotalLength); s = usb_audio_parsecontrol(dev, buffer, buflen, intf->altsetting->desc.bInterfaceNumber); if (s) { usb_set_intfdata (intf, s); diff --git a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c index dd7cbd35a0a7..b5f85504cf55 100644 --- a/drivers/usb/class/usb-midi.c +++ b/drivers/usb/class/usb-midi.c @@ -1804,7 +1804,7 @@ static int detect_yamaha_device( struct usb_device *d, i = d->actconfig - d->config; buffer = d->rawdescriptors[i]; - bufSize = d->actconfig->desc.wTotalLength; + bufSize = le16_to_cpu(d->actconfig->desc.wTotalLength); u = parse_descriptor( d, buffer, bufSize, ifnum, alts, 1); if ( u == NULL ) { @@ -1892,7 +1892,7 @@ static int detect_midi_subclass(struct usb_device *d, i = d->actconfig - d->config; buffer = d->rawdescriptors[i]; - bufSize = d->actconfig->desc.wTotalLength; + bufSize = le16_to_cpu(d->actconfig->desc.wTotalLength); u = parse_descriptor( d, buffer, bufSize, ifnum, alts, 0); if ( u == NULL ) { diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 6f81ecea0c3c..d35d54f12b09 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -320,7 +320,7 @@ int usb_parse_configuration(struct device *ddev, int cfgidx, } /* for ((buffer2 = buffer, size2 = size); ...) */ size = buffer2 - buffer; - config->desc.wTotalLength = buffer2 - buffer0; + config->desc.wTotalLength = cpu_to_le16(buffer2 - buffer0); if (n != nintf) dev_warn(ddev, "config %d has %d interface%s, different from " diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 4b4d0efedbff..0d156fee8581 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -148,7 +148,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l /* The descriptor may claim to be longer than it * really is. Here is the actual allocated length. */ unsigned alloclen = - dev->config[i].desc.wTotalLength; + le16_to_cpu(dev->config[i].desc.wTotalLength); len = length - (*ppos - pos); if (len > nbytes) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 174d5491fb48..4428d92e24d9 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -170,7 +170,7 @@ static const u8 fs_rh_config_descriptor [] = { /* one configuration */ 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ - 0x19, 0x00, /* __u16 wTotalLength; */ + 0x19, 0x00, /* __le16 wTotalLength; */ 0x01, /* __u8 bNumInterfaces; (1) */ 0x01, /* __u8 bConfigurationValue; */ 0x00, /* __u8 iConfiguration; */ @@ -217,7 +217,7 @@ static const u8 hs_rh_config_descriptor [] = { /* one configuration */ 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ - 0x19, 0x00, /* __u16 wTotalLength; */ + 0x19, 0x00, /* __le16 wTotalLength; */ 0x01, /* __u8 bNumInterfaces; (1) */ 0x01, /* __u8 bConfigurationValue; */ 0x00, /* __u8 iConfiguration; */ diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 74334bf74195..897329e788cd 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1189,7 +1189,7 @@ int usb_new_device(struct usb_device *udev) /* descriptor may appear anywhere in config */ if (__usb_get_extra_descriptor (udev->rawdescriptors[0], - udev->config[0].desc.wTotalLength, + le16_to_cpu(udev->config[0].desc.wTotalLength), USB_DT_OTG, (void **) &desc) == 0) { if (desc->bmAttributes & USB_OTG_HNP) { unsigned port1; @@ -2828,8 +2828,8 @@ static int config_descriptors_changed(struct usb_device *udev) struct usb_config_descriptor *buf; for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { - if (len < udev->config[index].desc.wTotalLength) - len = udev->config[index].desc.wTotalLength; + if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) + len = le16_to_cpu(udev->config[index].desc.wTotalLength); } buf = kmalloc (len, SLAB_KERNEL); if (buf == 0) { @@ -2839,7 +2839,7 @@ static int config_descriptors_changed(struct usb_device *udev) } for (index = 0; index < udev->descriptor.bNumConfigurations; index++) { int length; - int old_length = udev->config[index].desc.wTotalLength; + int old_length = le16_to_cpu(udev->config[index].desc.wTotalLength); length = usb_get_descriptor(udev, USB_DT_CONFIG, index, buf, old_length); diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 58e3e9151dfb..99360bdb483e 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -695,7 +695,7 @@ void usbfs_add_device(struct usb_device *dev) for (i = 0; i < dev->descriptor.bNumConfigurations; ++i) { struct usb_config_descriptor *config = (struct usb_config_descriptor *)dev->rawdescriptors[i]; - i_size += le16_to_cpu ((__force __le16)config->wTotalLength); + i_size += le16_to_cpu(config->wTotalLength); } if (dev->usbfs_dentry->d_inode) dev->usbfs_dentry->d_inode->i_size = i_size; diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index ac265542715c..58b2056d3792 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -136,7 +136,7 @@ static __u8 root_hub_config_des[] = { 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ - 0x19, /* __u16 wTotalLength; */ + 0x19, /* __le16 wTotalLength; */ 0x00, 0x01, /* __u8 bNumInterfaces; */ 0x01, /* __u8 bConfigurationValue; */ diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index b2633048ae03..28f309aa2cf9 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -527,10 +527,9 @@ static int is_good_config (char *buf, int len) return 0; } - le16_to_cpus (&config->wTotalLength); - if (config->wTotalLength == len) /* read it all */ + if (le16_to_cpu(config->wTotalLength) == len) /* read it all */ return 1; - if (config->wTotalLength >= TBUF_SIZE) /* max partial read */ + if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */ return 1; dbg ("bogus config descriptor read size"); return 0; diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h index e796edb6515a..d13b47bafcae 100644 --- a/include/linux/usb_ch9.h +++ b/include/linux/usb_ch9.h @@ -208,7 +208,7 @@ struct usb_config_descriptor { __u8 bLength; __u8 bDescriptorType; - __u16 wTotalLength; + __le16 wTotalLength; __u8 bNumInterfaces; __u8 bConfigurationValue; __u8 iConfiguration; diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 9160f5c44948..087342ccbd22 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -2933,8 +2933,8 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac struct usb_host_config *config = dev->actconfig; int err; - if (get_cfg_desc(config)->wTotalLength == EXTIGY_FIRMWARE_SIZE_OLD || - get_cfg_desc(config)->wTotalLength == EXTIGY_FIRMWARE_SIZE_NEW) { + if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD || + le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) { snd_printdd("sending Extigy boot sequence...\n"); /* Send message to force it to reconnect with full interface. */ err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), @@ -2946,7 +2946,8 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac if (err < 0) snd_printdd("error usb_get_descriptor: %d\n", err); err = usb_reset_configuration(dev); if (err < 0) snd_printdd("error usb_reset_configuration: %d\n", err); - snd_printdd("extigy_boot: new boot length = %d\n", get_cfg_desc(config)->wTotalLength); + snd_printdd("extigy_boot: new boot length = %d\n", + le16_to_cpu(get_cfg_desc(config)->wTotalLength)); return -ENODEV; /* quit this anyway */ } return 0; diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index ea90667b057b..424d6d311169 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c @@ -59,7 +59,7 @@ struct usb_ms_header_descriptor { __u8 bDescriptorType; __u8 bDescriptorSubtype; __u8 bcdMSC[2]; - __u16 wTotalLength; + __le16 wTotalLength; } __attribute__ ((packed)); struct usb_ms_endpoint_descriptor { -- cgit v1.2.3 From 552c4455c79db5117174280fc377ce8cccaf6ba4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 Dec 2004 01:15:36 -0800 Subject: USB: change wMaxPacketSize field in struct usb_config_descriptor to be __le16 Yet another step in the quest to get all USB data structures to be native endian. Signed-off-by: Greg Kroah-Hartman --- arch/mips/au1000/common/usbdev.c | 2 +- drivers/bluetooth/bfusb.c | 2 +- drivers/bluetooth/hci_usb.c | 10 ++++---- drivers/char/watchdog/pcwd_usb.c | 2 +- drivers/isdn/hisax/hfc_usb.c | 8 +++--- drivers/isdn/hisax/st5481_b.c | 2 +- drivers/isdn/hisax/st5481_d.c | 2 +- drivers/isdn/hisax/st5481_usb.c | 4 +-- drivers/media/dvb/b2c2/b2c2-usb-core.c | 2 +- drivers/net/irda/irda-usb.c | 2 +- drivers/usb/class/audio.c | 2 +- drivers/usb/class/bluetty.c | 6 ++--- drivers/usb/class/cdc-acm.c | 6 ++--- drivers/usb/core/config.c | 1 - drivers/usb/core/devices.c | 4 +-- drivers/usb/core/hcd.c | 6 ++--- drivers/usb/core/hub.c | 10 ++++---- drivers/usb/gadget/dummy_hcd.c | 4 +-- drivers/usb/gadget/file_storage.c | 2 +- drivers/usb/host/hc_crisv10.c | 4 +-- drivers/usb/host/ohci-q.c | 4 +-- drivers/usb/image/mdc800.c | 45 ++++++++++++++++++++++++++++++---- drivers/usb/input/ati_remote.c | 2 +- drivers/usb/media/ibmcam.c | 4 +-- drivers/usb/media/konicawc.c | 10 ++++---- drivers/usb/media/ov511.c | 2 +- drivers/usb/media/ultracam.c | 8 +++--- drivers/usb/misc/auerswald.c | 2 +- drivers/usb/misc/legousbtower.c | 4 +-- drivers/usb/misc/usbtest.c | 6 ++--- drivers/usb/serial/usb-serial.c | 8 +++--- drivers/usb/usb-skeleton.c | 2 +- drivers/w1/dscore.c | 2 +- include/linux/usb.h | 2 +- include/linux/usb_ch9.h | 2 +- sound/usb/usbaudio.c | 8 +++--- sound/usb/usx2y/usbusx2yaudio.c | 4 +-- 37 files changed, 115 insertions(+), 81 deletions(-) (limited to 'include') diff --git a/arch/mips/au1000/common/usbdev.c b/arch/mips/au1000/common/usbdev.c index 0db5b1c3efd4..447a9a4612a8 100644 --- a/arch/mips/au1000/common/usbdev.c +++ b/arch/mips/au1000/common/usbdev.c @@ -1398,7 +1398,7 @@ usbdev_init(struct usb_device_descriptor* dev_desc, epd->bEndpointAddress |= (u8)ep->address; ep->direction = epd->bEndpointAddress & 0x80; ep->type = epd->bmAttributes & 0x03; - ep->max_pkt_size = epd->wMaxPacketSize; + ep->max_pkt_size = le16_to_cpu(epd->wMaxPacketSize); spin_lock_init(&ep->lock); ep->desc = epd; ep->reg = &ep_reg[ep->address]; diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 7803b91ee808..70afb90dc14a 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -678,7 +678,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i bfusb->udev = udev; bfusb->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; bfusb->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; - bfusb->bulk_pkt_size = bulk_out_ep->desc.wMaxPacketSize; + bfusb->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); rwlock_init(&bfusb->lock); diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 88f9a89406d6..a5df8b573cfa 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c @@ -193,7 +193,7 @@ static int hci_usb_intr_rx_submit(struct hci_usb *husb) BT_DBG("%s", husb->hdev->name); - size = husb->intr_in_ep->desc.wMaxPacketSize; + size = le16_to_cpu(husb->intr_in_ep->desc.wMaxPacketSize); buf = kmalloc(size, GFP_ATOMIC); if (!buf) @@ -268,7 +268,7 @@ static int hci_usb_isoc_rx_submit(struct hci_usb *husb) int err, mtu, size; void *buf; - mtu = husb->isoc_in_ep->desc.wMaxPacketSize; + mtu = le16_to_cpu(husb->isoc_in_ep->desc.wMaxPacketSize); size = mtu * HCI_MAX_ISOC_FRAMES; buf = kmalloc(size, GFP_ATOMIC); @@ -525,7 +525,7 @@ static inline int hci_usb_send_isoc(struct hci_usb *husb, struct sk_buff *skb) urb->transfer_buffer = skb->data; urb->transfer_buffer_length = skb->len; - __fill_isoc_desc(urb, skb->len, husb->isoc_out_ep->desc.wMaxPacketSize); + __fill_isoc_desc(urb, skb->len, le16_to_cpu(husb->isoc_out_ep->desc.wMaxPacketSize)); _urb->priv = skb; return __tx_submit(husb, _urb); @@ -897,10 +897,10 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id switch (ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_ISOC: - if (ep->desc.wMaxPacketSize < size || + if (le16_to_cpu(ep->desc.wMaxPacketSize) < size || uif->desc.bAlternateSetting != isoc) break; - size = ep->desc.wMaxPacketSize; + size = le16_to_cpu(ep->desc.wMaxPacketSize); isoc_alts = uif->desc.bAlternateSetting; diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index a41a42606540..42bce3eea236 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c @@ -615,7 +615,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi usb_pcwd->udev = udev; usb_pcwd->interface = interface; usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; - usb_pcwd->intr_size = (endpoint->wMaxPacketSize > 8 ? endpoint->wMaxPacketSize : 8); + usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); /* set up the memory buffer's */ if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) { diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index 4fed45b5295a..fcc67afd53c5 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c @@ -1492,7 +1492,7 @@ static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id case USB_ENDPOINT_XFER_INT: context->fifos[cidx].pipe = usb_rcvintpipe(dev, ep->desc.bEndpointAddress); context->fifos[cidx].usb_transfer_mode = USB_INT; - packet_size = ep->desc.wMaxPacketSize; // remember max packet size + packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); // remember max packet size #ifdef VERBOSE_USB_DEBUG printk (KERN_INFO "HFC-USB: Interrupt-In Endpoint found %d ms(idx:%d cidx:%d)!\n", ep->desc.bInterval, idx, cidx); @@ -1504,7 +1504,7 @@ static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id else context->fifos[cidx].pipe = usb_sndbulkpipe(dev, ep->desc.bEndpointAddress); context->fifos[cidx].usb_transfer_mode = USB_BULK; - packet_size = ep->desc.wMaxPacketSize; // remember max packet size + packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); // remember max packet size #ifdef VERBOSE_USB_DEBUG printk (KERN_INFO "HFC-USB: Bulk Endpoint found (idx:%d cidx:%d)!\n", idx, cidx); @@ -1516,7 +1516,7 @@ static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id else context->fifos[cidx].pipe = usb_sndisocpipe(dev, ep->desc.bEndpointAddress); context->fifos[cidx].usb_transfer_mode = USB_ISOC; - iso_packet_size = ep->desc.wMaxPacketSize; // remember max packet size + iso_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); // remember max packet size #ifdef VERBOSE_USB_DEBUG printk (KERN_INFO "HFC-USB: ISO Endpoint found (idx:%d cidx:%d)!\n", idx, cidx); @@ -1529,7 +1529,7 @@ static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id if (context->fifos[cidx].pipe) { context->fifos[cidx].fifonum = cidx; context->fifos[cidx].hfc = context; - context->fifos[cidx].usb_packet_maxlen = ep->desc.wMaxPacketSize; + context->fifos[cidx].usb_packet_maxlen = le16_to_cpu(ep->desc.wMaxPacketSize); context->fifos[cidx].intervall = ep->desc.bInterval; context->fifos[cidx].skbuff = NULL; #ifdef VERBOSE_USB_DEBUG diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c index 880d07b3f036..2fcd093921d8 100644 --- a/drivers/isdn/hisax/st5481_b.c +++ b/drivers/isdn/hisax/st5481_b.c @@ -274,7 +274,7 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2]; DBG(4,"endpoint address=%02x,packet size=%d", - endpoint->desc.bEndpointAddress, endpoint->desc.wMaxPacketSize); + endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize)); // Allocate memory for 8000bytes/sec + extra bytes if underrun return st5481_setup_isocpipes(b_out->urb, dev, diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c index 51d12023773e..071b1d31999f 100644 --- a/drivers/isdn/hisax/st5481_d.c +++ b/drivers/isdn/hisax/st5481_d.c @@ -669,7 +669,7 @@ static int st5481_setup_d_out(struct st5481_adapter *adapter) endpoint = &altsetting->endpoint[EP_D_OUT-1]; DBG(2,"endpoint address=%02x,packet size=%d", - endpoint->desc.bEndpointAddress, endpoint->desc.wMaxPacketSize); + endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize)); return st5481_setup_isocpipes(d_out->urb, dev, usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress), diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c index 478b1a17b077..2369180b1cb1 100644 --- a/drivers/isdn/hisax/st5481_usb.c +++ b/drivers/isdn/hisax/st5481_usb.c @@ -268,8 +268,8 @@ int st5481_setup_usb(struct st5481_adapter *adapter) } // The descriptor is wrong for some early samples of the ST5481 chip - altsetting->endpoint[3].desc.wMaxPacketSize = 32; - altsetting->endpoint[4].desc.wMaxPacketSize = 32; + altsetting->endpoint[3].desc.wMaxPacketSize = __constant_cpu_to_le16(32); + altsetting->endpoint[4].desc.wMaxPacketSize = __constant_cpu_to_le16(32); // Use alternative setting 3 on interface 0 to have 2B+D if ((status = usb_set_interface (dev, 0, 3)) < 0) { diff --git a/drivers/media/dvb/b2c2/b2c2-usb-core.c b/drivers/media/dvb/b2c2/b2c2-usb-core.c index d46c8c0f8c15..05aa900b4eda 100644 --- a/drivers/media/dvb/b2c2/b2c2-usb-core.c +++ b/drivers/media/dvb/b2c2/b2c2-usb-core.c @@ -370,7 +370,7 @@ static void b2c2_exit_usb(struct usb_b2c2_usb *b2c2) static int b2c2_init_usb(struct usb_b2c2_usb *b2c2) { - u16 frame_size = b2c2->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize; + u16 frame_size = le16_to_cpu(b2c2->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize); int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret; int buffer_offset = 0; diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 2073919d7de1..9e93080d2a13 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1220,7 +1220,7 @@ static inline int irda_usb_parse_endpoints(struct irda_usb_cb *self, struct usb_ ep = endpoint[i].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; dir = endpoint[i].desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK; attr = endpoint[i].desc.bmAttributes; - psize = endpoint[i].desc.wMaxPacketSize; + psize = le16_to_cpu(endpoint[i].desc.wMaxPacketSize); /* Is it a bulk endpoint ??? */ if(attr == USB_ENDPOINT_XFER_BULK) { diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c index e388a3c920c8..e5b6194bbb4b 100644 --- a/drivers/usb/class/audio.c +++ b/drivers/usb/class/audio.c @@ -3717,7 +3717,7 @@ static struct usb_audio_state *usb_audio_parsecontrol(struct usb_device *dev, un if (alt->desc.bNumEndpoints > 0) { /* Check all endpoints; should they all have a bandwidth of 0 ? */ for (k = 0; k < alt->desc.bNumEndpoints; k++) { - if (alt->endpoint[k].desc.wMaxPacketSize > 0) { + if (le16_to_cpu(alt->endpoint[k].desc.wMaxPacketSize) > 0) { printk(KERN_ERR "usbaudio: device %d audiocontrol interface %u endpoint %d does not have 0 bandwidth at alt[0]\n", dev->devnum, ctrlif, k); break; } diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c index 6585faa2882d..6bac65e0ade7 100644 --- a/drivers/usb/class/bluetty.c +++ b/drivers/usb/class/bluetty.c @@ -1086,7 +1086,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf, err("No free urbs available"); goto probe_error; } - bluetooth->bulk_in_buffer_size = buffer_size = endpoint->wMaxPacketSize; + bluetooth->bulk_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); bluetooth->bulk_in_endpointAddress = endpoint->bEndpointAddress; bluetooth->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); if (!bluetooth->bulk_in_buffer) { @@ -1098,7 +1098,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf, endpoint = bulk_out_endpoint[0]; bluetooth->bulk_out_endpointAddress = endpoint->bEndpointAddress; - bluetooth->bulk_out_buffer_size = endpoint->wMaxPacketSize * 2; + bluetooth->bulk_out_buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2; endpoint = interrupt_in_endpoint[0]; bluetooth->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); @@ -1106,7 +1106,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf, err("No free urbs available"); goto probe_error; } - bluetooth->interrupt_in_buffer_size = buffer_size = endpoint->wMaxPacketSize; + bluetooth->interrupt_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); bluetooth->interrupt_in_endpointAddress = endpoint->bEndpointAddress; bluetooth->interrupt_in_interval = endpoint->bInterval; bluetooth->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index cf7fcf829450..654277281adf 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -657,9 +657,9 @@ next_desc: } memset(acm, 0, sizeof(struct acm)); - ctrlsize = epctrl->wMaxPacketSize; - readsize = epread->wMaxPacketSize; - acm->writesize = epwrite->wMaxPacketSize; + ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); + readsize = le16_to_cpu(epread->wMaxPacketSize); + acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); acm->control = control_interface; acm->data = data_interface; acm->minor = minor; diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index d35d54f12b09..42e9f8466272 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -87,7 +87,6 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, ++ifp->desc.bNumEndpoints; memcpy(&endpoint->desc, d, n); - le16_to_cpus(&endpoint->desc.wMaxPacketSize); INIT_LIST_HEAD(&endpoint->urb_list); /* Skip over any Class Specific or Vendor Specific descriptors; diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 0485f15faed4..a6961efc2cf0 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -180,7 +180,7 @@ static char *usb_dump_endpoint_descriptor ( in = (desc->bEndpointAddress & USB_DIR_IN); dir = in ? 'I' : 'O'; if (speed == USB_SPEED_HIGH) { - switch (desc->wMaxPacketSize & (0x03 << 11)) { + switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { case 1 << 11: bandwidth = 2; break; case 2 << 11: bandwidth = 3; break; } @@ -227,7 +227,7 @@ static char *usb_dump_endpoint_descriptor ( start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, desc->bmAttributes, type, - (desc->wMaxPacketSize & 0x07ff) * bandwidth, + (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * bandwidth, interval, unit); return start; } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 4428d92e24d9..da38086b21f8 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -208,7 +208,7 @@ static const u8 fs_rh_config_descriptor [] = { 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ - 0x02, 0x00, /* __u16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ + 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 0xff /* __u8 ep_bInterval; (255ms -- usb 2.0 spec) */ }; @@ -255,7 +255,7 @@ static const u8 hs_rh_config_descriptor [] = { 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ - 0x02, 0x00, /* __u16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ + 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ }; @@ -809,7 +809,7 @@ int usb_register_root_hub (struct usb_device *usb_dev, struct device *parent_dev down (&usb_bus_list_lock); usb_dev->bus->root_hub = usb_dev; - usb_dev->ep0.desc.wMaxPacketSize = 64; + usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); if (retval != sizeof usb_dev->descriptor) { usb_dev->bus->root_hub = NULL; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 897329e788cd..4509d9ee0370 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2119,17 +2119,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, */ switch (udev->speed) { case USB_SPEED_HIGH: /* fixed at 64 */ - udev->ep0.desc.wMaxPacketSize = 64; + udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); break; case USB_SPEED_FULL: /* 8, 16, 32, or 64 */ /* to determine the ep0 maxpacket size, try to read * the device descriptor to get bMaxPacketSize0 and * then correct our initial guess. */ - udev->ep0.desc.wMaxPacketSize = 64; + udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); break; case USB_SPEED_LOW: /* fixed at 8 */ - udev->ep0.desc.wMaxPacketSize = 8; + udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(8); break; default: goto fail; @@ -2263,7 +2263,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, goto fail; i = udev->descriptor.bMaxPacketSize0; - if (udev->ep0.desc.wMaxPacketSize != i) { + if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { if (udev->speed != USB_SPEED_FULL || !(i == 8 || i == 16 || i == 32 || i == 64)) { dev_err(&udev->dev, "ep0 maxpacket = %d\n", i); @@ -2271,7 +2271,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, goto fail; } dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i); - udev->ep0.desc.wMaxPacketSize = i; + udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); ep0_reinit(udev); } diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index aa5af7a5cadf..dcd3b55b357f 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -247,7 +247,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) dum = ep_to_dummy (ep); if (!dum->driver || !is_enabled (dum)) return -ESHUTDOWN; - max = desc->wMaxPacketSize & 0x3ff; + max = le16_to_cpu(desc->wMaxPacketSize) & 0x3ff; /* drivers must not request bad settings, since lower levels * (hardware or its drivers) may not check. some endpoints @@ -1025,7 +1025,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) int tmp; /* high bandwidth mode */ - tmp = ep->desc->wMaxPacketSize; + tmp = le16_to_cpu(ep->desc->wMaxPacketSize); tmp = le16_to_cpu (tmp); tmp = (tmp >> 11) & 0x03; tmp *= 8 /* applies to entire frame */; diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 84d1f39cbcbd..b339538ae3f2 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -3132,7 +3132,7 @@ reset: if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0) goto reset; fsg->bulk_out_enabled = 1; - fsg->bulk_out_maxpacket = d->wMaxPacketSize; + fsg->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); if (transport_is_cbi()) { d = ep_desc(fsg->gadget, &fs_intr_in_desc, &hs_intr_in_desc); diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 58b2056d3792..4b12be822bd4 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -160,7 +160,7 @@ static __u8 root_hub_config_des[] = 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ - 0x08, /* __u16 ep_wMaxPacketSize; 8 Bytes */ + 0x08, /* __le16 ep_wMaxPacketSize; 8 Bytes */ 0x00, 0xff /* __u8 ep_bInterval; 255 ms */ }; @@ -4528,7 +4528,7 @@ static int __init etrax_usb_hc_init(void) usb_rh->speed = USB_SPEED_FULL; usb_rh->devnum = 1; hc->bus->devnum_next = 2; - usb_rh->ep0.desc.wMaxPacketSize = 64; + usb_rh->ep0.desc.wMaxPacketSize = __const_cpu_to_le16(64); usb_get_device_descriptor(usb_rh, USB_DT_DEVICE_SIZE); usb_new_device(usb_rh); diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 56f8c75aaf8e..c86815586886 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c @@ -433,7 +433,7 @@ static struct ed *ed_get ( ed->type = usb_pipetype(pipe); info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << 7; - info |= ep->desc.wMaxPacketSize << 16; + info |= le16_to_cpu(ep->desc.wMaxPacketSize) << 16; if (udev->speed == USB_SPEED_LOW) info |= ED_LOWSPEED; /* only control transfers store pids in tds */ @@ -449,7 +449,7 @@ static struct ed *ed_get ( ed->load = usb_calc_bus_time ( udev->speed, !is_out, ed->type == PIPE_ISOCHRONOUS, - ep->desc.wMaxPacketSize) + le16_to_cpu(ep->desc.wMaxPacketSize)) / 1000; } } diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 66bb13307df5..9960af52dd07 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -182,13 +182,48 @@ struct mdc800_data /* Specification of the Endpoints */ static struct usb_endpoint_descriptor mdc800_ed [4] = { - { 0,0, 0x01, 0x02, 8, 0,0,0 }, - { 0,0, 0x82, 0x03, 8, 0,0,0 }, - { 0,0, 0x03, 0x02, 64, 0,0,0 }, - { 0,0, 0x84, 0x02, 64, 0,0,0 } + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x01, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(8), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x82, + .bmAttributes = 0x03, + .wMaxPacketSize = __constant_cpu_to_le16(8), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x03, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(64), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, + { + .bLength = 0, + .bDescriptorType = 0, + .bEndpointAddress = 0x84, + .bmAttributes = 0x02, + .wMaxPacketSize = __constant_cpu_to_le16(64), + .bInterval = 0, + .bRefresh = 0, + .bSynchAddress = 0, + }, }; - /* The Variable used by the driver */ static struct mdc800_data* mdc800; diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index e1ece1113bc5..3f5414446485 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -756,7 +756,7 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de retval = -ENODEV; goto error; } - if (ati_remote->endpoint_in->wMaxPacketSize == 0) { + if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { err("%s: endpoint_in message size==0? \n", __FUNCTION__); retval = -ENODEV; goto error; diff --git a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c index b4b1f59061bd..64eb7ca72836 100644 --- a/drivers/usb/media/ibmcam.c +++ b/drivers/usb/media/ibmcam.c @@ -3743,7 +3743,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * err("Interface %d. has ISO OUT endpoint!", ifnum); return -ENODEV; } - if (endpoint->wMaxPacketSize == 0) { + if (le16_to_cpu(endpoint->wMaxPacketSize) == 0) { if (inactInterface < 0) inactInterface = i; else { @@ -3753,7 +3753,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id * } else { if (actInterface < 0) { actInterface = i; - maxPS = endpoint->wMaxPacketSize; + maxPS = le16_to_cpu(endpoint->wMaxPacketSize); if (debug > 0) info("Active setting=%d. maxPS=%d.", i, maxPS); } else diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c index c7b427db989d..7ff1468f5977 100644 --- a/drivers/usb/media/konicawc.c +++ b/drivers/usb/media/konicawc.c @@ -390,7 +390,7 @@ static int konicawc_start_data(struct uvd *uvd) spd_to_iface[cam->speed]); if (!interface) return -ENXIO; - pktsz = interface->endpoint[1].desc.wMaxPacketSize; + pktsz = le16_to_cpu(interface->endpoint[1].desc.wMaxPacketSize); DEBUG(1, "pktsz = %d", pktsz); if (!CAMERA_IS_OPERATIONAL(uvd)) { err("Camera is not operational"); @@ -756,7 +756,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id } endpoint = &interface->endpoint[1].desc; DEBUG(1, "found endpoint: addr: 0x%2.2x maxps = 0x%4.4x", - endpoint->bEndpointAddress, endpoint->wMaxPacketSize); + endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize)); if (video_ep == 0) video_ep = endpoint->bEndpointAddress; else if (video_ep != endpoint->bEndpointAddress) { @@ -773,7 +773,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id interface->desc.bInterfaceNumber); return -ENODEV; } - if (endpoint->wMaxPacketSize == 0) { + if (le16_to_cpu(endpoint->wMaxPacketSize) == 0) { if (inactInterface < 0) inactInterface = i; else { @@ -786,8 +786,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id actInterface = i; } } - if(endpoint->wMaxPacketSize > maxPS) - maxPS = endpoint->wMaxPacketSize; + if (le16_to_cpu(endpoint->wMaxPacketSize) > maxPS) + maxPS = le16_to_cpu(endpoint->wMaxPacketSize); } if(actInterface == -1) { err("Cant find required endpoint"); diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 8e122ba44417..082c4fd8ed75 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -5596,7 +5596,7 @@ ov518_configure(struct usb_ov511 *ov) if (ifp) { alt = usb_altnum_to_altsetting(ifp, 7); if (alt) - mxps = alt->endpoint[0].desc.wMaxPacketSize; + mxps = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); } /* Some OV518s have packet numbering by default, some don't */ diff --git a/drivers/usb/media/ultracam.c b/drivers/usb/media/ultracam.c index b503332e792a..fec1f09615f4 100644 --- a/drivers/usb/media/ultracam.c +++ b/drivers/usb/media/ultracam.c @@ -565,7 +565,7 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id interface->desc.bInterfaceNumber); return -ENODEV; } - if (endpoint->wMaxPacketSize == 0) { + if (le16_to_cpu(endpoint->wMaxPacketSize) == 0) { if (inactInterface < 0) inactInterface = i; else { @@ -575,15 +575,15 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id } else { if (actInterface < 0) { actInterface = i; - maxPS = endpoint->wMaxPacketSize; + maxPS = le16_to_cpu(endpoint->wMaxPacketSize); if (debug > 0) info("Active setting=%d. maxPS=%d.", i, maxPS); } else { /* Got another active alt. setting */ - if (maxPS < endpoint->wMaxPacketSize) { + if (maxPS < le16_to_cpu(endpoint->wMaxPacketSize)) { /* This one is better! */ actInterface = i; - maxPS = endpoint->wMaxPacketSize; + maxPS = le16_to_cpu(endpoint->wMaxPacketSize); if (debug > 0) { info("Even better ctive setting=%d. maxPS=%d.", i, maxPS); diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index 61fd957379e7..d656592c25dd 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -1132,7 +1132,7 @@ static int auerswald_int_open (pauerswald_t cp) ret = -EFAULT; goto intoend; } - irqsize = ep->desc.wMaxPacketSize; + irqsize = le16_to_cpu(ep->desc.wMaxPacketSize); cp->irqsize = irqsize; /* allocate the urb and data buffer */ diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index e1e121791754..edf3df586a8c 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -405,7 +405,7 @@ static int tower_open (struct inode *inode, struct file *file) dev->udev, usb_rcvintpipe(dev->udev, dev->interrupt_in_endpoint->bEndpointAddress), dev->interrupt_in_buffer, - dev->interrupt_in_endpoint->wMaxPacketSize, + le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), tower_interrupt_in_callback, dev, dev->interrupt_in_interval); @@ -924,7 +924,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device err("Couldn't allocate read_buffer"); goto error; } - dev->interrupt_in_buffer = kmalloc (dev->interrupt_in_endpoint->wMaxPacketSize, GFP_KERNEL); + dev->interrupt_in_buffer = kmalloc (le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize), GFP_KERNEL); if (!dev->interrupt_in_buffer) { err("Couldn't allocate interrupt_in_buffer"); goto error; diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 28f309aa2cf9..02bf324f8f5b 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -1371,8 +1371,8 @@ static struct urb *iso_alloc_urb ( if (bytes < 0 || !desc) return NULL; - maxp = 0x7ff & desc->wMaxPacketSize; - maxp *= 1 + (0x3 & (desc->wMaxPacketSize >> 11)); + maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); + maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); packets = (bytes + maxp - 1) / maxp; urb = usb_alloc_urb (packets, SLAB_KERNEL); @@ -1432,7 +1432,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param, "... iso period %d %sframes, wMaxPacket %04x\n", 1 << (desc->bInterval - 1), (udev->speed == USB_SPEED_HIGH) ? "micro" : "", - desc->wMaxPacketSize); + le16_to_cpu(desc->wMaxPacketSize)); for (i = 0; i < param->sglen; i++) { urbs [i] = iso_alloc_urb (udev, pipe, desc, diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index cc28224926c7..2836dfed6be1 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -1060,7 +1060,7 @@ int usb_serial_probe(struct usb_interface *interface, dev_err(&interface->dev, "No free urbs available\n"); goto probe_error; } - buffer_size = endpoint->wMaxPacketSize; + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->bulk_in_size = buffer_size; port->bulk_in_endpointAddress = endpoint->bEndpointAddress; port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); @@ -1084,7 +1084,7 @@ int usb_serial_probe(struct usb_interface *interface, dev_err(&interface->dev, "No free urbs available\n"); goto probe_error; } - buffer_size = endpoint->wMaxPacketSize; + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->bulk_out_size = buffer_size; port->bulk_out_endpointAddress = endpoint->bEndpointAddress; port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL); @@ -1109,7 +1109,7 @@ int usb_serial_probe(struct usb_interface *interface, dev_err(&interface->dev, "No free urbs available\n"); goto probe_error; } - buffer_size = endpoint->wMaxPacketSize; + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->interrupt_in_endpointAddress = endpoint->bEndpointAddress; port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); if (!port->interrupt_in_buffer) { @@ -1136,7 +1136,7 @@ int usb_serial_probe(struct usb_interface *interface, dev_err(&interface->dev, "No free urbs available\n"); goto probe_error; } - buffer_size = endpoint->wMaxPacketSize; + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); port->interrupt_out_size = buffer_size; port->interrupt_out_endpointAddress = endpoint->bEndpointAddress; port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL); diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index d3a3fd9b109d..71abda209aa2 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -260,7 +260,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { /* we found a bulk in endpoint */ - buffer_size = endpoint->wMaxPacketSize; + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); dev->bulk_in_size = buffer_size; dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL); diff --git a/drivers/w1/dscore.c b/drivers/w1/dscore.c index 887d689e8c4f..284f378bb1b1 100644 --- a/drivers/w1/dscore.c +++ b/drivers/w1/dscore.c @@ -676,7 +676,7 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) ds_dev->ep[i+1] = endpoint->bEndpointAddress; printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", - i, endpoint->bEndpointAddress, endpoint->wMaxPacketSize, + i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); } diff --git a/include/linux/usb.h b/include/linux/usb.h index dd698c12b7ce..332e07e86b11 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1125,7 +1125,7 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out) return 0; /* NOTE: only 0x07ff bits are for packet size... */ - return ep->desc.wMaxPacketSize; + return le16_to_cpu(ep->desc.wMaxPacketSize); } /* -------------------------------------------------------------------------- */ diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h index d13b47bafcae..f08d6241fb63 100644 --- a/include/linux/usb_ch9.h +++ b/include/linux/usb_ch9.h @@ -264,7 +264,7 @@ struct usb_endpoint_descriptor { __u8 bEndpointAddress; __u8 bmAttributes; - __u16 wMaxPacketSize; + __le16 wMaxPacketSize; __u8 bInterval; // NOTE: these two are _only_ in audio endpoints. diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 087342ccbd22..ac1a5889752a 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -2450,7 +2450,7 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING && altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) || altsd->bNumEndpoints < 1 || - get_endpoint(alts, 0)->wMaxPacketSize == 0) + le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0) continue; /* must be isochronous */ if ((get_endpoint(alts, 0)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != @@ -2513,7 +2513,7 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; /* FIXME: decode wMaxPacketSize of high bandwith endpoints */ - fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize; + fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); fp->attributes = csep[3]; /* some quirks for attributes here */ @@ -2809,7 +2809,7 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, fp->iface = altsd->bInterfaceNumber; fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; - fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize; + fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); switch (fp->maxpacksize) { case 0x120: @@ -2875,7 +2875,7 @@ static int create_ua1000_quirk(snd_usb_audio_t *chip, struct usb_interface *ifac fp->iface = altsd->bInterfaceNumber; fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; - fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize; + fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); stream = (fp->endpoint & USB_DIR_IN) diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 85d6c5273417..bae3e1bff4b3 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -458,7 +458,7 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) ep = dev->ep_out[subs->endpoint]; if (!ep) return -EINVAL; - subs->maxpacksize = ep->desc.wMaxPacketSize; + subs->maxpacksize = le16_to_cpu(ep->desc.wMaxPacketSize); if (NULL == subs->tmpbuf) { subs->tmpbuf = kcalloc(NRPACKS, subs->maxpacksize, GFP_KERNEL); if (NULL == subs->tmpbuf) { @@ -471,7 +471,7 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) ep = dev->ep_in[subs->endpoint]; if (!ep) return -EINVAL; - subs->maxpacksize = ep->desc.wMaxPacketSize; + subs->maxpacksize = le16_to_cpu(ep->desc.wMaxPacketSize); } /* allocate and initialize data urbs */ -- cgit v1.2.3 From b86ab02803095190d6b72bcc18dcf620bf378df9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 20 Dec 2004 18:36:03 -0800 Subject: [PATCH] module sysfs: make module.mkobj inline Make module.mkobj inline. As this is simpler and what's usually done with kobjs when it's representing an entity. Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- include/linux/module.h | 2 +- kernel/module.c | 35 +++++++++++------------------------ kernel/params.c | 12 ++++-------- 3 files changed, 16 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/linux/module.h b/include/linux/module.h index c8dd7b8495c6..c1d709a317fd 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -250,7 +250,7 @@ struct module char name[MODULE_NAME_LEN]; /* Sysfs stuff. */ - struct module_kobject *mkobj; + struct module_kobject mkobj; struct param_kobject *params_kobject; /* Exported symbols */ diff --git a/kernel/module.c b/kernel/module.c index 0798443ce002..16208a97aadf 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -964,9 +964,6 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, unsigned int nloaded = 0, i; struct module_sect_attr *sattr; - if (!mod->mkobj) - return; - /* Count loaded sections and allocate structures */ for (i = 0; i < nsect; i++) if (sechdrs[i].sh_flags & SHF_ALLOC) @@ -980,7 +977,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, memset(mod->sect_attrs, 0, sizeof(struct module_sections)); if (kobject_set_name(&mod->sect_attrs->kobj, "sections")) goto out; - mod->sect_attrs->kobj.parent = &mod->mkobj->kobj; + mod->sect_attrs->kobj.parent = &mod->mkobj.kobj; mod->sect_attrs->kobj.ktype = &module_sect_ktype; if (kobject_register(&mod->sect_attrs->kobj)) goto out; @@ -1029,11 +1026,11 @@ static inline void remove_sect_attrs(struct module *mod) #ifdef CONFIG_MODULE_UNLOAD static inline int module_add_refcnt_attr(struct module *mod) { - return sysfs_create_file(&mod->mkobj->kobj, &refcnt.attr); + return sysfs_create_file(&mod->mkobj.kobj, &refcnt.attr); } static void module_remove_refcnt_attr(struct module *mod) { - return sysfs_remove_file(&mod->mkobj->kobj, &refcnt.attr); + return sysfs_remove_file(&mod->mkobj.kobj, &refcnt.attr); } #else static inline int module_add_refcnt_attr(struct module *mod) @@ -1052,17 +1049,13 @@ static int mod_sysfs_setup(struct module *mod, { int err; - mod->mkobj = kmalloc(sizeof(struct module_kobject), GFP_KERNEL); - if (!mod->mkobj) - return -ENOMEM; - - memset(&mod->mkobj->kobj, 0, sizeof(mod->mkobj->kobj)); - err = kobject_set_name(&mod->mkobj->kobj, "%s", mod->name); + memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj)); + err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name); if (err) goto out; - kobj_set_kset_s(mod->mkobj, module_subsys); - mod->mkobj->mod = mod; - err = kobject_register(&mod->mkobj->kobj); + kobj_set_kset_s(&mod->mkobj, module_subsys); + mod->mkobj.mod = mod; + err = kobject_register(&mod->mkobj.kobj); if (err) goto out; @@ -1077,11 +1070,8 @@ static int mod_sysfs_setup(struct module *mod, return 0; out_unreg: - /* Calls module_kobj_release */ - kobject_unregister(&mod->mkobj->kobj); - return err; + kobject_unregister(&mod->mkobj.kobj); out: - kfree(mod->mkobj); return err; } @@ -1090,8 +1080,7 @@ static void mod_kobject_remove(struct module *mod) module_remove_refcnt_attr(mod); module_param_sysfs_remove(mod); - /* Calls module_kobj_release */ - kobject_unregister(&mod->mkobj->kobj); + kobject_unregister(&mod->mkobj.kobj); } /* Free a module, remove from lists, etc (must hold module mutex). */ @@ -2089,11 +2078,9 @@ void module_add_driver(struct module *mod, struct device_driver *drv) { if (!mod || !drv) return; - if (!mod->mkobj) - return; /* Don't check return code; this call is idempotent */ - sysfs_create_link(&drv->kobj, &mod->mkobj->kobj, "module"); + sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); } EXPORT_SYMBOL(module_add_driver); diff --git a/kernel/params.c b/kernel/params.c index 45dd451e17c1..70d0868255e7 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -567,7 +567,7 @@ int module_param_sysfs_setup(struct module *mod, { struct param_kobject *pk; - pk = param_sysfs_setup(mod->mkobj, kparam, num_params, 0); + pk = param_sysfs_setup(&mod->mkobj, kparam, num_params, 0); if (IS_ERR(pk)) return PTR_ERR(pk); @@ -610,8 +610,10 @@ static void __init kernel_param_sysfs_setup(const char *name, kobject_register(&mk->kobj); /* no need to keep the kobject if no parameter is exported */ - if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) + if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) { kobject_unregister(&mk->kobj); + kfree(mk); + } } /* @@ -710,14 +712,8 @@ static struct sysfs_ops module_sysfs_ops = { }; #endif -static void module_kobj_release(struct kobject *kobj) -{ - kfree(container_of(kobj, struct module_kobject, kobj)); -} - static struct kobj_type module_ktype = { .sysfs_ops = &module_sysfs_ops, - .release = &module_kobj_release, }; decl_subsys(module, &module_ktype, NULL); -- cgit v1.2.3 From 6239c1cfe8b95d18533ca82d9b6d7cf7c55028a1 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 20 Dec 2004 18:36:20 -0800 Subject: [PATCH] module sysfs: expand module_attribute methods Modify module_attribute show/store methods to accept self argument to enable further extensions. Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- include/linux/module.h | 5 +++-- kernel/module.c | 3 ++- kernel/params.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/module.h b/include/linux/module.h index c1d709a317fd..a93281edc978 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -48,8 +48,9 @@ struct module; struct module_attribute { struct attribute attr; - ssize_t (*show)(struct module *, char *); - ssize_t (*store)(struct module *, const char *, size_t count); + ssize_t (*show)(struct module_attribute *, struct module *, char *); + ssize_t (*store)(struct module_attribute *, struct module *, + const char *, size_t count); }; struct module_kobject diff --git a/kernel/module.c b/kernel/module.c index 16208a97aadf..ad0e00e01ddd 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -651,7 +651,8 @@ void symbol_put_addr(void *addr) } EXPORT_SYMBOL_GPL(symbol_put_addr); -static ssize_t show_refcnt(struct module *mod, char *buffer) +static ssize_t show_refcnt(struct module_attribute *mattr, + struct module *mod, char *buffer) { /* sysfs holds a reference */ return sprintf(buffer, "%u\n", module_refcount(mod)-1); diff --git a/kernel/params.c b/kernel/params.c index 70d0868255e7..3fc1c9a805a3 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -693,7 +693,7 @@ static ssize_t module_attr_show(struct kobject *kobj, if (!try_module_get(mk->mod)) return -ENODEV; - ret = attribute->show(mk->mod, buf); + ret = attribute->show(attribute, mk->mod, buf); module_put(mk->mod); -- cgit v1.2.3 From 064840485854ee9deb170fd40b33cfdd1de7fa1a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 20 Dec 2004 18:36:35 -0800 Subject: [PATCH] module sysfs: sections attr reimplemented using attr group Reimplement section attributes using attribute group. This makes more sense, for, while they reside in a separate subdirectory, they belong to the ownig module and their lifetime exactly equals the lifetime of the owning module, and it's simpler. Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- include/linux/module.h | 8 +++--- kernel/module.c | 75 +++++++++++++++++++++++--------------------------- 2 files changed, 39 insertions(+), 44 deletions(-) (limited to 'include') diff --git a/include/linux/module.h b/include/linux/module.h index a93281edc978..a3f3117574dd 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -227,14 +227,14 @@ enum module_state #define MODULE_SECT_NAME_LEN 32 struct module_sect_attr { - struct attribute attr; + struct module_attribute mattr; char name[MODULE_SECT_NAME_LEN]; unsigned long address; }; -struct module_sections +struct module_sect_attrs { - struct kobject kobj; + struct attribute_group grp; struct module_sect_attr attrs[0]; }; @@ -313,7 +313,7 @@ struct module char *strtab; /* Section attributes */ - struct module_sections *sect_attrs; + struct module_sect_attrs *sect_attrs; #endif /* Per-cpu data. */ diff --git a/kernel/module.c b/kernel/module.c index ad0e00e01ddd..6247bf4ab003 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -937,76 +937,71 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, * J. Corbet */ #ifdef CONFIG_KALLSYMS -static void module_sect_attrs_release(struct kobject *kobj) -{ - kfree(container_of(kobj, struct module_sections, kobj)); -} - -static ssize_t module_sect_show(struct kobject *kobj, struct attribute *attr, - char *buf) +static ssize_t module_sect_show(struct module_attribute *mattr, + struct module *mod, char *buf) { struct module_sect_attr *sattr = - container_of(attr, struct module_sect_attr, attr); + container_of(mattr, struct module_sect_attr, mattr); return sprintf(buf, "0x%lx\n", sattr->address); } -static struct sysfs_ops module_sect_ops = { - .show = module_sect_show, -}; - -static struct kobj_type module_sect_ktype = { - .sysfs_ops = &module_sect_ops, - .release = module_sect_attrs_release, -}; - static void add_sect_attrs(struct module *mod, unsigned int nsect, char *secstrings, Elf_Shdr *sechdrs) { - unsigned int nloaded = 0, i; + unsigned int nloaded = 0, i, size[2]; + struct module_sect_attrs *sect_attrs; struct module_sect_attr *sattr; + struct attribute **gattr; /* Count loaded sections and allocate structures */ for (i = 0; i < nsect; i++) if (sechdrs[i].sh_flags & SHF_ALLOC) nloaded++; - mod->sect_attrs = kmalloc(sizeof(struct module_sections) + - nloaded*sizeof(mod->sect_attrs->attrs[0]), GFP_KERNEL); - if (! mod->sect_attrs) + size[0] = ALIGN(sizeof(*sect_attrs) + + nloaded * sizeof(sect_attrs->attrs[0]), + sizeof(sect_attrs->grp.attrs[0])); + size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.attrs[0]); + if (! (sect_attrs = kmalloc(size[0] + size[1], GFP_KERNEL))) return; - /* sections entry setup */ - memset(mod->sect_attrs, 0, sizeof(struct module_sections)); - if (kobject_set_name(&mod->sect_attrs->kobj, "sections")) - goto out; - mod->sect_attrs->kobj.parent = &mod->mkobj.kobj; - mod->sect_attrs->kobj.ktype = &module_sect_ktype; - if (kobject_register(&mod->sect_attrs->kobj)) - goto out; + /* Setup section attributes. */ + sect_attrs->grp.name = "sections"; + sect_attrs->grp.attrs = (void *)sect_attrs + size[0]; - /* And the section attributes. */ - sattr = &mod->sect_attrs->attrs[0]; + sattr = §_attrs->attrs[0]; + gattr = §_attrs->grp.attrs[0]; for (i = 0; i < nsect; i++) { if (! (sechdrs[i].sh_flags & SHF_ALLOC)) continue; sattr->address = sechdrs[i].sh_addr; strlcpy(sattr->name, secstrings + sechdrs[i].sh_name, - MODULE_SECT_NAME_LEN); - sattr->attr.name = sattr->name; - sattr->attr.owner = mod; - sattr->attr.mode = S_IRUGO; - (void) sysfs_create_file(&mod->sect_attrs->kobj, &sattr->attr); - sattr++; + MODULE_SECT_NAME_LEN); + sattr->mattr.show = module_sect_show; + sattr->mattr.store = NULL; + sattr->mattr.attr.name = sattr->name; + sattr->mattr.attr.owner = mod; + sattr->mattr.attr.mode = S_IRUGO; + *(gattr++) = &(sattr++)->mattr.attr; } + *gattr = NULL; + + if (sysfs_create_group(&mod->mkobj.kobj, §_attrs->grp)) + goto out; + + mod->sect_attrs = sect_attrs; return; out: - kfree(mod->sect_attrs); - mod->sect_attrs = NULL; + kfree(sect_attrs); } static void remove_sect_attrs(struct module *mod) { if (mod->sect_attrs) { - kobject_unregister(&mod->sect_attrs->kobj); + sysfs_remove_group(&mod->mkobj.kobj, + &mod->sect_attrs->grp); + /* We are positive that no one is using any sect attrs + * at this point. Deallocate immediately. */ + kfree(mod->sect_attrs); mod->sect_attrs = NULL; } } -- cgit v1.2.3 From fcf7104e3c6e9a4b2db96204e8f06efbe14cf258 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 20 Dec 2004 18:36:52 -0800 Subject: [PATCH] module sysfs: module parameters reimplemented using attr group Reimplement parameter attributes using attribute group. This makes more sense, for, while they reside in a separate subdirectory, they belong to the ownig module and their lifetime exactly equals the lifetime of the owning module, and it's simpler. Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- include/linux/module.h | 4 +- kernel/params.c | 179 +++++++++++++++---------------------------------- 2 files changed, 56 insertions(+), 127 deletions(-) (limited to 'include') diff --git a/include/linux/module.h b/include/linux/module.h index a3f3117574dd..159e8b9daa11 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -238,7 +238,7 @@ struct module_sect_attrs struct module_sect_attr attrs[0]; }; -struct param_kobject; +struct module_param_attrs; struct module { @@ -252,7 +252,7 @@ struct module /* Sysfs stuff. */ struct module_kobject mkobj; - struct param_kobject *params_kobject; + struct module_param_attrs *param_attrs; /* Exported symbols */ const struct kernel_symbol *syms; diff --git a/kernel/params.c b/kernel/params.c index 3fc1c9a805a3..a4888d7860ae 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -357,26 +357,23 @@ extern struct kernel_param __start___param[], __stop___param[]; struct param_attribute { - struct attribute attr; + struct module_attribute mattr; struct kernel_param *param; }; -struct param_kobject +struct module_param_attrs { - struct kobject kobj; - - unsigned int num_attributes; - struct param_attribute attr[0]; + struct attribute_group grp; + struct param_attribute attrs[0]; }; -#define to_param_attr(n) container_of(n, struct param_attribute, attr); +#define to_param_attr(n) container_of(n, struct param_attribute, mattr); -static ssize_t param_attr_show(struct kobject *kobj, - struct attribute *attr, - char *buf) +static ssize_t param_attr_show(struct module_attribute *mattr, + struct module *mod, char *buf) { int count; - struct param_attribute *attribute = to_param_attr(attr); + struct param_attribute *attribute = to_param_attr(mattr); if (!attribute->param->get) return -EPERM; @@ -390,12 +387,12 @@ static ssize_t param_attr_show(struct kobject *kobj, } /* sysfs always hands a nul-terminated string in buf. We rely on that. */ -static ssize_t param_attr_store(struct kobject *kobj, - struct attribute *attr, +static ssize_t param_attr_store(struct module_attribute *mattr, + struct module *owner, const char *buf, size_t len) { int err; - struct param_attribute *attribute = to_param_attr(attr); + struct param_attribute *attribute = to_param_attr(mattr); if (!attribute->param->set) return -EPERM; @@ -406,81 +403,12 @@ static ssize_t param_attr_store(struct kobject *kobj, return err; } - -static struct sysfs_ops param_sysfs_ops = { - .show = param_attr_show, - .store = param_attr_store, -}; - -static void param_kobj_release(struct kobject *kobj) -{ - kfree(container_of(kobj, struct param_kobject, kobj)); -} - -static struct kobj_type param_ktype = { - .sysfs_ops = ¶m_sysfs_ops, - .release = ¶m_kobj_release, -}; - -static struct kset param_kset = { - .subsys = &module_subsys, - .ktype = ¶m_ktype, -}; - #ifdef CONFIG_MODULES #define __modinit #else #define __modinit __init #endif -/* - * param_add_attribute - actually adds an parameter to sysfs - * @mod: owner of parameter - * @pk: param_kobject the attribute shall be assigned to. - * One per module, one per KBUILD_MODNAME. - * @kp: kernel_param to be added - * @skip: offset where the parameter name start in kp->name. - * Needed for built-in modules - * - * Fill in data into appropriate &pk->attr[], and create sysfs file. - */ -static __modinit int param_add_attribute(struct module *mod, - struct param_kobject *pk, - struct kernel_param *kp, - unsigned int skip) -{ - struct param_attribute *a; - int err; - - a = &pk->attr[pk->num_attributes]; - a->attr.name = (char *) &kp->name[skip]; - a->attr.owner = mod; - a->attr.mode = kp->perm; - a->param = kp; - err = sysfs_create_file(&pk->kobj, &a->attr); - if (!err) - pk->num_attributes++; - return err; -} - -/* - * param_sysfs_remove - remove sysfs support for one module or KBUILD_MODNAME - * @pk: struct param_kobject which is to be removed - * - * Called when an error in registration occurs or a module is removed - * from the system. - */ -static __modinit void param_sysfs_remove(struct param_kobject *pk) -{ - unsigned int i; - for (i = 0; i < pk->num_attributes; i++) - sysfs_remove_file(&pk->kobj,&pk->attr[i].attr); - - /* Calls param_kobj_release */ - kobject_unregister(&pk->kobj); -} - - /* * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME * @mk: struct module_kobject (contains parent kobject) @@ -492,15 +420,17 @@ static __modinit void param_sysfs_remove(struct param_kobject *pk) * in sysfs. A pointer to the param_kobject is returned on success, * NULL if there's no parameter to export, or other ERR_PTR(err). */ -static __modinit struct param_kobject * +static __modinit struct module_param_attrs * param_sysfs_setup(struct module_kobject *mk, struct kernel_param *kparam, unsigned int num_params, unsigned int name_skip) { - struct param_kobject *pk; + struct module_param_attrs *mp; unsigned int valid_attrs = 0; - unsigned int i; + unsigned int i, size[2]; + struct param_attribute *pattr; + struct attribute **gattr; int err; for (i=0; iattrs[0]), + sizeof(mp->grp.attrs[0])); + size[1] = (valid_attrs + 1) * sizeof(mp->grp.attrs[0]); - err = kobject_set_name(&pk->kobj, "parameters"); - if (err) - goto out; + mp = kmalloc(size[0] + size[1], GFP_KERNEL); + if (!mp) + return ERR_PTR(-ENOMEM); - pk->kobj.kset = ¶m_kset; - pk->kobj.parent = &mk->kobj; - err = kobject_register(&pk->kobj); - if (err) - goto out; + mp->grp.name = "parameters"; + mp->grp.attrs = (void *)mp + size[0]; + pattr = &mp->attrs[0]; + gattr = &mp->grp.attrs[0]; for (i = 0; i < num_params; i++) { - if (kparam[i].perm) { - err = param_add_attribute(mk->mod, pk, - &kparam[i], name_skip); - if (err) - goto out_unreg; + struct kernel_param *kp = &kparam[i]; + if (kp->perm) { + pattr->param = kp; + pattr->mattr.show = param_attr_show; + pattr->mattr.store = param_attr_store; + pattr->mattr.attr.name = (char *)&kp->name[name_skip]; + pattr->mattr.attr.owner = mk->mod; + pattr->mattr.attr.mode = kp->perm; + *(gattr++) = &(pattr++)->mattr.attr; } } + *gattr = NULL; - return pk; - -out_unreg: - param_sysfs_remove(pk); - return ERR_PTR(err); - -out: - kfree(pk); - return ERR_PTR(err); + if ((err = sysfs_create_group(&mk->kobj, &mp->grp))) { + kfree(mp); + return ERR_PTR(err); + } + return mp; } @@ -565,13 +492,13 @@ int module_param_sysfs_setup(struct module *mod, struct kernel_param *kparam, unsigned int num_params) { - struct param_kobject *pk; + struct module_param_attrs *mp; - pk = param_sysfs_setup(&mod->mkobj, kparam, num_params, 0); - if (IS_ERR(pk)) - return PTR_ERR(pk); + mp = param_sysfs_setup(&mod->mkobj, kparam, num_params, 0); + if (IS_ERR(mp)) + return PTR_ERR(mp); - mod->params_kobject = pk; + mod->param_attrs = mp; return 0; } @@ -584,9 +511,13 @@ int module_param_sysfs_setup(struct module *mod, */ void module_param_sysfs_remove(struct module *mod) { - if (mod->params_kobject) { - param_sysfs_remove(mod->params_kobject); - mod->params_kobject = NULL; + if (mod->param_attrs) { + sysfs_remove_group(&mod->mkobj.kobj, + &mod->param_attrs->grp); + /* We are positive that no one is using any param + * attrs at this point. Deallocate immediately. */ + kfree(mod->param_attrs); + mod->param_attrs = NULL; } } #endif @@ -724,8 +655,6 @@ decl_subsys(module, &module_ktype, NULL); static int __init param_sysfs_init(void) { subsystem_register(&module_subsys); - kobject_set_name(¶m_kset.kobj, "parameters"); - kset_init(¶m_kset); param_sysfs_builtin(); -- cgit v1.2.3 From 9df7c5fcecfa1a0fb844232e3b12d2b4c690741c Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 20 Dec 2004 18:37:07 -0800 Subject: [PATCH] sysfs: add mmap support to struct bin_attribute files This patch adds an mmap method and some more error checking to struct bin_attribute--good for things like exporting PCI resources directly. I wasn't sure about the return values for the case where an attribute is missing a given method, and it looks like mm.h can't be included in sysfs.h, so I had to forward declare struct vm_area_struct. Other than that, it works fine for my test cases. Signed-off-by: Jesse Barnes Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/bin.c | 27 +++++++++++++++++++++++++-- include/linux/sysfs.h | 6 ++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 1ce077888aec..d4aaa88d0214 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c @@ -1,5 +1,9 @@ /* * bin.c - binary file operations for sysfs. + * + * Copyright (c) 2003 Patrick Mochel + * Copyright (c) 2003 Matthew Wilcox + * Copyright (c) 2004 Silicon Graphics, Inc. */ #undef DEBUG @@ -20,6 +24,9 @@ fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) struct bin_attribute * attr = to_bin_attr(dentry); struct kobject * kobj = to_kobj(dentry->d_parent); + if (!attr->read) + return -EINVAL; + return attr->read(kobj, buffer, off, count); } @@ -63,6 +70,9 @@ flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) struct bin_attribute *attr = to_bin_attr(dentry); struct kobject *kobj = to_kobj(dentry->d_parent); + if (!attr->write) + return -EINVAL; + return attr->write(kobj, buffer, offset, count); } @@ -92,6 +102,18 @@ static ssize_t write(struct file * file, const char __user * userbuf, return count; } +static int mmap(struct file *file, struct vm_area_struct *vma) +{ + struct dentry *dentry = file->f_dentry; + struct bin_attribute *attr = to_bin_attr(dentry); + struct kobject *kobj = to_kobj(dentry->d_parent); + + if (!attr->mmap) + return -EINVAL; + + return attr->mmap(kobj, attr, vma); +} + static int open(struct inode * inode, struct file * file) { struct kobject *kobj = sysfs_get_kobject(file->f_dentry->d_parent); @@ -107,9 +129,9 @@ static int open(struct inode * inode, struct file * file) goto Done; error = -EACCES; - if ((file->f_mode & FMODE_WRITE) && !attr->write) + if ((file->f_mode & FMODE_WRITE) && !(attr->write || attr->mmap)) goto Error; - if ((file->f_mode & FMODE_READ) && !attr->read) + if ((file->f_mode & FMODE_READ) && !(attr->read || attr->mmap)) goto Error; error = -ENOMEM; @@ -144,6 +166,7 @@ static int release(struct inode * inode, struct file * file) struct file_operations bin_fops = { .read = read, .write = write, + .mmap = mmap, .llseek = generic_file_llseek, .open = open, .release = release, diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index d12ee2b1eaef..6f502ff7902a 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -2,6 +2,7 @@ * sysfs.h - definitions for the device driver filesystem * * Copyright (c) 2001,2002 Patrick Mochel + * Copyright (c) 2004 Silicon Graphics, Inc. * * Please see Documentation/filesystems/sysfs.txt for more information. */ @@ -47,11 +48,16 @@ struct attribute_group { #define attr_name(_attr) (_attr).attr.name +struct vm_area_struct; + struct bin_attribute { struct attribute attr; size_t size; + void *private; ssize_t (*read)(struct kobject *, char *, loff_t, size_t); ssize_t (*write)(struct kobject *, char *, loff_t, size_t); + int (*mmap)(struct kobject *, struct bin_attribute *attr, + struct vm_area_struct *vma); }; struct sysfs_ops { -- cgit v1.2.3 From fc1e0463ef36d066223156996f8657cd082e6eb0 Mon Sep 17 00:00:00 2001 From: "Ed L. Cashin" Date: Mon, 20 Dec 2004 18:50:37 -0800 Subject: [PATCH] rename ETH_P_AOE Rename old ETH_P_EDP2 ("EtherDrive Protocol 2") to ETH_P_AOE (ATA over Ethernet). Signed-off-by: Ed L. Cashin Signed-off-by: Greg Kroah-Hartman --- drivers/block/aoe/aoe.h | 1 - include/linux/if_ether.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index f27b5b6c0167..ef6bcdf19b2f 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h @@ -26,7 +26,6 @@ enum { AOECCMD_FSET, AOE_HVER = 0x10, - ETH_P_AOE = 0x88a2, }; struct aoe_hdr { diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h index 4037aaab7aa9..53390b6ab2d6 100644 --- a/include/linux/if_ether.h +++ b/include/linux/if_ether.h @@ -69,7 +69,7 @@ #define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport * over Ethernet */ -#define ETH_P_EDP2 0x88A2 /* Coraid EDP2 */ +#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ /* * Non DIX types. Won't clash for 1500 types. -- cgit v1.2.3 From 4e512312c1129a37427bc5af139661c1dc49c681 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 20 Dec 2004 19:08:03 -0800 Subject: [PATCH] I2C: Use PCI_DEVICE in bus drivers > Hint, the PCI_DEVICE() macro makes this a lot simpler :) What about this cleanup patch then? It generalizes the use of PCI_DEVICE() among i2c/busses drivers (with some pci ids cleanups for free). Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-ali1535.c | 7 +--- drivers/i2c/busses/i2c-ali1563.c | 7 +--- drivers/i2c/busses/i2c-ali15x3.c | 7 +--- drivers/i2c/busses/i2c-amd756.c | 15 +++++--- drivers/i2c/busses/i2c-amd8111.c | 2 +- drivers/i2c/busses/i2c-hydra.c | 7 +--- drivers/i2c/busses/i2c-i801.c | 56 +++++------------------------ drivers/i2c/busses/i2c-nforce2.c | 12 +++---- drivers/i2c/busses/i2c-piix4.c | 54 +++++++--------------------- drivers/i2c/busses/i2c-prosavage.c | 7 ---- drivers/i2c/busses/i2c-sis96x.c | 12 +------ drivers/i2c/busses/i2c-viapro.c | 72 +++++++++----------------------------- include/linux/pci_ids.h | 6 ++++ 13 files changed, 62 insertions(+), 202 deletions(-) (limited to 'include') diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index dcc9365676d0..b00cd4098221 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c @@ -487,12 +487,7 @@ static struct i2c_adapter ali1535_adapter = { }; static struct pci_device_id ali1535_ids[] = { - { - .vendor = PCI_VENDOR_ID_AL, - .device = PCI_DEVICE_ID_AL_M7101, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, + { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, { }, }; diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index b3ee9a812bee..1ca7694315ff 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c @@ -385,12 +385,7 @@ static void __exit ali1563_remove(struct pci_dev * dev) } static struct pci_device_id __devinitdata ali1563_id_table[] = { - { - .vendor = PCI_VENDOR_ID_AL, - .device = PCI_DEVICE_ID_AL_M1563, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, + { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1563) }, {}, }; diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 8e13b8341971..5bd6a4a77c1e 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -477,12 +477,7 @@ static struct i2c_adapter ali15x3_adapter = { }; static struct pci_device_id ali15x3_ids[] = { - { - .vendor = PCI_VENDOR_ID_AL, - .device = PCI_DEVICE_ID_AL_M7101, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, + { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 35a1835193c8..eca5ed3738b8 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -316,11 +316,16 @@ static const char* chipname[] = { }; static struct pci_device_id amd756_ids[] = { - {PCI_VENDOR_ID_AMD, 0x740B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD756 }, - {PCI_VENDOR_ID_AMD, 0x7413, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD766 }, - {PCI_VENDOR_ID_AMD, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD768 }, - {PCI_VENDOR_ID_AMD, 0x746B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD8111 }, - {PCI_VENDOR_ID_NVIDIA, 0x01B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_740B), + .driver_data = AMD756 }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7413), + .driver_data = AMD766 }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7443), + .driver_data = AMD768 }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS), + .driver_data = AMD8111 }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS), + .driver_data = NFORCE }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 5eb4d38bcf9d..af22b401a38b 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -332,7 +332,7 @@ static struct i2c_algorithm smbus_algorithm = { static struct pci_device_id amd8111_ids[] = { - { 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS2) }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index 7480fd0b4e69..e0cb3b0f92fa 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c @@ -111,12 +111,7 @@ static struct i2c_adapter hydra_adap = { }; static struct pci_device_id hydra_ids[] = { - { - .vendor = PCI_VENDOR_ID_APPLE, - .device = PCI_DEVICE_ID_APPLE_HYDRA, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, + { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_HYDRA) }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 8d6ec1525735..b4acf8891281 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -548,54 +548,14 @@ static struct i2c_adapter i801_adapter = { }; static struct pci_device_id i801_ids[] = { - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801AA_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801AB_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801BA_2, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801CA_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801DB_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801EB_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_ESB_4, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_ICH6_16, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_3) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_3) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_3) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_4) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_16) }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 2cf9a75badd8..b2b6081327d8 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -291,14 +291,10 @@ static u32 nforce2_func(struct i2c_adapter *adapter) static struct pci_device_id nforce2_ids[] = { - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS) }, { 0 } }; diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 8bb467ade222..646381b6b3bf 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -414,48 +414,18 @@ static struct i2c_adapter piix4_adapter = { }; static struct pci_device_id piix4_ids[] = { - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82371AB_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 3 - }, - { - .vendor = PCI_VENDOR_ID_SERVERWORKS, - .device = PCI_DEVICE_ID_SERVERWORKS_OSB4, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 0, - }, - { - .vendor = PCI_VENDOR_ID_SERVERWORKS, - .device = PCI_DEVICE_ID_SERVERWORKS_CSB5, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 0, - }, - { - .vendor = PCI_VENDOR_ID_SERVERWORKS, - .device = PCI_DEVICE_ID_SERVERWORKS_CSB6, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 0, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82443MX_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 3, - }, - { - .vendor = PCI_VENDOR_ID_EFAR, - .device = PCI_DEVICE_ID_EFAR_SLC90E66_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 0, - }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3), + .driver_data = 3 }, + { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4), + .driver_data = 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5), + .driver_data = 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6), + .driver_data = 0 }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3), + .driver_data = 3 }, + { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3), + .driver_data = 0 }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index f5804568b57d..13d66289933b 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c @@ -96,13 +96,6 @@ struct s_i2c_chip { /* * S3/VIA 8365/8375 registers */ -#ifndef PCI_DEVICE_ID_S3_SAVAGE4 -#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 -#endif -#ifndef PCI_DEVICE_ID_S3_PROSAVAGE8 -#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 -#endif - #define VGA_CR_IX 0x3d4 #define VGA_CR_DATA 0x3d5 diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 69a2e7d7e44e..3cac6d43bce5 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c @@ -51,9 +51,6 @@ */ #define SIS96x_VERSION "1.0.0" -/* SiS96x SMBus PCI device ID */ -#define PCI_DEVICE_ID_SI_SMBUS 0x16 - /* base address register in PCI config space */ #define SIS96x_BAR 0x04 @@ -267,14 +264,7 @@ static struct i2c_adapter sis96x_adapter = { }; static struct pci_device_id sis96x_ids[] = { - - { - .vendor = PCI_VENDOR_ID_SI, - .device = PCI_DEVICE_ID_SI_SMBUS, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - }, - + { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_SMBUS) }, { 0, } }; diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 83a77ba976b0..d86cdc6524e7 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -395,62 +395,22 @@ static void __devexit vt596_remove(struct pci_dev *pdev) } static struct pci_device_id vt596_ids[] = { - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_82C596_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA1, - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_82C596B_3, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA1, - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_82C686_4, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA1, - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_8233_0, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA3 - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_8233A, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA3, - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_8235, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA3 - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_8237, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA3 - }, - { - .vendor = PCI_VENDOR_ID_VIA, - .device = PCI_DEVICE_ID_VIA_8231_4, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = SMBBA1, - }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596_3), + .driver_data = SMBBA1 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596B_3), + .driver_data = SMBBA1 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4), + .driver_data = SMBBA1 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_0), + .driver_data = SMBBA3 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233A), + .driver_data = SMBBA3 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235), + .driver_data = SMBBA3 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237), + .driver_data = SMBBA3 }, + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4), + .driver_data = SMBBA1 }, { 0, } }; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 38bf9f395629..3b0624474956 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -496,6 +496,8 @@ # define PCI_DEVICE_ID_AMD_VIPER_7449 PCI_DEVICE_ID_AMD_OPUS_7449 #define PCI_DEVICE_ID_AMD_8111_LAN 0x7462 #define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 +#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a +#define PCI_DEVICE_ID_AMD_8111_SMBUS 0x746b #define PCI_DEVICE_ID_AMD_8111_AUDIO 0x746d #define PCI_DEVICE_ID_AMD_8151_0 0x7454 #define PCI_DEVICE_ID_AMD_8131_APIC 0x7450 @@ -585,6 +587,7 @@ #define PCI_DEVICE_ID_SI_6202 0x0002 #define PCI_DEVICE_ID_SI_503 0x0008 #define PCI_DEVICE_ID_SI_ACPI 0x0009 +#define PCI_DEVICE_ID_SI_SMBUS 0x0016 #define PCI_DEVICE_ID_SI_LPC 0x0018 #define PCI_DEVICE_ID_SI_5597_VGA 0x0200 #define PCI_DEVICE_ID_SI_6205 0x0205 @@ -1133,6 +1136,7 @@ #define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0 #define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 #define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 +#define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 #define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc #define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 #define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 @@ -2048,9 +2052,11 @@ #define PCI_DEVICE_ID_S3_PLATO_PXG 0x8902 #define PCI_DEVICE_ID_S3_ViRGE_DXGX 0x8a01 #define PCI_DEVICE_ID_S3_ViRGE_GX2 0x8a10 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 #define PCI_DEVICE_ID_S3_ViRGE_MX 0x8c01 #define PCI_DEVICE_ID_S3_ViRGE_MXP 0x8c02 #define PCI_DEVICE_ID_S3_ViRGE_MXPMV 0x8c03 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 #define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 #define PCI_VENDOR_ID_DUNORD 0x5544 -- cgit v1.2.3 From dd13e88a15c5a0bf8e7005de204823bb6eef7ef9 Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Mon, 20 Dec 2004 19:08:43 -0800 Subject: [PATCH] I2C patch from MIPS tree... Here is a newer i2c patch from the mainline Linux/MIPS kernel tree. Some more changes came in since yesterday. Please apply this for inclusion in the next Linux release. Thanks. Signed-off-by: Steven J. Hill Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/Kconfig | 13 ++ drivers/i2c/algos/Makefile | 2 + drivers/i2c/algos/i2c-algo-sgi.c | 189 +++++++++++++++++++++++++++++ drivers/i2c/algos/i2c-algo-sibyte.c | 231 ++++++++++++++++++++++++++++++++++++ drivers/i2c/busses/Kconfig | 6 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-sibyte.c | 71 +++++++++++ include/linux/i2c-algo-sgi.h | 27 +++++ include/linux/i2c-algo-sibyte.h | 33 ++++++ include/linux/i2c-id.h | 11 ++ 10 files changed, 584 insertions(+) create mode 100644 drivers/i2c/algos/i2c-algo-sgi.c create mode 100644 drivers/i2c/algos/i2c-algo-sibyte.c create mode 100644 drivers/i2c/busses/i2c-sibyte.c create mode 100644 include/linux/i2c-algo-sgi.h create mode 100644 include/linux/i2c-algo-sibyte.h (limited to 'include') diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig index cf9832bdc746..f13482f9eff2 100644 --- a/drivers/i2c/algos/Kconfig +++ b/drivers/i2c/algos/Kconfig @@ -53,5 +53,18 @@ config I2C_ALGO8XX tristate "MPC8xx CPM I2C interface" depends on 8xx && I2C +config I2C_ALGO_SIBYTE + tristate "SiByte SMBus interface" + depends on SIBYTE_SB1xxx_SOC && I2C + help + Supports the SiByte SOC on-chip I2C interfaces (2 channels). + +config I2C_ALGO_SGI + tristate "I2C SGI interfaces" + depends on I2C + help + Supports the SGI interfaces like the ones found on SGI Indy VINO + or SGI O2 MACE. + endmenu diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile index 3545644be0f6..867fe1f67401 100644 --- a/drivers/i2c/algos/Makefile +++ b/drivers/i2c/algos/Makefile @@ -6,6 +6,8 @@ obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o +obj-$(CONFIG_I2C_ALGO_SIBYTE) += i2c-algo-sibyte.o +obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) EXTRA_CFLAGS += -DDEBUG diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c new file mode 100644 index 000000000000..b4e0a065b78b --- /dev/null +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -0,0 +1,189 @@ +/* + * i2c-algo-sgi.c: i2c driver algorithms for SGI adapters. + * + * This file is subject to the terms and conditions of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * Copyright (C) 2003 Ladislav Michl + */ + +#include +#include +#include +#include +#include + +#include +#include + + +#define SGI_I2C_FORCE_IDLE (0 << 0) +#define SGI_I2C_NOT_IDLE (1 << 0) +#define SGI_I2C_WRITE (0 << 1) +#define SGI_I2C_READ (1 << 1) +#define SGI_I2C_RELEASE_BUS (0 << 2) +#define SGI_I2C_HOLD_BUS (1 << 2) +#define SGI_I2C_XFER_DONE (0 << 4) +#define SGI_I2C_XFER_BUSY (1 << 4) +#define SGI_I2C_ACK (0 << 5) +#define SGI_I2C_NACK (1 << 5) +#define SGI_I2C_BUS_OK (0 << 7) +#define SGI_I2C_BUS_ERR (1 << 7) + +#define get_control() adap->getctrl(adap->data) +#define set_control(val) adap->setctrl(adap->data, val) +#define read_data() adap->rdata(adap->data) +#define write_data(val) adap->wdata(adap->data, val) + + +static int wait_xfer_done(struct i2c_algo_sgi_data *adap) +{ + int i; + + for (i = 0; i < adap->xfer_timeout; i++) { + if ((get_control() & SGI_I2C_XFER_BUSY) == 0) + return 0; + udelay(1); + } + + return -ETIMEDOUT; +} + +static int wait_ack(struct i2c_algo_sgi_data *adap) +{ + int i; + + if (wait_xfer_done(adap)) + return -ETIMEDOUT; + for (i = 0; i < adap->ack_timeout; i++) { + if ((get_control() & SGI_I2C_NACK) == 0) + return 0; + udelay(1); + } + + return -ETIMEDOUT; +} + +static int force_idle(struct i2c_algo_sgi_data *adap) +{ + int i; + + set_control(SGI_I2C_FORCE_IDLE); + for (i = 0; i < adap->xfer_timeout; i++) { + if ((get_control() & SGI_I2C_NOT_IDLE) == 0) + goto out; + udelay(1); + } + return -ETIMEDOUT; +out: + if (get_control() & SGI_I2C_BUS_ERR) + return -EIO; + return 0; +} + +static int do_address(struct i2c_algo_sgi_data *adap, unsigned int addr, + int rd) +{ + if (rd) + set_control(SGI_I2C_NOT_IDLE); + /* Check if bus is idle, eventually force it to do so */ + if (get_control() & SGI_I2C_NOT_IDLE) + if (force_idle(adap)) + return -EIO; + /* Write out the i2c chip address and specify operation */ + set_control(SGI_I2C_HOLD_BUS | SGI_I2C_WRITE | SGI_I2C_NOT_IDLE); + if (rd) + addr |= 1; + write_data(addr); + if (wait_ack(adap)) + return -EIO; + return 0; +} + +static int i2c_read(struct i2c_algo_sgi_data *adap, unsigned char *buf, + unsigned int len) +{ + int i; + + set_control(SGI_I2C_HOLD_BUS | SGI_I2C_READ | SGI_I2C_NOT_IDLE); + for (i = 0; i < len; i++) { + if (wait_xfer_done(adap)) + return -EIO; + buf[i] = read_data(); + } + set_control(SGI_I2C_RELEASE_BUS | SGI_I2C_FORCE_IDLE); + + return 0; + +} + +static int i2c_write(struct i2c_algo_sgi_data *adap, unsigned char *buf, + unsigned int len) +{ + int i; + + /* We are already in write state */ + for (i = 0; i < len; i++) { + write_data(buf[i]); + if (wait_ack(adap)) + return -EIO; + } + return 0; +} + +static int sgi_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], + int num) +{ + struct i2c_algo_sgi_data *adap = i2c_adap->algo_data; + struct i2c_msg *p; + int i, err = 0; + + for (i = 0; !err && i < num; i++) { + p = &msgs[i]; + err = do_address(adap, p->addr, p->flags & I2C_M_RD); + if (err || !p->len) + continue; + if (p->flags & I2C_M_RD) + err = i2c_read(adap, p->buf, p->len); + else + err = i2c_write(adap, p->buf, p->len); + } + + return err; +} + +static u32 sgi_func(struct i2c_adapter *adap) +{ + return I2C_FUNC_SMBUS_EMUL; +} + +static struct i2c_algorithm sgi_algo = { + .name = "SGI algorithm", + .id = I2C_ALGO_SGI, + .master_xfer = sgi_xfer, + .functionality = sgi_func, +}; + +/* + * registering functions to load algorithms at runtime + */ +int i2c_sgi_add_bus(struct i2c_adapter *adap) +{ + adap->id |= sgi_algo.id; + adap->algo = &sgi_algo; + + return i2c_add_adapter(adap); +} + + +int i2c_sgi_del_bus(struct i2c_adapter *adap) +{ + return i2c_del_adapter(adap); +} + +EXPORT_SYMBOL(i2c_sgi_add_bus); +EXPORT_SYMBOL(i2c_sgi_del_bus); + +MODULE_AUTHOR("Ladislav Michl "); +MODULE_DESCRIPTION("I2C-Bus SGI algorithm"); +MODULE_LICENSE("GPL"); diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c new file mode 100644 index 000000000000..e4d41caf0b26 --- /dev/null +++ b/drivers/i2c/algos/i2c-algo-sibyte.c @@ -0,0 +1,231 @@ +/* ------------------------------------------------------------------------- */ +/* i2c-algo-sibyte.c i2c driver algorithms for bit-shift adapters */ +/* ------------------------------------------------------------------------- */ +/* Copyright (C) 2001,2002,2003 Broadcom Corporation + Copyright (C) 1995-2000 Simon G. Vogl + + 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. */ +/* ------------------------------------------------------------------------- */ + +/* With some changes from Kyösti Mälkki and even + Frodo Looijaard . */ + +/* Ported for SiByte SOCs by Broadcom Corporation. */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +/* ----- global defines ----------------------------------------------- */ +#define SMB_CSR(a,r) ((long)(a->reg_base + r)) + +/* ----- global variables --------------------------------------------- */ + +/* module parameters: + */ +static int bit_scan=0; /* have a look at what's hanging 'round */ + + +static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, + unsigned short flags, char read_write, + u8 command, int size, union i2c_smbus_data * data) +{ + struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; + int data_bytes = 0; + int error; + + while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY) + ; + + switch (size) { + case I2C_SMBUS_QUICK: + csr_out32((V_SMB_ADDR(addr) | (read_write == I2C_SMBUS_READ ? M_SMB_QDATA : 0) | + V_SMB_TT_QUICKCMD), SMB_CSR(adap, R_SMB_START)); + break; + case I2C_SMBUS_BYTE: + if (read_write == I2C_SMBUS_READ) { + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_RD1BYTE), + SMB_CSR(adap, R_SMB_START)); + data_bytes = 1; + } else { + csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR1BYTE), + SMB_CSR(adap, R_SMB_START)); + } + break; + case I2C_SMBUS_BYTE_DATA: + csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); + if (read_write == I2C_SMBUS_READ) { + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD1BYTE), + SMB_CSR(adap, R_SMB_START)); + data_bytes = 1; + } else { + csr_out32(V_SMB_LB(data->byte), SMB_CSR(adap, R_SMB_DATA)); + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE), + SMB_CSR(adap, R_SMB_START)); + } + break; + case I2C_SMBUS_WORD_DATA: + csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); + if (read_write == I2C_SMBUS_READ) { + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD2BYTE), + SMB_CSR(adap, R_SMB_START)); + data_bytes = 2; + } else { + csr_out32(V_SMB_LB(data->word & 0xff), SMB_CSR(adap, R_SMB_DATA)); + csr_out32(V_SMB_MB(data->word >> 8), SMB_CSR(adap, R_SMB_DATA)); + csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE), + SMB_CSR(adap, R_SMB_START)); + } + break; + default: + return -1; /* XXXKW better error code? */ + } + + while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY) + ; + + error = csr_in32(SMB_CSR(adap, R_SMB_STATUS)); + if (error & M_SMB_ERROR) { + /* Clear error bit by writing a 1 */ + csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS)); + return -1; /* XXXKW better error code? */ + } + + if (data_bytes == 1) + data->byte = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xff; + if (data_bytes == 2) + data->word = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xffff; + + return 0; +} + +static int algo_control(struct i2c_adapter *adapter, + unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static u32 bit_func(struct i2c_adapter *adap) +{ + return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA); +} + + +/* -----exported algorithm data: ------------------------------------- */ + +static struct i2c_algorithm i2c_sibyte_algo = { + "SiByte algorithm", + I2C_ALGO_SIBYTE, + NULL, /* master_xfer */ + smbus_xfer, /* smbus_xfer */ + NULL, /* slave_xmit */ + NULL, /* slave_recv */ + algo_control, /* ioctl */ + bit_func, /* functionality */ +}; + +/* + * registering functions to load algorithms at runtime + */ +int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) +{ + int i; + struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; + + /* register new adapter to i2c module... */ + + i2c_adap->id |= i2c_sibyte_algo.id; + i2c_adap->algo = &i2c_sibyte_algo; + + /* Set the frequency to 100 kHz */ + csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); + csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); + + /* scan bus */ + if (bit_scan) { + union i2c_smbus_data data; + int rc; + printk(KERN_INFO " i2c-algo-sibyte.o: scanning bus %s.\n", + i2c_adap->name); + for (i = 0x00; i < 0x7f; i++) { + /* XXXKW is this a realistic probe? */ + rc = smbus_xfer(i2c_adap, i, 0, I2C_SMBUS_READ, 0, + I2C_SMBUS_BYTE_DATA, &data); + if (!rc) { + printk("(%02x)",i); + } else + printk("."); + } + printk("\n"); + } + +#ifdef MODULE + MOD_INC_USE_COUNT; +#endif + i2c_add_adapter(i2c_adap); + + return 0; +} + + +int i2c_sibyte_del_bus(struct i2c_adapter *adap) +{ + int res; + + if ((res = i2c_del_adapter(adap)) < 0) + return res; + +#ifdef MODULE + MOD_DEC_USE_COUNT; +#endif + return 0; +} + +int __init i2c_algo_sibyte_init (void) +{ + printk("i2c-algo-sibyte.o: i2c SiByte algorithm module\n"); + return 0; +} + + +EXPORT_SYMBOL(i2c_sibyte_add_bus); +EXPORT_SYMBOL(i2c_sibyte_del_bus); + +#ifdef MODULE +MODULE_AUTHOR("Kip Walker, Broadcom Corp."); +MODULE_DESCRIPTION("SiByte I2C-Bus algorithm"); +MODULE_PARM(bit_scan, "i"); +MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus"); +MODULE_LICENSE("GPL"); + +int init_module(void) +{ + return i2c_algo_sibyte_init(); +} + +void cleanup_module(void) +{ +} +#endif diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index d0e7da45523a..14bedba48216 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -323,6 +323,12 @@ config I2C_SAVAGE4 This driver can also be built as a module. If so, the module will be called i2c-savage4. +config I2C_SIBYTE + tristate "SiByte SMBus interface" + depends on SIBYTE_SB1xxx_SOC && I2C + help + Supports the SiByte SOC on-chip I2C interfaces (2 channels). + config SCx200_I2C tristate "NatSemi SCx200 I2C using GPIO pins" depends on SCx200_GPIO && I2C diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index e414a1d1ec77..fd58b2e609a3 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o +obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c new file mode 100644 index 000000000000..e5dd90bdb04a --- /dev/null +++ b/drivers/i2c/busses/i2c-sibyte.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2004 Steven J. Hill + * Copyright (C) 2001,2002,2003 Broadcom Corporation + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include + +static struct i2c_algo_sibyte_data sibyte_board_data[2] = { + { NULL, 0, (void *) (KSEG1+A_SMB_BASE(0)) }, + { NULL, 1, (void *) (KSEG1+A_SMB_BASE(1)) } +}; + +static struct i2c_adapter sibyte_board_adapter[2] = { + { + .owner = THIS_MODULE, + .id = I2C_HW_SIBYTE, + .class = I2C_CLASS_HWMON, + .algo = NULL, + .algo_data = &sibyte_board_data[0], + .name = "SiByte SMBus 0", + }, + { + .owner = THIS_MODULE, + .id = I2C_HW_SIBYTE, + .class = I2C_CLASS_HWMON, + .algo = NULL, + .algo_data = &sibyte_board_data[1], + .name = "SiByte SMBus 1", + }, +}; + +static int __init i2c_sibyte_init(void) +{ + printk("i2c-swarm.o: i2c SMBus adapter module for SiByte board\n"); + if (i2c_sibyte_add_bus(&sibyte_board_adapter[0], K_SMB_FREQ_100KHZ) < 0) + return -ENODEV; + if (i2c_sibyte_add_bus(&sibyte_board_adapter[1], K_SMB_FREQ_400KHZ) < 0) + return -ENODEV; + return 0; +} + +static void __exit i2c_sibyte_exit(void) +{ + i2c_sibyte_del_bus(&sibyte_board_adapter[0]); + i2c_sibyte_del_bus(&sibyte_board_adapter[1]); +} + +module_init(i2c_sibyte_init); +module_exit(i2c_sibyte_exit); + +MODULE_AUTHOR("Kip Walker , Steven J. Hill "); +MODULE_DESCRIPTION("SMBus adapter routines for SiByte boards"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c-algo-sgi.h b/include/linux/i2c-algo-sgi.h new file mode 100644 index 000000000000..4a0113d64064 --- /dev/null +++ b/include/linux/i2c-algo-sgi.h @@ -0,0 +1,27 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * Copyright (C) 2003 Ladislav Michl + */ + +#ifndef I2C_ALGO_SGI_H +#define I2C_ALGO_SGI_H 1 + +#include + +struct i2c_algo_sgi_data { + void *data; /* private data for lowlevel routines */ + unsigned (*getctrl)(void *data); + void (*setctrl)(void *data, unsigned val); + unsigned (*rdata)(void *data); + void (*wdata)(void *data, unsigned val); + + int xfer_timeout; + int ack_timeout; +}; + +int i2c_sgi_add_bus(struct i2c_adapter *); +int i2c_sgi_del_bus(struct i2c_adapter *); + +#endif /* I2C_ALGO_SGI_H */ diff --git a/include/linux/i2c-algo-sibyte.h b/include/linux/i2c-algo-sibyte.h new file mode 100644 index 000000000000..03914ded8614 --- /dev/null +++ b/include/linux/i2c-algo-sibyte.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2001,2002,2003 Broadcom Corporation + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef I2C_ALGO_SIBYTE_H +#define I2C_ALGO_SIBYTE_H 1 + +#include + +struct i2c_algo_sibyte_data { + void *data; /* private data */ + int bus; /* which bus */ + void *reg_base; /* CSR base */ +}; + +int i2c_sibyte_add_bus(struct i2c_adapter *, int speed); +int i2c_sibyte_del_bus(struct i2c_adapter *); + +#endif /* I2C_ALGO_SIBYTE_H */ diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index c75219a37bb5..a75f38041df5 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -109,6 +109,7 @@ #define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */ #define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */ #define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ +#define I2C_DRIVERID_SAA7114H 64 /* video decoder */ #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ @@ -196,6 +197,9 @@ #define I2C_ALGO_OCP_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */ #define I2C_ALGO_PCA 0x150000 /* PCA 9564 style adapters */ +#define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */ +#define I2C_ALGO_SGI 0x160000 /* SGI algorithm */ + #define I2C_ALGO_EXP 0x800000 /* experimental */ #define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */ @@ -258,6 +262,13 @@ /* --- PowerPC on-chip adapters */ #define I2C_HW_OCP 0x00 /* IBM on-chip I2C adapter */ +/* --- Broadcom SiByte adapters */ +#define I2C_HW_SIBYTE 0x00 + +/* --- SGI adapters */ +#define I2C_HW_SGI_VINO 0x00 +#define I2C_HW_SGI_MACE 0x01 + /* --- XSCALE on-chip adapters */ #define I2C_HW_IOP321 0x00 -- cgit v1.2.3 From 1133b2d25f4e06fdec0dff18b942a311009a465f Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 20 Dec 2004 19:57:56 -0800 Subject: [PATCH] PCI: add prototype for pci_choose_state() This adds missing prototype for pci_choose_state. Signed-off-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- include/linux/pci.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/pci.h b/include/linux/pci.h index fe2b98de55ca..32325b10d419 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -806,6 +806,7 @@ void pci_remove_rom(struct pci_dev *pdev); int pci_save_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev); int pci_set_power_state(struct pci_dev *dev, pci_power_t state); +pci_power_t pci_choose_state(struct pci_dev *dev, u32 state); int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ @@ -934,6 +935,7 @@ static inline const struct pci_device_id *pci_match_device(const struct pci_devi static inline int pci_save_state(struct pci_dev *dev) { return 0; } static inline int pci_restore_state(struct pci_dev *dev) { return 0; } static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } +static inline pci_power_t pci_choose_state(struct pci_dev *dev, u32 state) { return PCI_D0; } static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } #define isa_bridge ((struct pci_dev *)NULL) -- cgit v1.2.3 From 42298be0eeb5ae98453b3374c36161b05a46c5dc Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 20 Dec 2004 20:12:05 -0800 Subject: [PATCH] PCI: export PCI resources in sysfs This patch exports PCI resources to userspace in the corresponding sysfs device directory. It depends on the platform HAVE_PCI_MMAP code, and is #ifdef'd accordingly. I've also added documentation describing the sysfs PCI device file layout. Signed-off-by: Jesse Barnes Signed-off-by: Greg Kroah-Hartman --- Documentation/filesystems/sysfs-pci.txt | 64 +++++++++++++++++++++++ drivers/pci/pci-sysfs.c | 92 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 157 insertions(+) create mode 100644 Documentation/filesystems/sysfs-pci.txt (limited to 'include') diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt new file mode 100644 index 000000000000..4cabfed6a77d --- /dev/null +++ b/Documentation/filesystems/sysfs-pci.txt @@ -0,0 +1,64 @@ +Accessing PCI device resources through sysfs + +sysfs, usually mounted at /sys, provides access to PCI resources on platforms +that support it. For example, a given bus might look like this: + + pci0000:17 + |-- 0000:17:00.0 + | |-- class + | |-- config + | |-- detach_state + | |-- device + | |-- irq + | |-- local_cpus + | |-- resource + | |-- resource0 + | |-- resource1 + | |-- resource2 + | |-- rom + | |-- subsystem_device + | |-- subsystem_vendor + | `-- vendor + `-- detach_state + +The topmost element describes the PCI domain and bus number. In this case, +the domain number is 0000 and the bus number is 17 (both values are in hex). +This bus contains a single function device in slot 0. The domain and bus +numbers are reproduced for convenience. Under the device directory are several +files, each with their own function. + + file function + ---- -------- + class PCI class (ascii, ro) + config PCI config space (binary, rw) + detach_state connection status (bool, rw) + device PCI device (ascii, ro) + irq IRQ number (ascii, ro) + local_cpus nearby CPU mask (cpumask, ro) + resource PCI resource host addresses (ascii, ro) + resource0..N PCI resource N, if present (binary, mmap) + rom PCI ROM resource, if present (binary, ro) + subsystem_device PCI subsystem device (ascii, ro) + subsystem_vendor PCI subsystem vendor (ascii, ro) + vendor PCI vendor (ascii, ro) + + ro - read only file + rw - file is readable and writable + mmap - file is mmapable + ascii - file contains ascii text + binary - file contains binary data + cpumask - file contains a cpumask type + +The read only files are informational, writes to them will be ignored. +Writable files can be used to perform actions on the device (e.g. changing +config space, detaching a device). mmapable files are available via an +mmap of the file at offset 0 and can be used to do actual device programming +from userspace. Note that some platforms don't support mmapping of certain +resources, so be sure to check the return value from any attempted mmap. + +Supporting PCI access on new platforms + +In order to support PCI resource mapping as described above, Linux platform +code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function. +Platforms are free to only support subsets of the mmap functionality, but +useful return codes should be provided. diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7fcf935c51b5..79e298448389 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "pci.h" @@ -178,6 +179,93 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count) return count; } +#ifdef HAVE_PCI_MMAP +/** + * pci_mmap_resource - map a PCI resource into user memory space + * @kobj: kobject for mapping + * @attr: struct bin_attribute for the file being mapped + * @vma: struct vm_area_struct passed into the mmap + * + * Use the regular PCI mapping routines to map a PCI resource into userspace. + * FIXME: write combining? maybe automatic for prefetchable regions? + */ +static int +pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, + struct vm_area_struct *vma) +{ + struct pci_dev *pdev = to_pci_dev(container_of(kobj, + struct device, kobj)); + struct resource *res = (struct resource *)attr->private; + enum pci_mmap_state mmap_type; + + vma->vm_pgoff += res->start >> PAGE_SHIFT; + mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; + + return pci_mmap_page_range(pdev, vma, mmap_type, 0); +} + +/** + * pci_create_resource_files - create resource files in sysfs for @dev + * @dev: dev in question + * + * Walk the resources in @dev creating files for each resource available. + */ +static void +pci_create_resource_files(struct pci_dev *pdev) +{ + int i; + + /* Expose the PCI resources from this device as files */ + for (i = 0; i < PCI_ROM_RESOURCE; i++) { + struct bin_attribute *res_attr; + + /* skip empty resources */ + if (!pci_resource_len(pdev, i)) + continue; + + res_attr = kmalloc(sizeof(*res_attr) + 10, GFP_ATOMIC); + if (res_attr) { + pdev->res_attr[i] = res_attr; + /* Allocated above after the res_attr struct */ + res_attr->attr.name = (char *)(res_attr + 1); + sprintf(res_attr->attr.name, "resource%d", i); + res_attr->size = pci_resource_len(pdev, i); + res_attr->attr.mode = S_IRUSR | S_IWUSR; + res_attr->attr.owner = THIS_MODULE; + res_attr->mmap = pci_mmap_resource; + res_attr->private = &pdev->resource[i]; + sysfs_create_bin_file(&pdev->dev.kobj, res_attr); + } + } +} + +/** + * pci_remove_resource_files - cleanup resource files + * @dev: dev to cleanup + * + * If we created resource files for @dev, remove them from sysfs and + * free their resources. + */ +static void +pci_remove_resource_files(struct pci_dev *pdev) +{ + int i; + + for (i = 0; i < PCI_ROM_RESOURCE; i++) { + struct bin_attribute *res_attr; + + res_attr = pdev->res_attr[i]; + if (res_attr) { + sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); + kfree(res_attr); + } + } +} +#else /* !HAVE_PCI_MMAP */ +static inline void pci_create_resource_files(struct pci_dev *dev) { return; } +static inline void pci_remove_resource_files(struct pci_dev *dev) { return; } +#endif /* HAVE_PCI_MMAP */ + /** * pci_write_rom - used to enable access to the PCI ROM display * @kobj: kernel object handle @@ -269,6 +357,8 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev) else sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); + pci_create_resource_files(pdev); + /* If the device has a ROM, try to expose it in sysfs. */ if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { struct bin_attribute *rom_attr; @@ -304,6 +394,8 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) else sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); + pci_remove_resource_files(pdev); + if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { if (pdev->rom_attr) { sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); diff --git a/include/linux/pci.h b/include/linux/pci.h index 6e0973f334b1..5ba44f91fc3b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -539,6 +539,7 @@ struct pci_dev { u32 saved_config_space[16]; /* config space saved at suspend time */ struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ int rom_attr_enabled; /* has display of the rom attribute been enabled? */ + struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */ #ifdef CONFIG_PCI_NAMES #define PCI_NAME_SIZE 96 #define PCI_NAME_HALF __stringify(43) /* less than half to handle slop */ -- cgit v1.2.3 From 382c1386a743afc8231548966b89db6702eeb7c4 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 21 Dec 2004 00:51:39 -0800 Subject: [PATCH] driver core: allow struct bin_attributes in class devices This small patch adds routines to create and remove bin_attribute files for class devices. One intended use is for binary files corresponding to PCI busses, like bus legacy I/O ports or ISA memory. Signed-off-by: Jesse Barnes --- drivers/base/class.c | 18 ++++++++++++++++++ include/linux/device.h | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/drivers/base/class.c b/drivers/base/class.c index 54b20126c9f7..e22fa1fdf74a 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -179,6 +179,22 @@ void class_device_remove_file(struct class_device * class_dev, sysfs_remove_file(&class_dev->kobj, &attr->attr); } +int class_device_create_bin_file(struct class_device *class_dev, + struct bin_attribute *attr) +{ + int error = -EINVAL; + if (class_dev) + error = sysfs_create_bin_file(&class_dev->kobj, attr); + return error; +} + +void class_device_remove_bin_file(struct class_device *class_dev, + struct bin_attribute *attr) +{ + if (class_dev) + sysfs_remove_bin_file(&class_dev->kobj, attr); +} + static int class_device_dev_link(struct class_device * class_dev) { if (class_dev->dev) @@ -576,6 +592,8 @@ EXPORT_SYMBOL_GPL(class_device_get); EXPORT_SYMBOL_GPL(class_device_put); EXPORT_SYMBOL_GPL(class_device_create_file); EXPORT_SYMBOL_GPL(class_device_remove_file); +EXPORT_SYMBOL_GPL(class_device_create_bin_file); +EXPORT_SYMBOL_GPL(class_device_remove_bin_file); EXPORT_SYMBOL_GPL(class_interface_register); EXPORT_SYMBOL_GPL(class_interface_unregister); diff --git a/include/linux/device.h b/include/linux/device.h index d885723a2c3a..2c5d57283d5a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -228,7 +228,10 @@ extern int class_device_create_file(struct class_device *, const struct class_device_attribute *); extern void class_device_remove_file(struct class_device *, const struct class_device_attribute *); - +extern int class_device_create_bin_file(struct class_device *, + struct bin_attribute *); +extern void class_device_remove_bin_file(struct class_device *, + struct bin_attribute *); struct class_interface { struct list_head node; -- cgit v1.2.3 From 264c09f53e06a32f39aea0ef5ae07383068c28a6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 21 Dec 2004 06:40:34 -0800 Subject: sysfs: export the /sys/kernel subsystem for people to use. Signed-off-by: Greg Kroah-Hartman --- include/linux/kobject.h | 2 ++ kernel/ksysfs.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 187ac79e1f17..c22c8724a8dc 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -167,6 +167,8 @@ struct subsystem _varname##_subsys = { \ } \ } +/* The global /sys/kernel/ subsystem for people to chain off of */ +extern struct subsystem kernel_subsys; /** * Helpers for setting the kset of registered objects. diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 31f1a60df733..1f064a63f8cf 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -30,7 +30,8 @@ static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page) KERNEL_ATTR_RO(hotplug_seqnum); #endif -static decl_subsys(kernel, NULL, NULL); +decl_subsys(kernel, NULL, NULL); +EXPORT_SYMBOL_GPL(kernel_subsys); static struct attribute * kernel_attrs[] = { #ifdef CONFIG_HOTPLUG -- cgit v1.2.3 From c842b00abac4261b59f4c80094b264e40cc4f236 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 21 Dec 2004 18:11:27 -0800 Subject: [PATCH] PCI: Software visible configuration request retry status PCI Express allows cards to return "Configuration Request Retry" if they're not ready to handle accesses to configuration space. The PCI Express 1.0a specification says that the Root Complex should retry the access. ECN 27 http://www.pcisig.com/specifications/pciexpress/ECN_CRS_Software_Visibility_No27.pdf allows software to handle the CRS. Signed-off-by: Matthew Wilcox Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 42 +++++++++++++++++++++++++++++++++++++++--- include/linux/pci.h | 14 ++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index d13ff06d2f7f..6f69ce367279 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2,6 +2,7 @@ * probe.c - PCI detection and setup code */ +#include #include #include #include @@ -336,6 +337,22 @@ struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_de return child; } +static void pci_enable_crs(struct pci_dev *dev) +{ + u16 cap, rpctl; + int rpcap = pci_find_capability(dev, PCI_CAP_ID_EXP); + if (!rpcap) + return; + + pci_read_config_word(dev, rpcap + PCI_CAP_FLAGS, &cap); + if (((cap & PCI_EXP_FLAGS_TYPE) >> 4) != PCI_EXP_TYPE_ROOT_PORT) + return; + + pci_read_config_word(dev, rpcap + PCI_EXP_RTCTL, &rpctl); + rpctl |= PCI_EXP_RTCTL_CRSSVE; + pci_write_config_word(dev, rpcap + PCI_EXP_RTCTL, rpctl); +} + unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus); /* @@ -366,6 +383,8 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); + pci_enable_crs(dev); + if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) { unsigned int cmax, busnr; /* @@ -614,9 +633,7 @@ pci_scan_device(struct pci_bus *bus, int devfn) struct pci_dev *dev; u32 l; u8 hdr_type; - - if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) - return NULL; + int delay = 1; if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) return NULL; @@ -626,6 +643,25 @@ pci_scan_device(struct pci_bus *bus, int devfn) l == 0x0000ffff || l == 0xffff0000) return NULL; + /* Configuration request Retry Status */ + while (l == 0xffff0001) { + msleep(delay); + delay *= 2; + if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) + return NULL; + /* Card hasn't responded in 60 seconds? Must be stuck. */ + if (delay > 60 * 1000) { + printk(KERN_WARNING "Device %04x:%02x:%02x.%d not " + "responding\n", pci_domain_nr(bus), + bus->number, PCI_SLOT(devfn), + PCI_FUNC(devfn)); + return NULL; + } + } + + if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) + return NULL; + dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); if (!dev) return NULL; diff --git a/include/linux/pci.h b/include/linux/pci.h index 32325b10d419..ee5456e9a5dd 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -364,6 +364,20 @@ #define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ #define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ #define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ +#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ +#define PCI_EXP_LNKCTL 16 /* Link Control */ +#define PCI_EXP_LNKSTA 18 /* Link Status */ +#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ +#define PCI_EXP_SLTCTL 24 /* Slot Control */ +#define PCI_EXP_SLTSTA 26 /* Slot Status */ +#define PCI_EXP_RTCTL 28 /* Root Control */ +#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */ +#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */ +#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */ +#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */ +#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ +#define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTSTA 32 /* Root Status */ /* Extended Capabilities (PCI-X 2.0 and Express) */ #define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) -- cgit v1.2.3 From 2bd816b9099d7715374a483340cc35b53a29fa50 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 21 Dec 2004 21:06:36 -0800 Subject: [PATCH] PCI: add legacy resources to sysfs for pci busses This patch adds legacy_io and legacy_mem files to the pci_bus class hierarchy in sysfs. The files can be used (if the platform supports them) to access legacy I/O port space and legacy ISA memory space--useful for things like x86 emulators or VGA card POSTing. The interfaces are documented in Documentation/filesystems/sysfs-pci.txt. Signed-off-by: Jesse Barnes Signed-off-by: Greg Kroah-Hartman --- Documentation/filesystems/sysfs-pci.txt | 26 ++++++++++- drivers/pci/pci-sysfs.c | 70 ++++++++++++++++++++++++++++ drivers/pci/probe.c | 82 +++++++++++++++++++++++++++------ include/linux/pci.h | 2 + 4 files changed, 164 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt index 4cabfed6a77d..e97d024eae77 100644 --- a/Documentation/filesystems/sysfs-pci.txt +++ b/Documentation/filesystems/sysfs-pci.txt @@ -3,7 +3,7 @@ Accessing PCI device resources through sysfs sysfs, usually mounted at /sys, provides access to PCI resources on platforms that support it. For example, a given bus might look like this: - pci0000:17 + /sys/devices/pci0000:17 |-- 0000:17:00.0 | |-- class | |-- config @@ -56,9 +56,33 @@ mmap of the file at offset 0 and can be used to do actual device programming from userspace. Note that some platforms don't support mmapping of certain resources, so be sure to check the return value from any attempted mmap. +Accessing legacy resources through sysfs + +Legacy I/O port and ISA memory resources are also provided in sysfs if the +underlying platform supports them. They're located in the PCI class heirarchy, +e.g. + + /sys/class/pci_bus/0000:17/ + |-- bridge -> ../../../devices/pci0000:17 + |-- cpuaffinity + |-- legacy_io + `-- legacy_mem + +The legacy_io file is a read/write file that can be used by applications to +do legacy port I/O. The application should open the file, seek to the desired +port (e.g. 0x3e8) and do a read or a write of 1, 2 or 4 bytes. The legacy_mem +file should be mmapped with an offset corresponding to the memory offset +desired, e.g. 0xa0000 for the VGA frame buffer. The application can then +simply dereference the returned pointer (after checking for errors of course) +to access legacy memory space. + Supporting PCI access on new platforms In order to support PCI resource mapping as described above, Linux platform code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function. Platforms are free to only support subsets of the mmap functionality, but useful return codes should be provided. + +Legacy resources are protected by the HAVE_PCI_LEGACY define. Platforms +wishing to support legacy functionality should define it and provide +pci_legacy_read, pci_legacy_write and pci_mmap_legacy_page_range functions. \ No newline at end of file diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 79e298448389..fc7bc2357a11 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -179,6 +179,76 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count) return count; } +#ifdef HAVE_PCI_LEGACY +/** + * pci_read_legacy_io - read byte(s) from legacy I/O port space + * @kobj: kobject corresponding to file to read from + * @buf: buffer to store results + * @off: offset into legacy I/O port space + * @count: number of bytes to read + * + * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific + * callback routine (pci_legacy_read). + */ +ssize_t +pci_read_legacy_io(struct kobject *kobj, char *buf, loff_t off, size_t count) +{ + struct pci_bus *bus = to_pci_bus(container_of(kobj, + struct class_device, + kobj)); + + /* Only support 1, 2 or 4 byte accesses */ + if (count != 1 && count != 2 && count != 4) + return -EINVAL; + + return pci_legacy_read(bus, off, (u32 *)buf, count); +} + +/** + * pci_write_legacy_io - write byte(s) to legacy I/O port space + * @kobj: kobject corresponding to file to read from + * @buf: buffer containing value to be written + * @off: offset into legacy I/O port space + * @count: number of bytes to write + * + * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific + * callback routine (pci_legacy_write). + */ +ssize_t +pci_write_legacy_io(struct kobject *kobj, char *buf, loff_t off, size_t count) +{ + struct pci_bus *bus = to_pci_bus(container_of(kobj, + struct class_device, + kobj)); + /* Only support 1, 2 or 4 byte accesses */ + if (count != 1 && count != 2 && count != 4) + return -EINVAL; + + return pci_legacy_write(bus, off, *(u32 *)buf, count); +} + +/** + * pci_mmap_legacy_mem - map legacy PCI memory into user memory space + * @kobj: kobject corresponding to device to be mapped + * @attr: struct bin_attribute for this file + * @vma: struct vm_area_struct passed to mmap + * + * Uses an arch specific callback, pci_mmap_legacy_page_range, to mmap + * legacy memory space (first meg of bus space) into application virtual + * memory space. + */ +int +pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, + struct vm_area_struct *vma) +{ + struct pci_bus *bus = to_pci_bus(container_of(kobj, + struct class_device, + kobj)); + + return pci_mmap_legacy_page_range(bus, vma); +} +#endif /* HAVE_PCI_LEGACY */ + #ifdef HAVE_PCI_MMAP /** * pci_mmap_resource - map a PCI resource into user memory space diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1c70dd5a19e6..2c1d012233f7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -27,27 +27,49 @@ EXPORT_SYMBOL(pci_root_buses); LIST_HEAD(pci_devices); -/* - * PCI Bus Class +#ifdef HAVE_PCI_LEGACY +/** + * pci_create_legacy_files - create legacy I/O port and memory files + * @b: bus to create files under + * + * Some platforms allow access to legacy I/O port and ISA memory space on + * a per-bus basis. This routine creates the files and ties them into + * their associated read, write and mmap files from pci-sysfs.c */ -static void release_pcibus_dev(struct class_device *class_dev) +static void pci_create_legacy_files(struct pci_bus *b) { - struct pci_bus *pci_bus = to_pci_bus(class_dev); - if (pci_bus->bridge) - put_device(pci_bus->bridge); - kfree(pci_bus); + b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2, + GFP_ATOMIC); + if (b->legacy_io) { + b->legacy_io->attr.name = "legacy_io"; + b->legacy_io->size = 0xffff; + b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; + b->legacy_io->attr.owner = THIS_MODULE; + b->legacy_io->read = pci_read_legacy_io; + b->legacy_io->write = pci_write_legacy_io; + class_device_create_bin_file(&b->class_dev, b->legacy_io); + + /* Allocated above after the legacy_io struct */ + b->legacy_mem = b->legacy_io + 1; + b->legacy_mem->attr.name = "legacy_mem"; + b->legacy_mem->size = 1024*1024; + b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; + b->legacy_mem->attr.owner = THIS_MODULE; + b->legacy_mem->mmap = pci_mmap_legacy_mem; + class_device_create_bin_file(&b->class_dev, b->legacy_mem); + } } -static struct class pcibus_class = { - .name = "pci_bus", - .release = &release_pcibus_dev, -}; - -static int __init pcibus_class_init(void) +static void pci_remove_legacy_files(struct pci_bus *b) { - return class_register(&pcibus_class); + class_device_remove_bin_file(&b->class_dev, b->legacy_io); + class_device_remove_bin_file(&b->class_dev, b->legacy_mem); + kfree(b->legacy_io); /* both are allocated here */ } -postcore_initcall(pcibus_class_init); +#else /* !HAVE_PCI_LEGACY */ +static inline void pci_create_legacy_files(struct pci_bus *bus) { return; } +static inline void pci_remove_legacy_files(struct pci_bus *bus) { return; } +#endif /* HAVE_PCI_LEGACY */ /* * PCI Bus Class Devices @@ -64,6 +86,33 @@ static ssize_t pci_bus_show_cpuaffinity(struct class_device *class_dev, char *bu } static CLASS_DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); +/* + * PCI Bus Class + */ +static void release_pcibus_dev(struct class_device *class_dev) +{ + struct pci_bus *pci_bus = to_pci_bus(class_dev); + + pci_remove_legacy_files(pci_bus); + class_device_remove_file(&pci_bus->class_dev, + &class_device_attr_cpuaffinity); + sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge"); + if (pci_bus->bridge) + put_device(pci_bus->bridge); + kfree(pci_bus); +} + +static struct class pcibus_class = { + .name = "pci_bus", + .release = &release_pcibus_dev, +}; + +static int __init pcibus_class_init(void) +{ + return class_register(&pcibus_class); +} +postcore_initcall(pcibus_class_init); + /* * Translate the low bits of the PCI base * to the resource type @@ -808,6 +857,9 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, if (error) goto class_dev_create_file_err; + /* Create legacy_io and legacy_mem files for this bus */ + pci_create_legacy_files(b); + error = sysfs_create_link(&b->class_dev.kobj, &b->bridge->kobj, "bridge"); if (error) goto sys_create_link_err; diff --git a/include/linux/pci.h b/include/linux/pci.h index 5ba44f91fc3b..329e7e71f2af 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -594,6 +594,8 @@ struct pci_bus { unsigned short pad2; struct device *bridge; struct class_device class_dev; + struct bin_attribute *legacy_io; /* legacy I/O for this bus */ + struct bin_attribute *legacy_mem; /* legacy mem */ }; #define pci_bus_b(n) list_entry(n, struct pci_bus, node) -- cgit v1.2.3 From 57683a86839aaba3b861c3baa0da94a6140e0c36 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Wed, 5 Jan 2005 23:05:54 -0800 Subject: [PATCH] Update IOP3xx I2C bus driver The following patch is a major cleanup of the IOP3xx I2C bus driver that is found on Intel's IOP and IXP chipsets. The existing driver in the 2.6 tree uses hardcoded I/O addresses based on board configuration which is just going to get ugly as more chips use this unit. The update switches to using the driver model and passing in the I/O addresses via platform_device resources. The patch also updates the ID name to more closely match the actual usage of the device. I have tested this new driver on IXP46x systems and Dave Jiang has tested it on both IOP321 and IOP331 systems. ARM-specific patches to provide platform-level hooks will go upstream after this patch is integrated. An example of using the new driver (from IXP46x ARM code) follows: static struct resource ixp46x_i2c_resources[] = { [0] = { .start = 0xc8011000, .end = 0xc801101c, .flags = IORESOURCE_MEM, }, [1] = { .start = IRQ_IXP4XX_I2C, .end = IRQ_IXP4XX_I2C, .flags = IORESOURCE_IRQ } }; static struct platform_device ixp46x_i2c_controller = { .name = "IOP3xx-I2C", .id = 0, .num_resources = 2, .resource = &ixp46x_i2c_resources }; static struct platform_device *ixp46x_devices[] __initdata = { &ixp46x_i2c_controller }; void __init ixp4xx_init(void) { if (cpu_is_ixp46x()) { platform_add_devices(ixp46x_devices, ARRAY_SIZE(ixp46x_devices)); } } Signed-off-by: Deepak Saxena Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/Kconfig | 10 +- drivers/i2c/busses/i2c-iop3xx.c | 547 +++++++++++++++++++++------------------- drivers/i2c/busses/i2c-iop3xx.h | 103 ++++---- include/linux/i2c-id.h | 4 +- 4 files changed, 339 insertions(+), 325 deletions(-) (limited to 'include') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 14bedba48216..9d44bd94b712 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -143,8 +143,14 @@ config I2C_IBM_IIC will be called i2c-ibm_iic. config I2C_IOP3XX - tristate "Intel XScale IOP3xx on-chip I2C interface" - depends on ARCH_IOP3XX && I2C + tristate "Intel IOP3xx and IXP4xx on-chip I2C interface" + depends on (ARCH_IOP3XX || ARCH_IXP4XX) && I2C + help + Say Y here if you want to use the IIC bus controller on + the Intel IOP3xx I/O Processors or IXP4xx Network Processors. + + This driver can also be built as a module. If so, the module + will be called i2c-iop3xx. config I2C_ISA tristate "ISA Bus support" diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 844aa3e03256..961241b19f88 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c @@ -1,35 +1,30 @@ /* ------------------------------------------------------------------------- */ -/* i2c-iop3xx.c i2c driver algorithms for Intel XScale IOP3xx */ +/* i2c-iop3xx.c i2c driver algorithms for Intel XScale IOP3xx & IXP46x */ /* ------------------------------------------------------------------------- */ -/* Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd - * - - 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, version 2. - - - 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. */ -/* ------------------------------------------------------------------------- */ -/* - With acknowledgements to i2c-algo-ibm_ocp.c by - Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com - - And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund: - - Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund - - And which acknowledged Kyösti Mälkki , - Frodo Looijaard , Martin Bailey - - ---------------------------------------------------------------------------*/ +/* Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd + * + * + * With acknowledgements to i2c-algo-ibm_ocp.c by + * Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com + * + * And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund: + * + * Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund + * + * And which acknowledged Kyösti Mälkki , + * Frodo Looijaard , Martin Bailey + * + * Major cleanup by Deepak Saxena , 01/2005: + * + * - Use driver model to pass per-chip info instead of hardcoding and #ifdefs + * - Use ioremap/__raw_readl/__raw_writel instead of direct dereference + * - Make it work with IXP46x chips + * - Cleanup function names, coding style, etc + * + * 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, version 2. + */ #include #include @@ -40,24 +35,18 @@ #include #include #include +#include #include +#include -#include -#include #include "i2c-iop3xx.h" +/* global unit counter */ +static int i2c_id = 0; -/* ----- global defines ----------------------------------------------- */ -#define PASSERT(x) do { if (!(x) ) \ - printk(KERN_CRIT "PASSERT %s in %s:%d\n", #x, __FILE__, __LINE__ );\ - } while (0) - - -/* ----- global variables --------------------------------------------- */ - - -static inline unsigned char iic_cook_addr(struct i2c_msg *msg) +static inline unsigned char +iic_cook_addr(struct i2c_msg *msg) { unsigned char addr; @@ -66,103 +55,110 @@ static inline unsigned char iic_cook_addr(struct i2c_msg *msg) if (msg->flags & I2C_M_RD) addr |= 1; - /* PGM: what is M_REV_DIR_ADDR - do we need it ?? */ + /* + * Read or Write? + */ if (msg->flags & I2C_M_REV_DIR_ADDR) addr ^= 1; return addr; } - -static inline void iop3xx_adap_reset(struct i2c_algo_iop3xx_data *iop3xx_adap) +static void +iop3xx_i2c_reset(struct i2c_algo_iop3xx_data *iop3xx_adap) { /* Follows devman 9.3 */ - *iop3xx_adap->biu->CR = IOP321_ICR_UNIT_RESET; - *iop3xx_adap->biu->SR = IOP321_ISR_CLEARBITS; - *iop3xx_adap->biu->CR = 0; + __raw_writel(IOP3XX_ICR_UNIT_RESET, iop3xx_adap->ioaddr + CR_OFFSET); + __raw_writel(IOP3XX_ISR_CLEARBITS, iop3xx_adap->ioaddr + SR_OFFSET); + __raw_writel(0, iop3xx_adap->ioaddr + CR_OFFSET); } -static inline void iop3xx_adap_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap) +static void +iop3xx_i2c_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap) { - *iop3xx_adap->biu->SAR = MYSAR; + __raw_writel(MYSAR, iop3xx_adap->ioaddr + SAR_OFFSET); } -static inline void iop3xx_adap_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) +static void +iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) { - u32 cr = IOP321_ICR_GCD|IOP321_ICR_SCLEN|IOP321_ICR_UE; + u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; + + /* + * Everytime unit enable is asserted, GPOD needs to be cleared + * on IOP321 to avoid data corruption on the bus. + */ +#ifdef CONFIG_ARCH_IOP321 +#define IOP321_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */ +#define IOP321_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */ + *IOP321_GPOD &= (iop3xx_adap->id == 0) ? ~IOP321_GPOD_I2C0 : + ~IOP321_GPOD_I2C1; +#endif /* NB SR bits not same position as CR IE bits :-( */ - iop3xx_adap->biu->SR_enabled = - IOP321_ISR_ALD | IOP321_ISR_BERRD | - IOP321_ISR_RXFULL | IOP321_ISR_TXEMPTY; + iop3xx_adap->SR_enabled = + IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD | + IOP3XX_ISR_RXFULL | IOP3XX_ISR_TXEMPTY; - cr |= IOP321_ICR_ALDIE | IOP321_ICR_BERRIE | - IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE; + cr |= IOP3XX_ICR_ALD_IE | IOP3XX_ICR_BERR_IE | + IOP3XX_ICR_RXFULL_IE | IOP3XX_ICR_TXEMPTY_IE; - *iop3xx_adap->biu->CR = cr; + __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); } -static void iop3xx_adap_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap) +static void +iop3xx_i2c_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap) { - unsigned cr = *iop3xx_adap->biu->CR; + unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); - cr &= ~(IOP321_ICR_MSTART | IOP321_ICR_TBYTE | - IOP321_ICR_MSTOP | IOP321_ICR_SCLEN); - *iop3xx_adap->biu->CR = cr; -} + cr &= ~(IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE | + IOP3XX_ICR_MSTOP | IOP3XX_ICR_SCLEN); -static void iop3xx_adap_final_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap) -{ - unsigned cr = *iop3xx_adap->biu->CR; - - cr &= ~(IOP321_ICR_ALDIE | IOP321_ICR_BERRIE | - IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE); - iop3xx_adap->biu->SR_enabled = 0; - *iop3xx_adap->biu->CR = cr; + __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); } /* * NB: the handler has to clear the source of the interrupt! * Then it passes the SR flags of interest to BH via adap data */ -static irqreturn_t iop3xx_i2c_handler(int this_irq, - void *dev_id, - struct pt_regs *regs) +static irqreturn_t +iop3xx_i2c_irq_handler(int this_irq, void *dev_id, struct pt_regs *regs) { struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id; + u32 sr = __raw_readl(iop3xx_adap->ioaddr + SR_OFFSET); - u32 sr = *iop3xx_adap->biu->SR; - - if ((sr &= iop3xx_adap->biu->SR_enabled)) { - *iop3xx_adap->biu->SR = sr; - iop3xx_adap->biu->SR_received |= sr; + if ((sr &= iop3xx_adap->SR_enabled)) { + __raw_writel(sr, iop3xx_adap->ioaddr + SR_OFFSET); + iop3xx_adap->SR_received |= sr; wake_up_interruptible(&iop3xx_adap->waitq); } return IRQ_HANDLED; } /* check all error conditions, clear them , report most important */ -static int iop3xx_adap_error(u32 sr) +static int +iop3xx_i2c_error(u32 sr) { int rc = 0; - if ((sr&IOP321_ISR_BERRD)) { + if ((sr & IOP3XX_ISR_BERRD)) { if ( !rc ) rc = -I2C_ERR_BERR; } - if ((sr&IOP321_ISR_ALD)) { + if ((sr & IOP3XX_ISR_ALD)) { if ( !rc ) rc = -I2C_ERR_ALD; } return rc; } -static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap) +static inline u32 +iop3xx_i2c_get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap) { unsigned long flags; u32 sr; spin_lock_irqsave(&iop3xx_adap->lock, flags); - sr = iop3xx_adap->biu->SR_received; - iop3xx_adap->biu->SR_received = 0; + sr = iop3xx_adap->SR_received; + iop3xx_adap->SR_received = 0; spin_unlock_irqrestore(&iop3xx_adap->lock, flags); return sr; @@ -175,9 +171,10 @@ static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap) typedef int (* compare_func)(unsigned test, unsigned mask); /* returns 1 on correct comparison */ -static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, - unsigned flags, unsigned* status, - compare_func compare) +static int +iop3xx_i2c_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, + unsigned flags, unsigned* status, + compare_func compare) { unsigned sr = 0; int interrupted; @@ -187,13 +184,13 @@ static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, do { interrupted = wait_event_interruptible_timeout ( iop3xx_adap->waitq, - (done = compare( sr = get_srstat(iop3xx_adap),flags )), - iop3xx_adap->timeout + (done = compare( sr = iop3xx_i2c_get_srstat(iop3xx_adap) ,flags )), + 1 * HZ; ); - if ((rc = iop3xx_adap_error(sr)) < 0) { + if ((rc = iop3xx_i2c_error(sr)) < 0) { *status = sr; return rc; - }else if (!interrupted) { + } else if (!interrupted) { *status = sr; return -ETIMEDOUT; } @@ -207,141 +204,131 @@ static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, /* * Concrete compare_funcs */ -static int all_bits_clear(unsigned test, unsigned mask) +static int +all_bits_clear(unsigned test, unsigned mask) { return (test & mask) == 0; } -static int any_bits_set(unsigned test, unsigned mask) + +static int +any_bits_set(unsigned test, unsigned mask) { return (test & mask) != 0; } -static int iop3xx_adap_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) +static int +iop3xx_i2c_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) { - return iop3xx_adap_wait_event( + return iop3xx_i2c_wait_event( iop3xx_adap, - IOP321_ISR_TXEMPTY|IOP321_ISR_ALD|IOP321_ISR_BERRD, + IOP3XX_ISR_TXEMPTY | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD, status, any_bits_set); } -static int iop3xx_adap_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) +static int +iop3xx_i2c_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) { - return iop3xx_adap_wait_event( + return iop3xx_i2c_wait_event( iop3xx_adap, - IOP321_ISR_RXFULL|IOP321_ISR_ALD|IOP321_ISR_BERRD, + IOP3XX_ISR_RXFULL | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD, status, any_bits_set); } -static int iop3xx_adap_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) -{ - return iop3xx_adap_wait_event( - iop3xx_adap, IOP321_ISR_UNITBUSY, status, all_bits_clear); -} - -/* - * Description: This performs the IOP3xx initialization sequence - * Valid for IOP321. Maybe valid for IOP310?. - */ -static int iop3xx_adap_init (struct i2c_algo_iop3xx_data *iop3xx_adap) +static int +iop3xx_i2c_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) { - *IOP321_GPOD &= ~(iop3xx_adap->channel==0 ? - IOP321_GPOD_I2C0: - IOP321_GPOD_I2C1); - - iop3xx_adap_reset(iop3xx_adap); - iop3xx_adap_set_slave_addr(iop3xx_adap); - iop3xx_adap_enable(iop3xx_adap); - - return 0; + return iop3xx_i2c_wait_event( + iop3xx_adap, IOP3XX_ISR_UNITBUSY, status, all_bits_clear); } -static int iop3xx_adap_send_target_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap, - struct i2c_msg* msg) +static int +iop3xx_i2c_send_target_addr(struct i2c_algo_iop3xx_data *iop3xx_adap, + struct i2c_msg* msg) { - unsigned cr = *iop3xx_adap->biu->CR; + unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); int status; int rc; - *iop3xx_adap->biu->DBR = iic_cook_addr(msg); + __raw_writel(iic_cook_addr(msg), iop3xx_adap->ioaddr + DBR_OFFSET); - cr &= ~(IOP321_ICR_MSTOP | IOP321_ICR_NACK); - cr |= IOP321_ICR_MSTART | IOP321_ICR_TBYTE; - - *iop3xx_adap->biu->CR = cr; - rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status); - /* this assert fires every time, contrary to IOP manual - PASSERT((status&IOP321_ISR_UNITBUSY)!=0); - */ - PASSERT((status&IOP321_ISR_RXREAD)==0); - + cr &= ~(IOP3XX_ICR_MSTOP | IOP3XX_ICR_NACK); + cr |= IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE; + + __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); + rc = iop3xx_i2c_wait_tx_done(iop3xx_adap, &status); + return rc; } -static int iop3xx_adap_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, int stop) +static int +iop3xx_i2c_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, + int stop) { - unsigned cr = *iop3xx_adap->biu->CR; + unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); int status; int rc = 0; - *iop3xx_adap->biu->DBR = byte; - cr &= ~IOP321_ICR_MSTART; + __raw_writel(byte, iop3xx_adap->ioaddr + DBR_OFFSET); + cr &= ~IOP3XX_ICR_MSTART; if (stop) { - cr |= IOP321_ICR_MSTOP; + cr |= IOP3XX_ICR_MSTOP; } else { - cr &= ~IOP321_ICR_MSTOP; + cr &= ~IOP3XX_ICR_MSTOP; } - *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE; - rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status); + cr |= IOP3XX_ICR_TBYTE; + __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); + rc = iop3xx_i2c_wait_tx_done(iop3xx_adap, &status); return rc; } -static int iop3xx_adap_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, - char* byte, int stop) +static int +iop3xx_i2c_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char* byte, + int stop) { - unsigned cr = *iop3xx_adap->biu->CR; + unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); int status; int rc = 0; - cr &= ~IOP321_ICR_MSTART; + cr &= ~IOP3XX_ICR_MSTART; if (stop) { - cr |= IOP321_ICR_MSTOP|IOP321_ICR_NACK; + cr |= IOP3XX_ICR_MSTOP | IOP3XX_ICR_NACK; } else { - cr &= ~(IOP321_ICR_MSTOP|IOP321_ICR_NACK); + cr &= ~(IOP3XX_ICR_MSTOP | IOP3XX_ICR_NACK); } - *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE; + cr |= IOP3XX_ICR_TBYTE; + __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); - rc = iop3xx_adap_wait_rx_done(iop3xx_adap, &status); + rc = iop3xx_i2c_wait_rx_done(iop3xx_adap, &status); - *byte = *iop3xx_adap->biu->DBR; + *byte = __raw_readl(iop3xx_adap->ioaddr + DBR_OFFSET); return rc; } -static int iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap, - const char *buf, int count) +static int +iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap, const char *buf, int count) { struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; int ii; int rc = 0; - for (ii = 0; rc == 0 && ii != count; ++ii) { - rc = iop3xx_adap_write_byte(iop3xx_adap, buf[ii], ii==count-1); - } + for (ii = 0; rc == 0 && ii != count; ++ii) + rc = iop3xx_i2c_write_byte(iop3xx_adap, buf[ii], ii==count-1); return rc; } -static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, - char *buf, int count) +static int +iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count) { struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; int ii; int rc = 0; - for (ii = 0; rc == 0 && ii != count; ++ii) { - rc = iop3xx_adap_read_byte(iop3xx_adap, &buf[ii], ii==count-1); - } + for (ii = 0; rc == 0 && ii != count; ++ii) + rc = iop3xx_i2c_read_byte(iop3xx_adap, &buf[ii], ii==count-1); + return rc; } @@ -352,12 +339,13 @@ static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, * Each transfer (i.e. a read or a write) is separated by a repeated start * condition. */ -static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) +static int +iop3xx_i2c_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) { struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; int rc; - rc = iop3xx_adap_send_target_slave_addr(iop3xx_adap, pmsg); + rc = iop3xx_i2c_send_target_addr(iop3xx_adap, pmsg); if (rc < 0) { return rc; } @@ -372,22 +360,24 @@ static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) /* * master_xfer() - main read/write entry */ -static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) +static int +iop3xx_i2c_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], + int num) { struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; int im = 0; int ret = 0; int status; - iop3xx_adap_wait_idle(iop3xx_adap, &status); - iop3xx_adap_reset(iop3xx_adap); - iop3xx_adap_enable(iop3xx_adap); + iop3xx_i2c_wait_idle(iop3xx_adap, &status); + iop3xx_i2c_reset(iop3xx_adap); + iop3xx_i2c_enable(iop3xx_adap); for (im = 0; ret == 0 && im != num; im++) { - ret = iop3xx_handle_msg(i2c_adap, &msgs[im]); + ret = iop3xx_i2c_handle_msg(i2c_adap, &msgs[im]); } - iop3xx_adap_transaction_cleanup(iop3xx_adap); + iop3xx_i2c_transaction_cleanup(iop3xx_adap); if(ret) return ret; @@ -395,136 +385,165 @@ static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[ return im; } -static int algo_control(struct i2c_adapter *adapter, unsigned int cmd, +static int +iop3xx_i2c_algo_control(struct i2c_adapter *adapter, unsigned int cmd, unsigned long arg) { return 0; } -static u32 iic_func(struct i2c_adapter *adap) +static u32 +iop3xx_i2c_func(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } - -/* -----exported algorithm data: ------------------------------------- */ - -static struct i2c_algorithm iic_algo = { +static struct i2c_algorithm iop3xx_i2c_algo = { .name = "IOP3xx I2C algorithm", - .id = I2C_ALGO_OCP_IOP3XX, - .master_xfer = iop3xx_master_xfer, - .algo_control = algo_control, - .functionality = iic_func, + .id = I2C_ALGO_IOP3XX, + .master_xfer = iop3xx_i2c_master_xfer, + .algo_control = iop3xx_i2c_algo_control, + .functionality = iop3xx_i2c_func, }; -/* - * registering functions to load algorithms at runtime - */ -static int i2c_iop3xx_add_bus(struct i2c_adapter *iic_adap) +static int +iop3xx_i2c_remove(struct device *device) { - struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data; + struct platform_device *pdev = to_platform_device(device); + struct i2c_adapter *padapter = dev_get_drvdata(&pdev->dev); + struct i2c_algo_iop3xx_data *adapter_data = + (struct i2c_algo_iop3xx_data *)padapter->algo_data; + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + unsigned long cr = __raw_readl(adapter_data->ioaddr + CR_OFFSET); + + /* + * Disable the actual HW unit + */ + cr &= ~(IOP3XX_ICR_ALD_IE | IOP3XX_ICR_BERR_IE | + IOP3XX_ICR_RXFULL_IE | IOP3XX_ICR_TXEMPTY_IE); + __raw_writel(cr, adapter_data->ioaddr + CR_OFFSET); + + iounmap((void __iomem*)adapter_data->ioaddr); + release_mem_region(res->start, IOP3XX_I2C_IO_SIZE); + kfree(adapter_data); + kfree(padapter); + + dev_set_drvdata(&pdev->dev, NULL); + + return 0; +} - if (!request_region( REGION_START(iop3xx_adap), - REGION_LENGTH(iop3xx_adap), - iic_adap->name)) { - return -ENODEV; +static int +iop3xx_i2c_probe(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct resource *res; + int ret; + struct i2c_adapter *new_adapter; + struct i2c_algo_iop3xx_data *adapter_data; + + new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); + if (!new_adapter) { + ret = -ENOMEM; + goto out; } + memset((void*)new_adapter, 0, sizeof(*new_adapter)); - init_waitqueue_head(&iop3xx_adap->waitq); - spin_lock_init(&iop3xx_adap->lock); + adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); + if (!adapter_data) { + ret = -ENOMEM; + goto free_adapter; + } + memset((void*)adapter_data, 0, sizeof(*adapter_data)); - if (request_irq( - iop3xx_adap->biu->irq, - iop3xx_i2c_handler, - /* SA_SAMPLE_RANDOM */ 0, - iic_adap->name, - iop3xx_adap)) { - return -ENODEV; - } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + ret = -ENODEV; + goto free_both; + } - /* register new iic_adapter to i2c module... */ - iic_adap->id |= iic_algo.id; - iic_adap->algo = &iic_algo; + if (!request_mem_region(res->start, IOP3XX_I2C_IO_SIZE, pdev->name)) { + ret = -EBUSY; + goto free_both; + } - iic_adap->timeout = 100; /* default values, should */ - iic_adap->retries = 3; /* be replaced by defines */ + /* set the adapter enumeration # */ + adapter_data->id = i2c_id++; - iop3xx_adap_init(iic_adap->algo_data); - i2c_add_adapter(iic_adap); - return 0; -} + adapter_data->ioaddr = (u32)ioremap(res->start, IOP3XX_I2C_IO_SIZE); + if (!adapter_data->ioaddr) { + ret = -ENOMEM; + goto release_region; + } -static int i2c_iop3xx_del_bus(struct i2c_adapter *iic_adap) -{ - struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data; + res = request_irq(platform_get_irq(pdev, 0), iop3xx_i2c_irq_handler, 0, + pdev->name, adapter_data); + if (res) { + ret = -EIO; + goto unmap; + } - iop3xx_adap_final_cleanup(iop3xx_adap); - free_irq(iop3xx_adap->biu->irq, iop3xx_adap); + memcpy(new_adapter->name, pdev->name, strlen(pdev->name)); + new_adapter->id = I2C_HW_IOP3XX; + new_adapter->owner = THIS_MODULE; + new_adapter->dev.parent = &pdev->dev; - release_region(REGION_START(iop3xx_adap), REGION_LENGTH(iop3xx_adap)); + /* + * Default values...should these come in from board code? + */ + new_adapter->timeout = 100; + new_adapter->retries = 3; + new_adapter->algo = &iop3xx_i2c_algo; - return i2c_del_adapter(iic_adap); -} + init_waitqueue_head(&adapter_data->waitq); + spin_lock_init(&adapter_data->lock); -#ifdef CONFIG_ARCH_IOP321 + iop3xx_i2c_reset(adapter_data); + iop3xx_i2c_set_slave_addr(adapter_data); + iop3xx_i2c_enable(adapter_data); -static struct iop3xx_biu biu0 = { - .CR = IOP321_ICR0, - .SR = IOP321_ISR0, - .SAR = IOP321_ISAR0, - .DBR = IOP321_IDBR0, - .BMR = IOP321_IBMR0, - .irq = IRQ_IOP321_I2C_0, -}; + dev_set_drvdata(&pdev->dev, new_adapter); + new_adapter->algo_data = adapter_data; -static struct iop3xx_biu biu1 = { - .CR = IOP321_ICR1, - .SR = IOP321_ISR1, - .SAR = IOP321_ISAR1, - .DBR = IOP321_IDBR1, - .BMR = IOP321_IBMR1, - .irq = IRQ_IOP321_I2C_1, -}; + i2c_add_adapter(new_adapter); -#define ADAPTER_NAME_ROOT "IOP321 i2c biu adapter " -#else -#error Please define the BIU struct iop3xx_biu for your processor arch -#endif + return 0; -static struct i2c_algo_iop3xx_data algo_iop3xx_data0 = { - .channel = 0, - .biu = &biu0, - .timeout = 1*HZ, -}; -static struct i2c_algo_iop3xx_data algo_iop3xx_data1 = { - .channel = 1, - .biu = &biu1, - .timeout = 1*HZ, -}; +unmap: + iounmap((void __iomem*)adapter_data->ioaddr); -static struct i2c_adapter iop3xx_ops0 = { - .owner = THIS_MODULE, - .name = ADAPTER_NAME_ROOT "0", - .id = I2C_HW_IOP321, - .algo_data = &algo_iop3xx_data0, -}; -static struct i2c_adapter iop3xx_ops1 = { - .owner = THIS_MODULE, - .name = ADAPTER_NAME_ROOT "1", - .id = I2C_HW_IOP321, - .algo_data = &algo_iop3xx_data1, +release_region: + release_mem_region(res->start, IOP3XX_I2C_IO_SIZE); + +free_both: + kfree(adapter_data); + +free_adapter: + kfree(new_adapter); + +out: + return ret; +} + + +static struct device_driver iop3xx_i2c_driver = { + .name = "IOP3xx-I2C", + .bus = &platform_bus_type, + .probe = iop3xx_i2c_probe, + .remove = iop3xx_i2c_remove }; -static int __init i2c_iop3xx_init (void) +static int __init +i2c_iop3xx_init (void) { - return i2c_iop3xx_add_bus(&iop3xx_ops0) || - i2c_iop3xx_add_bus(&iop3xx_ops1); + return driver_register(&iop3xx_i2c_driver); } -static void __exit i2c_iop3xx_exit (void) +static void __exit +i2c_iop3xx_exit (void) { - i2c_iop3xx_del_bus(&iop3xx_ops0); - i2c_iop3xx_del_bus(&iop3xx_ops1); + driver_unregister(&iop3xx_i2c_driver); + return; } module_init (i2c_iop3xx_init); diff --git a/drivers/i2c/busses/i2c-iop3xx.h b/drivers/i2c/busses/i2c-iop3xx.h index f375881842a1..e46ebaea7b1e 100644 --- a/drivers/i2c/busses/i2c-iop3xx.h +++ b/drivers/i2c/busses/i2c-iop3xx.h @@ -25,20 +25,20 @@ /* * iop321 hardware bit definitions */ -#define IOP321_ICR_FAST_MODE 0x8000 /* 1=400kBps, 0=100kBps */ -#define IOP321_ICR_UNIT_RESET 0x4000 /* 1=RESET */ -#define IOP321_ICR_SADIE 0x2000 /* 1=Slave Detect Interrupt Enable */ -#define IOP321_ICR_ALDIE 0x1000 /* 1=Arb Loss Detect Interrupt Enable */ -#define IOP321_ICR_SSDIE 0x0800 /* 1=Slave STOP Detect Interrupt Enable */ -#define IOP321_ICR_BERRIE 0x0400 /* 1=Bus Error Interrupt Enable */ -#define IOP321_ICR_RXFULLIE 0x0200 /* 1=Receive Full Interrupt Enable */ -#define IOP321_ICR_TXEMPTYIE 0x0100 /* 1=Transmit Empty Interrupt Enable */ -#define IOP321_ICR_GCD 0x0080 /* 1=General Call Disable */ +#define IOP3XX_ICR_FAST_MODE 0x8000 /* 1=400kBps, 0=100kBps */ +#define IOP3XX_ICR_UNIT_RESET 0x4000 /* 1=RESET */ +#define IOP3XX_ICR_SAD_IE 0x2000 /* 1=Slave Detect Interrupt Enable */ +#define IOP3XX_ICR_ALD_IE 0x1000 /* 1=Arb Loss Detect Interrupt Enable */ +#define IOP3XX_ICR_SSD_IE 0x0800 /* 1=Slave STOP Detect Interrupt Enable */ +#define IOP3XX_ICR_BERR_IE 0x0400 /* 1=Bus Error Interrupt Enable */ +#define IOP3XX_ICR_RXFULL_IE 0x0200 /* 1=Receive Full Interrupt Enable */ +#define IOP3XX_ICR_TXEMPTY_IE 0x0100 /* 1=Transmit Empty Interrupt Enable */ +#define IOP3XX_ICR_GCD 0x0080 /* 1=General Call Disable */ /* - * IOP321_ICR_GCD: 1 disables response as slave. "This bit must be set + * IOP3XX_ICR_GCD: 1 disables response as slave. "This bit must be set * when sending a master mode general call message from the I2C unit" */ -#define IOP321_ICR_UE 0x0040 /* 1=Unit Enable */ +#define IOP3XX_ICR_UE 0x0040 /* 1=Unit Enable */ /* * "NOTE: To avoid I2C bus integrity problems, * the user needs to ensure that the GPIO Output Data Register - @@ -47,38 +47,38 @@ * The user prepares to enable I2C port 0 and * I2C port 1 by clearing GPOD bits 7:6 and GPOD bits 5:4, respectively. */ -#define IOP321_ICR_SCLEN 0x0020 /* 1=SCL enable for master mode */ -#define IOP321_ICR_MABORT 0x0010 /* 1=Send a STOP with no data +#define IOP3XX_ICR_SCLEN 0x0020 /* 1=SCL enable for master mode */ +#define IOP3XX_ICR_MABORT 0x0010 /* 1=Send a STOP with no data * NB TBYTE must be clear */ -#define IOP321_ICR_TBYTE 0x0008 /* 1=Send/Receive a byte. i2c clears */ -#define IOP321_ICR_NACK 0x0004 /* 1=reply with NACK */ -#define IOP321_ICR_MSTOP 0x0002 /* 1=send a STOP after next data byte */ -#define IOP321_ICR_MSTART 0x0001 /* 1=initiate a START */ +#define IOP3XX_ICR_TBYTE 0x0008 /* 1=Send/Receive a byte. i2c clears */ +#define IOP3XX_ICR_NACK 0x0004 /* 1=reply with NACK */ +#define IOP3XX_ICR_MSTOP 0x0002 /* 1=send a STOP after next data byte */ +#define IOP3XX_ICR_MSTART 0x0001 /* 1=initiate a START */ -#define IOP321_ISR_BERRD 0x0400 /* 1=BUS ERROR Detected */ -#define IOP321_ISR_SAD 0x0200 /* 1=Slave ADdress Detected */ -#define IOP321_ISR_GCAD 0x0100 /* 1=General Call Address Detected */ -#define IOP321_ISR_RXFULL 0x0080 /* 1=Receive Full */ -#define IOP321_ISR_TXEMPTY 0x0040 /* 1=Transmit Empty */ -#define IOP321_ISR_ALD 0x0020 /* 1=Arbitration Loss Detected */ -#define IOP321_ISR_SSD 0x0010 /* 1=Slave STOP Detected */ -#define IOP321_ISR_BBUSY 0x0008 /* 1=Bus BUSY */ -#define IOP321_ISR_UNITBUSY 0x0004 /* 1=Unit Busy */ -#define IOP321_ISR_NACK 0x0002 /* 1=Unit Rx or Tx a NACK */ -#define IOP321_ISR_RXREAD 0x0001 /* 1=READ 0=WRITE (R/W bit of slave addr */ +#define IOP3XX_ISR_BERRD 0x0400 /* 1=BUS ERROR Detected */ +#define IOP3XX_ISR_SAD 0x0200 /* 1=Slave ADdress Detected */ +#define IOP3XX_ISR_GCAD 0x0100 /* 1=General Call Address Detected */ +#define IOP3XX_ISR_RXFULL 0x0080 /* 1=Receive Full */ +#define IOP3XX_ISR_TXEMPTY 0x0040 /* 1=Transmit Empty */ +#define IOP3XX_ISR_ALD 0x0020 /* 1=Arbitration Loss Detected */ +#define IOP3XX_ISR_SSD 0x0010 /* 1=Slave STOP Detected */ +#define IOP3XX_ISR_BBUSY 0x0008 /* 1=Bus BUSY */ +#define IOP3XX_ISR_UNITBUSY 0x0004 /* 1=Unit Busy */ +#define IOP3XX_ISR_NACK 0x0002 /* 1=Unit Rx or Tx a NACK */ +#define IOP3XX_ISR_RXREAD 0x0001 /* 1=READ 0=WRITE (R/W bit of slave addr */ -#define IOP321_ISR_CLEARBITS 0x07f0 +#define IOP3XX_ISR_CLEARBITS 0x07f0 -#define IOP321_ISAR_SAMASK 0x007f +#define IOP3XX_ISAR_SAMASK 0x007f -#define IOP321_IDBR_MASK 0x00ff +#define IOP3XX_IDBR_MASK 0x00ff -#define IOP321_IBMR_SCL 0x0002 -#define IOP321_IBMR_SDA 0x0001 +#define IOP3XX_IBMR_SCL 0x0002 +#define IOP3XX_IBMR_SDA 0x0001 -#define IOP321_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */ -#define IOP321_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */ +#define IOP3XX_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */ +#define IOP3XX_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */ #define MYSAR 0x02 /* SWAG a suitable slave address */ @@ -87,32 +87,21 @@ #define I2C_ERR_ALD (I2C_ERR+1) -struct iop3xx_biu { /* Bus Interface Unit - the hardware */ -/* physical hardware defs - regs*/ - u32 *CR; - u32 *SR; - u32 *SAR; - u32 *DBR; - u32 *BMR; -/* irq bit vector */ - u32 irq; -/* stored flags */ - u32 SR_enabled, SR_received; -}; +#define CR_OFFSET 0 +#define SR_OFFSET 0x4 +#define SAR_OFFSET 0x8 +#define DBR_OFFSET 0xc +#define CCR_OFFSET 0x10 +#define BMR_OFFSET 0x14 -struct i2c_algo_iop3xx_data { - int channel; +#define IOP3XX_I2C_IO_SIZE 0x18 +struct i2c_algo_iop3xx_data { + u32 ioaddr; wait_queue_head_t waitq; spinlock_t lock; - int timeout; - struct iop3xx_biu* biu; + u32 SR_enabled, SR_received; + int id; }; -#define REGION_START(adap) ((u32)((adap)->biu->CR)) -#define REGION_END(adap) ((u32)((adap)->biu->BMR+1)) -#define REGION_LENGTH(adap) (REGION_END(adap)-REGION_START(adap)) - -#define IRQ_STATUS_MASK(adap) (1<biu->irq) - #endif /* I2C_IOP3XX_H */ diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index a75f38041df5..802732f51a23 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -194,7 +194,7 @@ #define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */ #define I2C_ALGO_OCP 0x120000 /* IBM or otherwise On-chip I2C algorithm */ #define I2C_ALGO_BITHS 0x130000 /* enhanced bit style adapters */ -#define I2C_ALGO_OCP_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */ +#define I2C_ALGO_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */ #define I2C_ALGO_PCA 0x150000 /* PCA 9564 style adapters */ #define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */ @@ -270,7 +270,7 @@ #define I2C_HW_SGI_MACE 0x01 /* --- XSCALE on-chip adapters */ -#define I2C_HW_IOP321 0x00 +#define I2C_HW_IOP3XX 0x00 /* --- SMBus only adapters */ #define I2C_HW_SMBUS_PIIX4 0x00 -- cgit v1.2.3 From dd9ce4c0f2f3af77943324d8c5cd0aed95391b85 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 6 Jan 2005 00:38:08 -0800 Subject: [PATCH] debugfs-typo-fix Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- include/linux/debugfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 05042df44f5f..6dc7e3eca188 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -82,7 +82,7 @@ static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode, struct dentry *parent, u8 *value) { - return EFF_PTR(-ENODEV); + return ERR_PTR(-ENODEV); } #endif -- cgit v1.2.3 From 94be39b80794358aa469a32b1ce705f647c14342 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 6 Jan 2005 16:45:22 -0800 Subject: [PATCH] USB: minor usb doc/comment fixes Some minor doc/comment fixes for USB. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/epautoconf.c | 3 +++ drivers/usb/gadget/omap_udc.c | 2 +- include/linux/usb.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 2d529f15bcd5..f7c6d758e1b0 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -55,6 +55,9 @@ static __initdata unsigned in_epnum; * * Type suffixes are "-bulk", "-iso", or "-int". Numbers are decimal. * Less common restrictions are implied by gadget_is_*(). + * + * NOTE: each endpoint is unidirectional, as specified by its USB + * descriptor; and isn't specific to a configuration or altsetting. */ static int __init ep_matches ( diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 98dfa4c850d7..aeb821a5f2c3 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c @@ -1,5 +1,5 @@ /* - * omap_udc.c -- for OMAP 1610 udc, with OTG support + * omap_udc.c -- for OMAP full speed udc; most chips support OTG. * * Copyright (C) 2004 Texas Instruments, Inc. * Copyright (C) 2004 David Brownell diff --git a/include/linux/usb.h b/include/linux/usb.h index 332e07e86b11..7dbcc054c7dc 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -739,8 +739,8 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); * to poll for transfers. After the URB has been submitted, the interval * field reflects how the transfer was actually scheduled. * The polling interval may be more frequent than requested. - * For example, some controllers have a maximum interval of 32 microseconds, - * while others support intervals of up to 1024 microseconds. + * For example, some controllers have a maximum interval of 32 milliseconds, + * while others support intervals of up to 1024 milliseconds. * Isochronous URBs also have transfer intervals. (Note that for isochronous * endpoints, as well as high speed interrupt endpoints, the encoding of * the transfer interval in the endpoint descriptor is logarithmic. -- cgit v1.2.3 From a4ea4100b774242ac1886916e9a752b7873950e6 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 6 Jan 2005 16:45:52 -0800 Subject: [PATCH] USB: definitions for USB2 debug device, debug port This provides basic definitions to support "USB2 Debug Devices", as supported by certain EHCI root hub ports (from ALI, Intel, NVidia, and other vendors). Docs are available at Intel's USB spec webpage. The basic idea is to help debug "legacy free" systems, with no serial port for a console or debugger to use. The USB debug port uses PIO to send and receive at most 8 bytes of high speed data at a time, so it can support one I/O channel without needing _any_ of the usbcore infrastructure, or DMA, or IRQs. (Cost can be 2KB rather than ~150KB.) Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci.h | 24 ++++++++++++++++++++++++ include/linux/usb_ch9.h | 13 +++++++++++++ 2 files changed, 37 insertions(+) (limited to 'include') diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 35de07a9e3b4..e28d19724f56 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -264,6 +264,30 @@ struct ehci_regs { #define PORT_CONNECT (1<<0) /* device connected */ } __attribute__ ((packed)); +/* Appendix C, Debug port ... intended for use with special "debug devices" + * that can help if there's no serial console. (nonstandard enumeration.) + */ +struct ehci_dbg_port { + u32 control; +#define DBGP_OWNER (1<<30) +#define DBGP_ENABLED (1<<28) +#define DBGP_DONE (1<<16) +#define DBGP_INUSE (1<<10) +#define DBGP_ERRCODE(x) (((x)>>7)&0x0f) +# define DBGP_ERR_BAD 1 +# define DBGP_ERR_SIGNAL 2 +#define DBGP_ERROR (1<<6) +#define DBGP_GO (1<<5) +#define DBGP_OUT (1<<4) +#define DBGP_LEN(x) (((x)>>0)&0x0f) + u32 pids; +#define DBGP_PID_GET(x) (((x)>>16)&0xff) +#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok)); + u32 data03; + u32 data47; + u32 address; +#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep)); +} __attribute__ ((packed)); /*-------------------------------------------------------------------------*/ diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h index f08d6241fb63..f5fe94e09a03 100644 --- a/include/linux/usb_ch9.h +++ b/include/linux/usb_ch9.h @@ -79,6 +79,7 @@ #define USB_DEVICE_B_HNP_ENABLE 3 /* dev may initiate HNP */ #define USB_DEVICE_A_HNP_SUPPORT 4 /* RH port supports HNP */ #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* other RH port does */ +#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ #define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ @@ -323,6 +324,18 @@ struct usb_otg_descriptor { /*-------------------------------------------------------------------------*/ +/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ +struct usb_debug_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + /* bulk endpoints with 8 byte maxpacket */ + __u8 bDebugInEndpoint; + __u8 bDebugOutEndpoint; +}; + +/*-------------------------------------------------------------------------*/ + /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ struct usb_interface_assoc_descriptor { __u8 bLength; -- cgit v1.2.3 From b3aa40315f5f2eb84e9f53f87974e08c1343e416 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Thu, 6 Jan 2005 19:14:41 -0800 Subject: [PATCH] I2C: add new sensors driver: SMSC LPC47B397-NC This patch (3rd time's a charm) adds support for the SMSC LPC47B397-NC sensor chip. It was sponsored by In-Store Broadcasting Network. Signed-off-by: Craig Kelly (In-Store Broadcasting Network) Signed-off-by: Glenn Ball (Utilitek Systems, Inc.) Signed-off-by: Mark M. Hoffman --- Documentation/i2c/chips/smsc47b397.txt | 146 ++++++++++++++ drivers/i2c/chips/Kconfig | 12 ++ drivers/i2c/chips/Makefile | 1 + drivers/i2c/chips/smsc47b397.c | 353 +++++++++++++++++++++++++++++++++ include/linux/i2c-id.h | 1 + 5 files changed, 513 insertions(+) create mode 100644 Documentation/i2c/chips/smsc47b397.txt create mode 100644 drivers/i2c/chips/smsc47b397.c (limited to 'include') diff --git a/Documentation/i2c/chips/smsc47b397.txt b/Documentation/i2c/chips/smsc47b397.txt new file mode 100644 index 000000000000..389edae7f8df --- /dev/null +++ b/Documentation/i2c/chips/smsc47b397.txt @@ -0,0 +1,146 @@ +November 23, 2004 + +The following specification describes the SMSC LPC47B397-NC sensor chip +(for which there is no public datasheet available). This document was +provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected +by Mark M. Hoffman . + +* * * * * + +Methods for detecting the HP SIO and reading the thermal data on a dc7100. + +The thermal information on the dc7100 is contained in the SIO Hardware Monitor +(HWM). The information is accessed through an index/data pair. The index/data +pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The +HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) +and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and +0x480 and 0x481 for the index/data pair. + +Reading temperature information. +The temperature information is located in the following registers: +Temp1 0x25 (Currently, this reflects the CPU temp on all systems). +Temp2 0x26 +Temp3 0x27 +Temp4 0x80 + +Programming Example +The following is an example of how to read the HWM temperature registers: +MOV DX,480H +MOV AX,25H +OUT DX,AL +MOV DX,481H +IN AL,DX + +AL contains the data in hex, the temperature in Celsius is the decimal +equivalent. + +Ex: If AL contains 0x2A, the temperature is 42 degrees C. + +Reading tach information. +The fan speed information is located in the following registers: + LSB MSB +Tach1 0x28 0x29 (Currently, this reflects the CPU + fan speed on all systems). +Tach2 0x2A 0x2B +Tach3 0x2C 0x2D +Tach4 0x2E 0x2F + +Important!!! +Reading the tach LSB locks the tach MSB. +The LSB Must be read first. + +How to convert the tach reading to RPM. +The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) +The SIO counts the number of 90kHz (11.111us) pulses per revolution. +RPM = 60/(TCount * 11.111us) + +Example: +Reg 0x28 = 0x9B +Reg 0x29 = 0x08 + +TCount = 0x89B = 2203 + +RPM = 60 / (2203 * 11.11111 E-6) = 2451 RPM + +Obtaining the SIO version. + +CONFIGURATION SEQUENCE +To program the configuration registers, the following sequence must be followed: +1. Enter Configuration Mode +2. Configure the Configuration Registers +3. Exit Configuration Mode. + +Enter Configuration Mode +To place the chip into the Configuration State The config key (0x55) is written +to the CONFIG PORT (0x2E). + +Configuration Mode +In configuration mode, the INDEX PORT is located at the CONFIG PORT address and +the DATA PORT is at INDEX PORT address + 1. + +The desired configuration registers are accessed in two steps: +a. Write the index of the Logical Device Number Configuration Register + (i.e., 0x07) to the INDEX PORT and then write the number of the + desired logical device to the DATA PORT. + +b. Write the address of the desired configuration register within the + logical device to the INDEX PORT and then write or read the config- + uration register through the DATA PORT. + +Note: If accessing the Global Configuration Registers, step (a) is not required. + +Exit Configuration Mode +To exit the Configuration State the write 0xAA to the CONFIG PORT (0x2E). +The chip returns to the RUN State. (This is important). + +Programming Example +The following is an example of how to read the SIO Device ID located at 0x20 + +; ENTER CONFIGURATION MODE +MOV DX,02EH +MOV AX,055H +OUT DX,AL +; GLOBAL CONFIGURATION REGISTER +MOV DX,02EH +MOV AL,20H +OUT DX,AL +; READ THE DATA +MOV DX,02FH +IN AL,DX +; EXIT CONFIGURATION MODE +MOV DX,02EH +MOV AX,0AAH +OUT DX,AL + +The registers of interest for identifying the SIO on the dc7100 are Device ID +(0x20) and Device Rev (0x21). + +The Device ID will read 0X6F +The Device Rev currently reads 0x01 + +Obtaining the HWM Base Address. +The following is an example of how to read the HWM Base Address located in +Logical Device 8. + +; ENTER CONFIGURATION MODE +MOV DX,02EH +MOV AX,055H +OUT DX,AL +; CONFIGURE REGISTER CRE0, +; LOGICAL DEVICE 8 +MOV DX,02EH +MOV AL,07H +OUT DX,AL ;Point to LD# Config Reg +MOV DX,02FH +MOV AL, 08H +OUT DX,AL;Point to Logical Device 8 +; +MOV DX,02EH +MOV AL,60H +OUT DX,AL ; Point to HWM Base Addr MSB +MOV DX,02FH +IN AL,DX ; Get MSB of HWM Base Addr +; EXIT CONFIGURATION MODE +MOV DX,02EH +MOV AX,0AAH +OUT DX,AL diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index f1f35409ab8d..1c4ba5619908 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig @@ -239,6 +239,18 @@ config SENSORS_PC87360 This driver can also be built as a module. If so, the module will be called pc87360. +config SENSORS_SMSC47B397 + tristate "SMSC LPC47B397-NC" + depends on I2C && EXPERIMENTAL + select I2C_SENSOR + select I2C_ISA + help + If you say yes here you get support for the SMSC LPC47B397-NC + sensor chip. + + This driver can also be built as a module. If so, the module + will be called smsc47b397. + config SENSORS_SMSC47M1 tristate "SMSC LPC47M10x and compatibles" depends on I2C && EXPERIMENTAL diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 90dd7dd0ca14..74dd56873a8b 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o +obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o diff --git a/drivers/i2c/chips/smsc47b397.c b/drivers/i2c/chips/smsc47b397.c new file mode 100644 index 000000000000..aab9f246d7e2 --- /dev/null +++ b/drivers/i2c/chips/smsc47b397.c @@ -0,0 +1,353 @@ +/* + smsc47b397.c - Part of lm_sensors, Linux kernel modules + for hardware monitoring + + Supports the SMSC LPC47B397-NC Super-I/O chip. + + Author/Maintainer: Mark M. Hoffman + Copyright (C) 2004 Utilitek Systems, Inc. + + derived in part from smsc47m1.c: + Copyright (C) 2002 Mark D. Studebaker + Copyright (C) 2004 Jean Delvare + + 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. +*/ + +#include +#include +#include +#include +#include +#include +#include + +static unsigned short normal_i2c[] = { I2C_CLIENT_END }; +/* Address is autodetected, there is no default value */ +static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; +static struct i2c_force_data forces[] = {{NULL}}; + +enum chips { any_chip, smsc47b397 }; +static struct i2c_address_data addr_data = { + .normal_i2c = normal_i2c, + .normal_isa = normal_isa, + .probe = normal_i2c, /* cheat */ + .ignore = normal_i2c, /* cheat */ + .forces = forces, +}; + +/* Super-I/0 registers and commands */ + +#define REG 0x2e /* The register to read/write */ +#define VAL 0x2f /* The value to read/write */ + +static inline void superio_outb(int reg, int val) +{ + outb(reg, REG); + outb(val, VAL); +} + +static inline int superio_inb(int reg) +{ + outb(reg, REG); + return inb(VAL); +} + +/* select superio logical device */ +static inline void superio_select(int ld) +{ + superio_outb(0x07, ld); +} + +static inline void superio_enter(void) +{ + outb(0x55, REG); +} + +static inline void superio_exit(void) +{ + outb(0xAA, REG); +} + +#define SUPERIO_REG_DEVID 0x20 +#define SUPERIO_REG_DEVREV 0x21 +#define SUPERIO_REG_BASE_MSB 0x60 +#define SUPERIO_REG_BASE_LSB 0x61 +#define SUPERIO_REG_LD8 0x08 + +#define SMSC_EXTENT 0x02 + +/* 0 <= nr <= 3 */ +static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80}; +#define SMSC47B397_REG_TEMP(nr) (smsc47b397_reg_temp[(nr)]) + +/* 0 <= nr <= 3 */ +#define SMSC47B397_REG_FAN_LSB(nr) (0x28 + 2 * (nr)) +#define SMSC47B397_REG_FAN_MSB(nr) (0x29 + 2 * (nr)) + +struct smsc47b397_data { + struct i2c_client client; + struct semaphore lock; + + struct semaphore update_lock; + unsigned long last_updated; /* in jiffies */ + int valid; + + /* register values */ + u16 fan[4]; + u8 temp[4]; +}; + +static int smsc47b397_read_value(struct i2c_client *client, u8 reg) +{ + struct smsc47b397_data *data = i2c_get_clientdata(client); + int res; + + down(&data->lock); + outb(reg, client->addr); + res = inb_p(client->addr + 1); + up(&data->lock); + return res; +} + +static struct smsc47b397_data *smsc47b397_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct smsc47b397_data *data = i2c_get_clientdata(client); + int i; + + down(&data->update_lock); + + if (time_after(jiffies - data->last_updated, (unsigned long)HZ) + || time_before(jiffies, data->last_updated) || !data->valid) { + + dev_dbg(&client->dev, "starting device update...\n"); + + /* 4 temperature inputs, 4 fan inputs */ + for (i = 0; i < 4; i++) { + data->temp[i] = smsc47b397_read_value(client, + SMSC47B397_REG_TEMP(i)); + + /* must read LSB first */ + data->fan[i] = smsc47b397_read_value(client, + SMSC47B397_REG_FAN_LSB(i)); + data->fan[i] |= smsc47b397_read_value(client, + SMSC47B397_REG_FAN_MSB(i)) << 8; + } + + data->last_updated = jiffies; + data->valid = 1; + + dev_dbg(&client->dev, "... device update complete\n"); + } + + up(&data->update_lock); + + return data; +} + +/* TEMP: 0.001C/bit (-128C to +127C) + REG: 1C/bit, two's complement */ +static int temp_from_reg(u8 reg) +{ + return (s8)reg * 1000; +} + +/* 0 <= nr <= 3 */ +static ssize_t show_temp(struct device *dev, char *buf, int nr) +{ + struct smsc47b397_data *data = smsc47b397_update_device(dev); + return sprintf(buf, "%d\n", temp_from_reg(data->temp[nr])); +} + +#define sysfs_temp(num) \ +static ssize_t show_temp##num(struct device *dev, char *buf) \ +{ \ + return show_temp(dev, buf, num-1); \ +} \ +static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL) + +sysfs_temp(1); +sysfs_temp(2); +sysfs_temp(3); +sysfs_temp(4); + +#define device_create_file_temp(client, num) \ + device_create_file(&client->dev, &dev_attr_temp##num##_input) + +/* FAN: 1 RPM/bit + REG: count of 90kHz pulses / revolution */ +static int fan_from_reg(u16 reg) +{ + return 90000 * 60 / reg; +} + +/* 0 <= nr <= 3 */ +static ssize_t show_fan(struct device *dev, char *buf, int nr) +{ + struct smsc47b397_data *data = smsc47b397_update_device(dev); + return sprintf(buf, "%d\n", fan_from_reg(data->fan[nr])); +} + +#define sysfs_fan(num) \ +static ssize_t show_fan##num(struct device *dev, char *buf) \ +{ \ + return show_fan(dev, buf, num-1); \ +} \ +static DEVICE_ATTR(fan##num##_input, S_IRUGO, show_fan##num, NULL) + +sysfs_fan(1); +sysfs_fan(2); +sysfs_fan(3); +sysfs_fan(4); + +#define device_create_file_fan(client, num) \ + device_create_file(&client->dev, &dev_attr_fan##num##_input) + +static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind); + +static int smsc47b397_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_detect(adapter, &addr_data, smsc47b397_detect); +} + +static int smsc47b397_detach_client(struct i2c_client *client) +{ + int err; + + if ((err = i2c_detach_client(client))) { + dev_err(&client->dev, "Client deregistration failed, " + "client not detached.\n"); + return err; + } + + release_region(client->addr, SMSC_EXTENT); + kfree(i2c_get_clientdata(client)); + + return 0; +} + +static struct i2c_driver smsc47b397_driver = { + .owner = THIS_MODULE, + .name = "smsc47b397", + .id = I2C_DRIVERID_SMSC47B397, + .flags = I2C_DF_NOTIFY, + .attach_adapter = smsc47b397_attach_adapter, + .detach_client = smsc47b397_detach_client, +}; + +static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) +{ + struct i2c_client *new_client; + struct smsc47b397_data *data; + int err = 0; + + if (!i2c_is_isa_adapter(adapter)) { + return 0; + } + + if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) { + dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr); + return -EBUSY; + } + + if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { + err = -ENOMEM; + goto error_release; + } + memset(data, 0x00, sizeof(struct smsc47b397_data)); + + new_client = &data->client; + i2c_set_clientdata(new_client, data); + new_client->addr = addr; + init_MUTEX(&data->lock); + new_client->adapter = adapter; + new_client->driver = &smsc47b397_driver; + new_client->flags = 0; + + strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE); + + init_MUTEX(&data->update_lock); + + if ((err = i2c_attach_client(new_client))) + goto error_free; + + device_create_file_temp(new_client, 1); + device_create_file_temp(new_client, 2); + device_create_file_temp(new_client, 3); + device_create_file_temp(new_client, 4); + + device_create_file_fan(new_client, 1); + device_create_file_fan(new_client, 2); + device_create_file_fan(new_client, 3); + device_create_file_fan(new_client, 4); + + return 0; + +error_free: + kfree(new_client); +error_release: + release_region(addr, SMSC_EXTENT); + return err; +} + +static int __init smsc47b397_find(unsigned int *addr) +{ + u8 id, rev; + + superio_enter(); + id = superio_inb(SUPERIO_REG_DEVID); + + if (id != 0x6f) { + superio_exit(); + return -ENODEV; + } + + rev = superio_inb(SUPERIO_REG_DEVREV); + + superio_select(SUPERIO_REG_LD8); + *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) + | superio_inb(SUPERIO_REG_BASE_LSB); + + printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " + "(base address 0x%04x, revision %u)\n", *addr, rev); + + superio_exit(); + return 0; +} + +static int __init smsc47b397_init(void) +{ + int ret; + + if ((ret = smsc47b397_find(normal_isa))) + return ret; + + return i2c_add_driver(&smsc47b397_driver); +} + +static void __exit smsc47b397_exit(void) +{ + i2c_del_driver(&smsc47b397_driver); +} + +MODULE_AUTHOR("Mark M. Hoffman "); +MODULE_DESCRIPTION("SMSC LPC47B397 driver"); +MODULE_LICENSE("GPL"); + +module_init(smsc47b397_init); +module_exit(smsc47b397_exit); diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 802732f51a23..bfa2d557d47a 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -167,6 +167,7 @@ #define I2C_DRIVERID_ASB100 1043 #define I2C_DRIVERID_FSCHER 1046 #define I2C_DRIVERID_W83L785TS 1047 +#define I2C_DRIVERID_SMSC47B397 1050 /* * ---- Adapter types ---------------------------------------------------- -- cgit v1.2.3 From c8cf06ef69645994704a36ad1bcb556211102e6f Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:57:44 -0800 Subject: [PATCH] m68knommu: cache init code for ColdFire CPU's Cache initialization code for the ColdFire CPU's. They are not all identical. This code is used as part of the common head start code for all ColdFire platforms. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/mcfcache.h | 125 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 include/asm-m68knommu/mcfcache.h (limited to 'include') diff --git a/include/asm-m68knommu/mcfcache.h b/include/asm-m68knommu/mcfcache.h new file mode 100644 index 000000000000..136587b6ae60 --- /dev/null +++ b/include/asm-m68knommu/mcfcache.h @@ -0,0 +1,125 @@ +/****************************************************************************/ + +/* + * mcfcache.h -- ColdFire CPU cache support code + * + * (C) Copyright 2004, Greg Ungerer + */ + +/****************************************************************************/ +#ifndef __M68KNOMMU_MCFCACHE_H +#define __M68KNOMMU_MCFCACHE_H +/****************************************************************************/ + +#include + +/* + * The different ColdFire families have different cache arrangments. + * Everything from a small linstruction only cache, to configurable + * data and/or instruction cache, to unified instruction/data, to + * harvard style separate instruction and data caches. + */ + +#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || defined(CONFIG_M5272) +/* + * Simple verion 2 core cache. These have instruction cache only, + * we just need to invalidate it and enable it. + */ +.macro CACHE_ENABLE + movel #0x01000000,%d0 /* invalidate cache cmd */ + movec %d0,%CACR /* do invalidate cache */ + movel #0x80000100,%d0 /* setup cache mask */ + movec %d0,%CACR /* enable cache */ +.endm +#endif /* CONFIG_M5206 || CONFIG_M5206e || CONFIG_M5272 */ + +#if defined(CONFIG_M527x) +/* + * New version 2 cores have a configurable split cache arrangement. + * For now I am just enabling instruction cache - but ultimately I + * think a split instruction/data cache would be better. + */ +.macro CACHE_ENABLE + movel #0x01400000,%d0 + movec %d0,%CACR /* invalidate cache */ + nop + movel #0x0000c000,%d0 /* set SDRAM cached only */ + movec %d0,%ACR0 + movel #0x00000000,%d0 /* no other regions cached */ + movec %d0,%ACR1 + movel #0x80400100,%d0 /* configure cache */ + movec %d0,%CACR /* enable cache */ + nop +.endm +#endif /* CONFIG_M527x */ + +#if defined(CONFIG_M528x) +/* + * Cache is totally broken on early 5282 silicon. So far now we + * disable its cache all together. + */ +.macro CACHE_ENABLE + movel #0x01000000,%d0 + movec %d0,%CACR /* invalidate cache */ + nop + movel #0x0000c000,%d0 /* set SDRAM cached only */ + movec %d0,%ACR0 + movel #0x00000000,%d0 /* no other regions cached */ + movec %d0,%ACR1 + movel #0x00000000,%d0 /* configure cache */ + movec %d0,%CACR /* enable cache */ + nop +.endm +#endif /* CONFIG_M528x */ + +#if defined(CONFIG_M5249) || defined(CONFIG_M5307) +/* + * The version 3 core cache. Oddly enough the version 2 core 5249 + * has the same SDRAM and cache setup as the version 3 cores. + * This is a single unified instruction/data cache. + */ +.macro CACHE_ENABLE + movel #0x01000000,%d0 /* invalidate whole cache */ + movec %d0,%CACR + nop +#if defined(DEBUGGER_COMPATIBLE_CACHE) || defined(CONFIG_SECUREEDGEMP3) + movel #0x0000c000,%d0 /* set SDRAM cached (write-thru) */ +#else + movel #0x0000c020,%d0 /* set SDRAM cached (copyback) */ +#endif + movec %d0,%ACR0 + movel #0x00000000,%d0 /* no other regions cached */ + movec %d0,%ACR1 + movel #0xa0000200,%d0 /* enable cache */ + movec %d0,%CACR + nop +.endm +#endif /* CONFIG_M5249 || CONFIG_M5307 */ + +#if defined(CONFIG_M5407) +/* + * Version 4 cores have a true hardvard style separate instruction + * and data cache. Invalidate and enable cache, also enable write + * buffers and branch accelerator. + */ +.macro CACHE_ENABLE + movel #0x01040100,%d0 /* invalidate whole cache */ + movec %d0,%CACR + nop + movel #0x000fc000,%d0 /* set SDRAM cached only */ + movec %d0, %ACR0 + movel #0x00000000,%d0 /* no other regions cached */ + movec %d0, %ACR1 + movel #0x000fc000,%d0 /* set SDRAM cached only */ + movec %d0, %ACR2 + movel #0x00000000,%d0 /* no other regions cached */ + movec %d0, %ACR3 + movel #0xb6088400,%d0 /* enable caches */ + movec %d0,%CACR + nop +.endm +#endif /* CONFIG_M5407 */ + + +/****************************************************************************/ +#endif /* __M68KNOMMU_MCFCACHE_H */ -- cgit v1.2.3 From 011e3cde7c310a621575ad373f676363c127a447 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:57:59 -0800 Subject: [PATCH] m68knommu: change ColdFire 5206 SDRAM register names Change the SDRAM register names to be consistent across all ColdFire header files. Simplied their use in common memory sizing code at startup time. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/m5206sim.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/asm-m68knommu/m5206sim.h b/include/asm-m68knommu/m5206sim.h index 2bfb23ff8b27..d1e7509021c5 100644 --- a/include/asm-m68knommu/m5206sim.h +++ b/include/asm-m68knommu/m5206sim.h @@ -47,12 +47,12 @@ #define MCFSIM_DCRR 0x46 /* DRAM Refresh reg (r/w) */ #define MCFSIM_DCTR 0x4a /* DRAM Timing reg (r/w) */ -#define MCFSIM_DCAR0 0x4c /* DRAM 0 Address reg(r/w) */ -#define MCFSIM_DCMR0 0x50 /* DRAM 0 Mask reg (r/w) */ -#define MCFSIM_DCCR0 0x57 /* DRAM 0 Control reg (r/w) */ -#define MCFSIM_DCAR1 0x58 /* DRAM 1 Address reg (r/w) */ -#define MCFSIM_DCMR1 0x5c /* DRAM 1 Mask reg (r/w) */ -#define MCFSIM_DCCR1 0x63 /* DRAM 1 Control reg (r/w) */ +#define MCFSIM_DAR0 0x4c /* DRAM 0 Address reg(r/w) */ +#define MCFSIM_DMR0 0x50 /* DRAM 0 Mask reg (r/w) */ +#define MCFSIM_DCR0 0x57 /* DRAM 0 Control reg (r/w) */ +#define MCFSIM_DAR1 0x58 /* DRAM 1 Address reg (r/w) */ +#define MCFSIM_DMR1 0x5c /* DRAM 1 Mask reg (r/w) */ +#define MCFSIM_DCR1 0x63 /* DRAM 1 Control reg (r/w) */ #define MCFSIM_CSAR0 0x64 /* CS 0 Address 0 reg (r/w) */ #define MCFSIM_CSMR0 0x68 /* CS 0 Mask 0 reg (r/w) */ -- cgit v1.2.3 From cf85dd228196ba3026b43cc9c37bf0f259a362a4 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:58:12 -0800 Subject: [PATCH] m68knommu: move ColdFire 5249 platform specific startup code Move some platform specific setup code into the ColdFire 5249 header. Doing this for platforms that needs it means the startup code can be identical for all ColdFire based platforms. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/m5249sim.h | 90 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'include') diff --git a/include/asm-m68knommu/m5249sim.h b/include/asm-m68knommu/m5249sim.h index 2ca313637b17..9344f529bd8f 100644 --- a/include/asm-m68knommu/m5249sim.h +++ b/include/asm-m68knommu/m5249sim.h @@ -115,5 +115,95 @@ #define mcf_getipr() \ *((volatile unsigned long *) (MCF_MBAR + MCFSIM_IPR)) +/****************************************************************************/ + +#ifdef __ASSEMBLER__ + +/* + * The M5249C3 board needs a little help getting all its SIM devices + * initialized at kernel start time. dBUG doesn't set much up, so + * we need to do it manually. + */ +.macro m5249c3_setup + /* + * Set MBAR1 and MBAR2, just incase they are not set. + */ + movel #0x10000001,%a0 + movec %a0,%MBAR /* map MBAR region */ + subql #1,%a0 /* get MBAR address in a0 */ + + movel #0x80000001,%a1 + movec %a1,#3086 /* map MBAR2 region */ + subql #1,%a1 /* get MBAR2 address in a1 */ + + /* + * Move secondary interrupts to base at 128. + */ + moveb #0x80,%d0 + moveb %d0,0x16b(%a1) /* interrupt base register */ + + /* + * Work around broken CSMR0/DRAM vector problem. + */ + movel #0x001F0021,%d0 /* disable C/I bit */ + movel %d0,0x84(%a0) /* set CSMR0 */ + + /* + * Disable the PLL firstly. (Who knows what state it is + * in here!). + */ + movel 0x180(%a1),%d0 /* get current PLL value */ + andl #0xfffffffe,%d0 /* PLL bypass first */ + movel %d0,0x180(%a1) /* set PLL register */ + nop + +#ifdef CONFIG_CLOCK_140MHz + /* + * Set initial clock frequency. This assumes M5249C3 board + * is fitted with 11.2896MHz crystal. It will program the + * PLL for 140MHz. Lets go fast :-) + */ + movel #0x125a40f0,%d0 /* set for 140MHz */ + movel %d0,0x180(%a1) /* set PLL register */ + orl #0x1,%d0 + movel %d0,0x180(%a1) /* set PLL register */ +#endif + + /* + * Setup CS1 for ethernet controller. + * (Setup as per M5249C3 doco). + */ + movel #0xe0000000,%d0 /* CS1 mapped at 0xe0000000 */ + movel %d0,0x8c(%a0) + movel #0x001f0021,%d0 /* CS1 size of 1Mb */ + movel %d0,0x90(%a0) + movew #0x0080,%d0 /* CS1 = 16bit port, AA */ + movew %d0,0x96(%a0) + + /* + * Setup CS2 for IDE interface. + */ + movel #0x50000000,%d0 /* CS2 mapped at 0x50000000 */ + movel %d0,0x98(%a0) + movel #0x001f0001,%d0 /* CS2 size of 1MB */ + movel %d0,0x9c(%a0) + movew #0x0080,%d0 /* CS2 = 16bit, TA */ + movew %d0,0xa2(%a0) + + movel #0x00107000,%d0 /* IDEconfig1 */ + movel %d0,0x18c(%a1) + movel #0x000c0400,%d0 /* IDEconfig2 */ + movel %d0,0x190(%a1) + + movel #0x00080000,%d0 /* GPIO19, IDE reset bit */ + orl %d0,0xc(%a1) /* function GPIO19 */ + orl %d0,0x8(%a1) /* enable GPIO19 as output */ + orl %d0,0x4(%a1) /* de-assert IDE reset */ +.endm + +#define PLATFORM_SETUP m5249c3_setup + +#endif /* __ASSEMBLER__ */ + /****************************************************************************/ #endif /* m5249sim_h */ -- cgit v1.2.3 From e6cd81eb2a3554a5d5a80cf50adb65976ed9b1a4 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:58:28 -0800 Subject: [PATCH] m68knommu: define differences in ColdFire 5270/1 and 5274/5 SDRAM registers The 527[01] ColdFire devices and the 527[45] devices have a very similar SDRAM register setup. But some registers are at different addresses. Define them appropriately so common sizing code can work for all ColdFire platforms. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/m527xsim.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/asm-m68knommu/m527xsim.h b/include/asm-m68knommu/m527xsim.h index 82a39bca5664..d280d013da03 100644 --- a/include/asm-m68knommu/m527xsim.h +++ b/include/asm-m68knommu/m527xsim.h @@ -34,5 +34,25 @@ #define MCFINT_UART2 15 /* Interrupt number for UART2 */ #define MCFINT_PIT1 36 /* Interrupt number for PIT1 */ +/* + * SDRAM configuration registers. + */ +#ifdef CONFIG_M5271EVB +#define MCFSIM_DCR 0x40 /* SDRAM control */ +#define MCFSIM_DACR0 0x48 /* SDRAM base address 0 */ +#define MCFSIM_DMR0 0x4c /* SDRAM address mask 0 */ +#define MCFSIM_DACR1 0x50 /* SDRAM base address 1 */ +#define MCFSIM_DMR1 0x54 /* SDRAM address mask 1 */ +#else +#define MCFSIM_DMR 0x40 /* SDRAM mode */ +#define MCFSIM_DCR 0x44 /* SDRAM control */ +#define MCFSIM_DCFG1 0x48 /* SDRAM configuration 1 */ +#define MCFSIM_DCFG2 0x4c /* SDRAM configuration 2 */ +#define MCFSIM_DBAR0 0x50 /* SDRAM base address 0 */ +#define MCFSIM_DMR0 0x54 /* SDRAM address mask 0 */ +#define MCFSIM_DBAR1 0x58 /* SDRAM base address 1 */ +#define MCFSIM_DMR1 0x5c /* SDRAM address mask 1 */ +#endif + /****************************************************************************/ #endif /* m527xsim_h */ -- cgit v1.2.3 From f800b0c06dad3b39c205ba6289560e55ffced15e Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:58:41 -0800 Subject: [PATCH] m68knommu: definitions for the SDRAM registers on the ColdFire 528x CPU's Add definitions for the SDRAM configuration registers on the 528x ColdFire CPU's. Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/m528xsim.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/asm-m68knommu/m528xsim.h b/include/asm-m68knommu/m528xsim.h index bc91a4bf5458..371993a206ac 100644 --- a/include/asm-m68knommu/m528xsim.h +++ b/include/asm-m68knommu/m528xsim.h @@ -32,5 +32,14 @@ #define MCFINT_UART0 13 /* Interrupt number for UART0 */ #define MCFINT_PIT1 55 /* Interrupt number for PIT1 */ +/* + * SDRAM configuration registers. + */ +#define MCFSIM_DCR 0x44 /* SDRAM control */ +#define MCFSIM_DACR0 0x48 /* SDRAM base address 0 */ +#define MCFSIM_DMR0 0x4c /* SDRAM address mask 0 */ +#define MCFSIM_DACR1 0x50 /* SDRAM base address 1 */ +#define MCFSIM_DMR1 0x54 /* SDRAM address mask 1 */ + /****************************************************************************/ #endif /* m528xsim_h */ -- cgit v1.2.3 From 2fabc7c1e9338b51b1337a96e47012cd55be8e29 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:58:56 -0800 Subject: [PATCH] m68knommu: remove duplicate THREAD_SIZE define Remove duplicated definition of THREAD_SIZE, it is defined in page.h. Also modify asm constraints to explicilty let gas know that the input arg is a constant in the current_thread_info() function. Patch originally submitted by Philippe De Muyter Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/thread_info.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include') diff --git a/include/asm-m68knommu/thread_info.h b/include/asm-m68knommu/thread_info.h index dcdc2b33dcf7..72d8839531d0 100644 --- a/include/asm-m68knommu/thread_info.h +++ b/include/asm-m68knommu/thread_info.h @@ -12,12 +12,6 @@ #ifdef __KERNEL__ -/* - * Size of kernel stack for each process. This must be a power of 2... - */ -#define THREAD_SIZE 8192 /* 2 pages */ - - #ifndef __ASSEMBLY__ /* @@ -59,7 +53,7 @@ static inline struct thread_info *current_thread_info(void) "move.l %%sp, %0 \n\t" "and.l %1, %0" : "=&d"(ti) - : "d" (~(THREAD_SIZE-1)) + : "di" (~(THREAD_SIZE-1)) ); return ti; } -- cgit v1.2.3 From 65f075a594462dbccba53b7236881abdd51bc52b Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Sun, 9 Jan 2005 15:59:23 -0800 Subject: [PATCH] m68knommu: optimize atomic macros For some reason the asm versions of atomic_dec_and_test and friends were masked by inefficient and big macros. With it I spare up to 8k in the text size of my coldfire linux and 5k on my cpu32 version. Patch originally submitted by Philippe De Muyter Signed-off-by: Greg Ungerer Signed-off-by: Linus Torvalds --- include/asm-m68knommu/atomic.h | 74 +++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/asm-m68knommu/atomic.h b/include/asm-m68knommu/atomic.h index 0f33ee426b8a..b1957fba083b 100644 --- a/include/asm-m68knommu/atomic.h +++ b/include/asm-m68knommu/atomic.h @@ -20,36 +20,79 @@ typedef struct { int counter; } atomic_t; static __inline__ void atomic_add(int i, atomic_t *v) { - __asm__ __volatile__("addl %1,%0" : "=m" (*v) : "d" (i), "0" (*v)); +#ifdef CONFIG_COLDFIRE + __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "d" (i)); +#else + __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "di" (i)); +#endif } static __inline__ void atomic_sub(int i, atomic_t *v) { - __asm__ __volatile__("subl %1,%0" : "=m" (*v) : "d" (i), "0" (*v)); +#ifdef CONFIG_COLDFIRE + __asm__ __volatile__("subl %1,%0" : "+m" (*v) : "d" (i)); +#else + __asm__ __volatile__("subl %1,%0" : "+m" (*v) : "di" (i)); +#endif +} + +static __inline__ int atomic_sub_and_test(int i, atomic_t * v) +{ + char c; +#ifdef CONFIG_COLDFIRE + __asm__ __volatile__("subl %2,%1; seq %0" + : "=d" (c), "+m" (*v) + : "d" (i)); +#else + __asm__ __volatile__("subl %2,%1; seq %0" + : "=d" (c), "+m" (*v) + : "di" (i)); +#endif + return c != 0; } static __inline__ void atomic_inc(volatile atomic_t *v) { - __asm__ __volatile__("addql #1,%0" : "=m" (*v): "0" (*v)); + __asm__ __volatile__("addql #1,%0" : "+m" (*v)); +} + +/* + * atomic_inc_and_test - increment and test + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1 + * and returns true if the result is zero, or false for all + * other cases. + */ + +static __inline__ int atomic_inc_and_test(volatile atomic_t *v) +{ + char c; + __asm__ __volatile__("addql #1,%1; seq %0" : "=d" (c), "+m" (*v)); + return c != 0; } static __inline__ void atomic_dec(volatile atomic_t *v) { - __asm__ __volatile__("subql #1,%0" : "=m" (*v): "0" (*v)); + __asm__ __volatile__("subql #1,%0" : "+m" (*v)); } static __inline__ int atomic_dec_and_test(volatile atomic_t *v) { char c; - __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "=m" (*v): "1" (*v)); + __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "+m" (*v)); return c != 0; } -#define atomic_clear_mask(mask, v) \ - __asm__ __volatile__("andl %1,%0" : "=m" (*v) : "id" (~(mask)),"0"(*v)) +static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *v) +{ + __asm__ __volatile__("andl %1,%0" : "+m" (*v) : "id" (~(mask))); +} -#define atomic_set_mask(mask, v) \ - __asm__ __volatile__("orl %1,%0" : "=m" (*v) : "id" (mask),"0"(*v)) +static __inline__ void atomic_set_mask(unsigned long mask, unsigned long *v) +{ + __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask)); +} /* Atomic operations are already serializing */ #define smp_mb__before_atomic_dec() barrier() @@ -88,17 +131,4 @@ extern __inline__ int atomic_sub_return(int i, atomic_t * v) #define atomic_dec_return(v) atomic_sub_return(1,(v)) #define atomic_inc_return(v) atomic_add_return(1,(v)) -/* - * atomic_inc_and_test - increment and test - * @v: pointer of type atomic_t - * - * Atomically increments @v by 1 - * and returns true if the result is zero, or false for all - * other cases. - */ -#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) - -#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0) -#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) - #endif /* __ARCH_M68KNOMMU_ATOMIC __ */ -- cgit v1.2.3 From c91b9fc3ed6d60da5a3dec17fe63161307c6de68 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Sun, 9 Jan 2005 16:50:42 -0800 Subject: [PATCH] Fix gcc 4 compilation in ACPI extern declaration of static Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds --- include/acpi/processor.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/acpi/processor.h b/include/acpi/processor.h index f501eefd8976..5e3db76ccab2 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -177,7 +177,6 @@ int acpi_processor_notify_smm(struct module *calling_module); /* for communication between multiple parts of the processor kernel module */ extern struct acpi_processor *processors[NR_CPUS]; extern struct acpi_processor_errata errata; -extern void (*pm_idle_save)(void); /* in processor_perflib.c */ #ifdef CONFIG_CPU_FREQ -- cgit v1.2.3 From aafeed4acb2307b07383ed70e781c091cccf3ddd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 9 Jan 2005 17:20:09 -0800 Subject: Don't use __GFP_CLEAR for user pages. It doesn't do the virtual cache synchronization that clear_user_highpage() does. Pointed out by Hugh Dickins. --- include/linux/gfp.h | 1 - mm/memory.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 823589766569..b526b21bad1c 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -53,7 +53,6 @@ struct vm_area_struct; #define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) #define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS) #define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM) -#define GFP_HIGHZERO (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM | __GFP_ZERO) /* Flag - indicates that the buffer will be suitable for DMA. Ignored on some platforms, used as appropriate on others */ diff --git a/mm/memory.c b/mm/memory.c index 9e7f1ca3aa95..31451af257dd 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1795,9 +1795,10 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, if (unlikely(anon_vma_prepare(vma))) goto no_mem; - page = alloc_page_vma(GFP_HIGHZERO, vma, addr); + page = alloc_page_vma(GFP_HIGHUSER, vma, addr); if (!page) goto no_mem; + clear_user_highpage(page, addr); spin_lock(&mm->page_table_lock); page_table = pte_offset_map(pmd, addr); -- cgit v1.2.3 From a9625ef18290632e9b2abf9e63bb90c0b9cb64a6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 9 Jan 2005 23:18:02 -0800 Subject: [PATCH] fix __ptrace_unlink TASK_TRACED recovery for real parent The __ptrace_unlink code that checks for TASK_TRACED fixed the problem of a thread being left in TASK_TRACED when no longer being ptraced. However, an oversight in the original fix made it fail to handle the case where the child is ptraced by its real parent. Fixed thus. Signed-off-by: Roland McGrath Signed-off-by: Linus Torvalds --- include/linux/ptrace.h | 1 + kernel/exit.c | 2 +- kernel/ptrace.c | 47 +++++++++++++++++++++++++---------------------- 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index f18247125091..a373fc254df2 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -87,6 +87,7 @@ extern void ptrace_notify(int exit_code); extern void __ptrace_link(struct task_struct *child, struct task_struct *new_parent); extern void __ptrace_unlink(struct task_struct *child); +extern void ptrace_untrace(struct task_struct *child); static inline void ptrace_link(struct task_struct *child, struct task_struct *new_parent) diff --git a/kernel/exit.c b/kernel/exit.c index 54a59c727356..7127c15faf28 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -557,7 +557,7 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced) * a normal stop since it's no longer being * traced. */ - p->state = TASK_STOPPED; + ptrace_untrace(p); } } diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 60801c692810..794f7d0a670d 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -44,6 +44,23 @@ static inline int pending_resume_signal(struct sigpending *pending) return sigtestsetmask(&pending->signal, M(SIGCONT) | M(SIGKILL)); } +/* + * Turn a tracing stop into a normal stop now, since with no tracer there + * would be no way to wake it up with SIGCONT or SIGKILL. If there was a + * signal sent that would resume the child, but didn't because it was in + * TASK_TRACED, resume it now. + */ +void ptrace_untrace(task_t *child) +{ + spin_lock(&child->sighand->siglock); + child->state = TASK_STOPPED; + if (pending_resume_signal(&child->pending) || + pending_resume_signal(&child->signal->shared_pending)) { + signal_wake_up(child, 1); + } + spin_unlock(&child->sighand->siglock); +} + /* * unptrace a task: move it back to its original parent and * remove it from the ptrace list. @@ -55,29 +72,15 @@ void __ptrace_unlink(task_t *child) if (!child->ptrace) BUG(); child->ptrace = 0; - if (list_empty(&child->ptrace_list)) - return; - list_del_init(&child->ptrace_list); - REMOVE_LINKS(child); - child->parent = child->real_parent; - SET_LINKS(child); - - if (child->state == TASK_TRACED) { - /* - * Turn a tracing stop into a normal stop now, - * since with no tracer there would be no way - * to wake it up with SIGCONT or SIGKILL. - * If there was a signal sent that would resume the child, - * but didn't because it was in TASK_TRACED, resume it now. - */ - spin_lock(&child->sighand->siglock); - child->state = TASK_STOPPED; - if (pending_resume_signal(&child->pending) || - pending_resume_signal(&child->signal->shared_pending)) { - signal_wake_up(child, 1); - } - spin_unlock(&child->sighand->siglock); + if (!list_empty(&child->ptrace_list)) { + list_del_init(&child->ptrace_list); + REMOVE_LINKS(child); + child->parent = child->real_parent; + SET_LINKS(child); } + + if (child->state == TASK_TRACED) + ptrace_untrace(child); } /* -- cgit v1.2.3 From 167bfb35652f4e4dfa9bccf44c1df47692da83c7 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 10 Jan 2005 21:23:00 +0000 Subject: [ARM PATCH] 2372/1: S3C2410 - remove s3c2410_clock_tick_rate Patch from Ben Dooks This is an old definition, and is no longer used anywhere. Add a comment to that effect in the header file include/asm-arm/arch-s3c2410/timex.h and remove all other references. Thanks to Klaus Fetscher for pointing out that it isn't used anymore Signed-off-by: Ben Dooks Signed-off-by: Russell King --- arch/arm/mach-s3c2410/s3c2410.c | 5 ++--- include/asm-arm/arch-s3c2410/timex.h | 16 +++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c index 66a34913c0a9..0d0fb36d7b58 100644 --- a/arch/arm/mach-s3c2410/s3c2410.c +++ b/arch/arm/mach-s3c2410/s3c2410.c @@ -1,6 +1,6 @@ /* linux/arch/arm/mach-s3c2410/s3c2410.c * - * Copyright (c) 2003,2004 Simtec Electronics + * Copyright (c) 2003-2005 Simtec Electronics * Ben Dooks * * http://www.simtec.co.uk/products/EB2410ITX/ @@ -17,6 +17,7 @@ * 21-Aug-2004 BJD Added new struct s3c2410_board handler * 28-Sep-2004 BJD Updates for new serial port bits * 04-Nov-2004 BJD Updated UART configuration process + * 10-Jan-2004 BJD Removed s3c2410_clock_tick_rate */ #include @@ -42,8 +43,6 @@ #include "cpu.h" #include "clock.h" -int s3c2410_clock_tick_rate = 12*1000*1000; /* current timers at 12MHz */ - /* Initial IO mappings */ static struct map_desc s3c2410_iodesc[] __initdata = { diff --git a/include/asm-arm/arch-s3c2410/timex.h b/include/asm-arm/arch-s3c2410/timex.h index 44aa0dcf8fcc..3558a3a750bf 100644 --- a/include/asm-arm/arch-s3c2410/timex.h +++ b/include/asm-arm/arch-s3c2410/timex.h @@ -1,6 +1,6 @@ /* linux/include/asm-arm/arch-s3c2410/timex.h * - * (c) 2003,2004 Simtec Electronics + * (c) 2003-2005 Simtec Electronics * Ben Dooks * * S3C2410 - time parameters @@ -13,21 +13,19 @@ * 02-Sep-2003 BJD Created file * 05-Jan-2004 BJD Updated for Linux 2.6.0 * 22-Nov-2004 BJD Fixed CLOCK_TICK_RATE + * 10-Jan-2004 BJD Removed s3c2410_clock_tick_rate */ #ifndef __ASM_ARCH_TIMEX_H #define __ASM_ARCH_TIMEX_H -#if 0 -/* todo - this does not seem to work with 2.6.0 -> division by zero - * in header files - */ -extern int s3c2410_clock_tick_rate; +/* CLOCK_TICK_RATE needs to be evaluatable by the cpp, so making it + * a variable is useless. It seems as long as we make our timers an + * exact multiple of HZ, any value that makes a 1->1 correspondence + * for the time conversion functions to/from jiffies is acceptable. +*/ -#define CLOCK_TICK_RATE (s3c2410_clock_tick_rate) -#endif -/* currently, the BAST uses 12MHz as a base clock rate */ #define CLOCK_TICK_RATE 12000000 -- cgit v1.2.3 From 020af26601348413538994709defc57030aee487 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 10 Jan 2005 21:28:56 +0000 Subject: [ARM PATCH] 2373/1: S3C2410 - fix possible loop in irq macro Patch from Ben Dooks If we read the INTPEND register and get the wrong result (details below) then it looks like a possible loop to go back and re-read it after calculating the possible correct value for it. It seems that the INTPEND register, which should show the unique number of the interrupt that we need to handle. However, it seems that this register can show the wrong interrupt under certain conditions. Shannon's research shows that it is very possible that the occurence of an external interrupt can end up merging with the base interrupt number, causing the wrong result in the register. This patch also fixes the end position of the #ifdef block and ensures as many registers as possible are stacked before calling printk() for debug. Original patch for 2.6.9 by Shannon Holland re-written for 2.6.10 by Ben Dooks. Signed-off-by: Shannon Holland Signed-off-by: Ben Dooks Signed-off-by: Russell King --- include/asm-arm/arch-s3c2410/entry-macro.S | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/asm-arm/arch-s3c2410/entry-macro.S b/include/asm-arm/arch-s3c2410/entry-macro.S index ee4b3cff87d3..c5d0310e96c5 100644 --- a/include/asm-arm/arch-s3c2410/entry-macro.S +++ b/include/asm-arm/arch-s3c2410/entry-macro.S @@ -8,11 +8,12 @@ * warranty of any kind, whether express or implied. */ - .macro get_irqnr_and_base, irqnr, irqstat, base, tmp -30000: + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + mov \tmp, #S3C2410_VA_IRQ ldr \irqnr, [ \tmp, #0x14 ] @ get irq no +30000: teq \irqnr, #4 teqne \irqnr, #5 beq 1002f @ external irq reg @@ -29,15 +30,17 @@ tst \irqstat, #1 bne 20002f + /* debug/warning if we get an invalud response from the + * INTOFFSET register */ #if 1 - stmfd r13!, { r0 - r4 , r14 } - ldr r1, [ \tmp, #0x14 ] @ intoffset + stmfd r13!, { r0 - r4 , r8-r12, r14 } + ldr r1, [ \tmp, #0x14 ] @ INTOFFSET ldr r2, [ \tmp, #0x10 ] @ INTPND ldr r3, [ \tmp, #0x00 ] @ SRCPND adr r0, 20003f bl printk b 20004f -#endif + 20003: .ascii "<7>irq: err - bad offset %d, intpnd=%08x, srcpnd=%08x\n" .byte 0 @@ -45,7 +48,8 @@ 20004: mov r1, #1 mov \tmp, #S3C2410_VA_IRQ - ldmfd r13!, { r0 - r4 , r14 } + ldmfd r13!, { r0 - r4 , r8-r12, r14 } +#endif @ try working out interript number for ourselves mov \irqnr, #0 -- cgit v1.2.3 From e911b333ab9ec0b637b8656d7ca57267a5601df1 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 10 Jan 2005 21:48:31 +0000 Subject: [ARM PATCH] 2374/1: S3C2410 - remove unused code from entry-macro.S Patch from Ben Dooks Remove code for decoding LCD Frame/FIFO IRQs from the include/asm-arm/arch-s3c2410/entry-macro.S file. These are not currently implemented, and should be decoded by a chained IRQ handler from the irq code. Signed-off-by: Ben Dooks Signed-off-by: Russell King --- include/asm-arm/arch-s3c2410/entry-macro.S | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'include') diff --git a/include/asm-arm/arch-s3c2410/entry-macro.S b/include/asm-arm/arch-s3c2410/entry-macro.S index c5d0310e96c5..4cc886ed1dbb 100644 --- a/include/asm-arm/arch-s3c2410/entry-macro.S +++ b/include/asm-arm/arch-s3c2410/entry-macro.S @@ -17,8 +17,6 @@ teq \irqnr, #4 teqne \irqnr, #5 beq 1002f @ external irq reg - teq \irqnr, #16 - beq 1003f @ lcd controller @ debug check to see if interrupt reported is the same @ as the offset.... @@ -51,7 +49,7 @@ ldmfd r13!, { r0 - r4 , r8-r12, r14 } #endif - @ try working out interript number for ourselves + @ try working out interrupt number for ourselves mov \irqnr, #0 ldr \irqstat, [ \tmp, #0x10 ] @ INTPND 10021: @@ -102,19 +100,6 @@ @ found no interrupt, set Z flag and leave movs \irqnr, #0 - b 1001f - -1003: - @ lcd interrupt has been asserted... - add \tmp, \tmp, #S3C2410_VA_LCD - S3C2410_VA_IRQ - ldr \irqstat, [ \tmp, # 0x54 ] @ lcd int pending - - tst \irqstat, #2 - movne \irqnr, #IRQ_LCD_FRAME - tst \irqstat, #1 - movne \irqnr, #IRQ_LCD_FIFO - - @ fall through to exit with flags updated 1004: @ ensure Z flag clear in case our MOVS shifted out the last bit teq \irqnr, #0 -- cgit v1.2.3 From 530f8ae2d9852c73afbe2ec5e989c40d1d89214d Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 10 Jan 2005 22:07:21 +0000 Subject: [ARM PATCH] 2370/1: Add common Sharp SCOOP driver code Patch from Richard Purdie Add common driver code for the SCOOP I/O interface found on various Sharp PDAs (Collie, Poodle and Corgi models). It will be used by both SA1100 and PXA machines. [A patch to update Collie to use this driver will follow.] Signed-off-by: Richard Purdie Signed-off-by: Russell King --- arch/arm/Kconfig | 5 ++ arch/arm/common/Makefile | 1 + arch/arm/common/scoop.c | 132 +++++++++++++++++++++++++++++++++++++++ include/asm-arm/hardware/scoop.h | 47 ++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 arch/arm/common/scoop.c create mode 100644 include/asm-arm/hardware/scoop.h (limited to 'include') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e93530a40b8c..dc5864554f0c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -234,6 +234,11 @@ config SHARP_LOCOMO depends on SA1100_COLLIE default y +config SHARP_SCOOP + bool + depends on PXA_SHARPSL + default y + config FORCE_MAX_ZONEORDER int depends on SA1111 diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index 5b9f9eddddec..ba4a9d3957cc 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o obj-$(CONFIG_DMABOUNCE) += dmabounce.o obj-$(CONFIG_TIMER_ACORN) += time-acorn.o obj-$(CONFIG_SHARP_LOCOMO) += locomo.o +obj-$(CONFIG_SHARP_SCOOP) += scoop.o diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c new file mode 100644 index 000000000000..141dd460732f --- /dev/null +++ b/arch/arm/common/scoop.c @@ -0,0 +1,132 @@ +/* + * Support code for the SCOOP interface found on various Sharp PDAs + * + * Copyright (c) 2004 Richard Purdie + * + * Based on code written by Sharp/Lineo for 2.4 kernels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include + +static void __iomem *scoop_io_base; + +#define SCOOP_REG(adr) (*(volatile unsigned short*)(scoop_io_base+(adr))) + +void reset_scoop(void) +{ + SCOOP_REG(SCOOP_MCR) = 0x0100; // 00 + SCOOP_REG(SCOOP_CDR) = 0x0000; // 04 + SCOOP_REG(SCOOP_CPR) = 0x0000; // 0C + SCOOP_REG(SCOOP_CCR) = 0x0000; // 10 + SCOOP_REG(SCOOP_IMR) = 0x0000; // 18 + SCOOP_REG(SCOOP_IRM) = 0x00FF; // 14 + SCOOP_REG(SCOOP_ISR) = 0x0000; // 1C + SCOOP_REG(SCOOP_IRM) = 0x0000; +} + +static spinlock_t scoop_lock = SPIN_LOCK_UNLOCKED; +static u32 scoop_gpwr; + +unsigned short set_scoop_gpio(unsigned short bit) +{ + unsigned short gpio_bit; + unsigned long flag; + + spin_lock_irqsave(&scoop_lock, flag); + gpio_bit = SCOOP_REG(SCOOP_GPWR) | bit; + SCOOP_REG(SCOOP_GPWR) = gpio_bit; + spin_unlock_irqrestore(&scoop_lock, flag); + + return gpio_bit; +} + +unsigned short reset_scoop_gpio(unsigned short bit) +{ + unsigned short gpio_bit; + unsigned long flag; + + spin_lock_irqsave(&scoop_lock, flag); + gpio_bit = SCOOP_REG(SCOOP_GPWR) & ~bit; + SCOOP_REG(SCOOP_GPWR) = gpio_bit; + spin_unlock_irqrestore(&scoop_lock, flag); + + return gpio_bit; +} + +EXPORT_SYMBOL(set_scoop_gpio); +EXPORT_SYMBOL(reset_scoop_gpio); + +unsigned short read_scoop_reg(unsigned short reg) +{ + return SCOOP_REG(reg); +} + +void write_scoop_reg(unsigned short reg, unsigned short data) +{ + SCOOP_REG(reg)=data; +} + +EXPORT_SYMBOL(reset_scoop); +EXPORT_SYMBOL(read_scoop_reg); +EXPORT_SYMBOL(write_scoop_reg); + +static int scoop_suspend(struct device *dev, uint32_t state, uint32_t level) +{ + if (level == SUSPEND_POWER_DOWN) { + scoop_gpwr = SCOOP_REG(SCOOP_GPWR); + SCOOP_REG(SCOOP_GPWR) = 0; + } + return 0; +} + +static int scoop_resume(struct device *dev, uint32_t level) +{ + if (level == RESUME_POWER_ON) { + SCOOP_REG(SCOOP_GPWR) = scoop_gpwr; + } + return 0; +} + +int __init scoop_probe(struct device *dev) +{ + struct scoop_config *inf; + struct platform_device *pdev = to_platform_device(dev); + struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + if (!mem) return -EINVAL; + + inf = dev->platform_data; + scoop_io_base = ioremap(mem->start, 0x1000); + if (!scoop_io_base) return -ENOMEM; + + SCOOP_REG(SCOOP_MCR) = 0x0140; + + reset_scoop(); + + SCOOP_REG(SCOOP_GPCR) = inf->io_dir & 0xffff; + SCOOP_REG(SCOOP_GPWR) = inf->io_out & 0xffff; + + return 0; +} + +static struct device_driver scoop_driver = { + .name = "sharp-scoop", + .bus = &platform_bus_type, + .probe = scoop_probe, + .suspend = scoop_suspend, + .resume = scoop_resume, +}; + +int __init scoop_init(void) +{ + return driver_register(&scoop_driver); +} + +subsys_initcall(scoop_init); diff --git a/include/asm-arm/hardware/scoop.h b/include/asm-arm/hardware/scoop.h new file mode 100644 index 000000000000..669b7df6e570 --- /dev/null +++ b/include/asm-arm/hardware/scoop.h @@ -0,0 +1,47 @@ +/* + * Definitions for the SCOOP interface found on various Sharp PDAs + * + * Copyright (c) 2004 Richard Purdie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#define SCOOP_MCR 0x00 +#define SCOOP_CDR 0x04 +#define SCOOP_CSR 0x08 +#define SCOOP_CPR 0x0C +#define SCOOP_CCR 0x10 +#define SCOOP_IRR 0x14 +#define SCOOP_IRM 0x14 +#define SCOOP_IMR 0x18 +#define SCOOP_ISR 0x1C +#define SCOOP_GPCR 0x20 +#define SCOOP_GPWR 0x24 +#define SCOOP_GPRR 0x28 + +#define SCOOP_GPCR_PA22 ( 1 << 12 ) +#define SCOOP_GPCR_PA21 ( 1 << 11 ) +#define SCOOP_GPCR_PA20 ( 1 << 10 ) +#define SCOOP_GPCR_PA19 ( 1 << 9 ) +#define SCOOP_GPCR_PA18 ( 1 << 8 ) +#define SCOOP_GPCR_PA17 ( 1 << 7 ) +#define SCOOP_GPCR_PA16 ( 1 << 6 ) +#define SCOOP_GPCR_PA15 ( 1 << 5 ) +#define SCOOP_GPCR_PA14 ( 1 << 4 ) +#define SCOOP_GPCR_PA13 ( 1 << 3 ) +#define SCOOP_GPCR_PA12 ( 1 << 2 ) +#define SCOOP_GPCR_PA11 ( 1 << 1 ) + +struct scoop_config { + unsigned short io_out; + unsigned short io_dir; +}; + +void reset_scoop(void); +unsigned short set_scoop_gpio(unsigned short bit); +unsigned short reset_scoop_gpio(unsigned short bit); +unsigned short read_scoop_reg(unsigned short reg); +void write_scoop_reg(unsigned short reg, unsigned short data); -- cgit v1.2.3 From 8c81b0878a8c6abd44f82b5fea9f664fec9c0bb2 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 10 Jan 2005 22:19:47 +0000 Subject: [ARM PATCH] 2371/1: PXA: Add machine support for the Sharp SL-C7xx series of PDAs Patch from Richard Purdie Add base machine support for the Sharp SL-C7xx series of PDAs (Corgi - SL-C700, Shepherd - SL-C750 and Husky - SL-C760). See linux-arm-kernel for a support commitment for this code. Depends on 2370/1 (SCOOP Driver). Signed-off-by: Richard Purdie Signed-off-by: Russell King --- MAINTAINERS | 5 ++ arch/arm/mach-pxa/Kconfig | 20 +++++ arch/arm/mach-pxa/Makefile | 1 + arch/arm/mach-pxa/corgi.c | 159 +++++++++++++++++++++++++++++++++++++++ include/asm-arm/arch-pxa/corgi.h | 133 ++++++++++++++++++++++++++++++++ 5 files changed, 318 insertions(+) create mode 100644 arch/arm/mach-pxa/corgi.c create mode 100644 include/asm-arm/arch-pxa/corgi.h (limited to 'include') diff --git a/MAINTAINERS b/MAINTAINERS index da90e2c0a1e9..79be31b0462a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -287,6 +287,11 @@ P: Dave Gilbert M: linux@treblig.org S: Maintained +ARM/CORGI MACHINE SUPPORT +P: Richard Purdie +M: rpurdie@rpsys.net +S: Maintained + ARM/PLEB SUPPORT P: Peter Chubb M: pleb@gelato.unsw.edu.au diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig index bb28824d8cd1..f09e49d30efa 100644 --- a/arch/arm/mach-pxa/Kconfig +++ b/arch/arm/mach-pxa/Kconfig @@ -18,10 +18,30 @@ config ARCH_PXA_IDP bool "Accelent Xscale IDP" select PXA25x +config PXA_SHARPSL + bool "SHARP SL-C7xx Models (Corgi, Shepherd and Husky)" + select PXA25x + help + Say Y here if you intend to run this kernel on a + Sharp SL-C700 (Corgi), SL-C750 (Shepherd) or a + Sharp SL-C760 (Husky) handheld computer. + endchoice endmenu +config MACH_CORGI + bool "Enable Sharp SL-C700 (Corgi) Support" + depends PXA_SHARPSL + +config MACH_SHEPHERD + bool "Enable Sharp SL-C750 (Shepherd) Support" + depends PXA_SHARPSL + +config MACH_HUSKY + bool "Enable Sharp SL-C760 (Husky) Support" + depends PXA_SHARPSL + config PXA25x bool help diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile index 23c51e388a91..0464f512de95 100644 --- a/arch/arm/mach-pxa/Makefile +++ b/arch/arm/mach-pxa/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_PXA27x) += pxa27x.o obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o obj-$(CONFIG_ARCH_PXA_IDP) += idp.o +obj-$(CONFIG_PXA_SHARPSL) += corgi.o # Support for blinky lights led-y := leds.o diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c new file mode 100644 index 000000000000..8173808121f7 --- /dev/null +++ b/arch/arm/mach-pxa/corgi.c @@ -0,0 +1,159 @@ +/* + * Support for Sharp SL-C7xx PDAs + * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky) + * + * Copyright (c) 2004-2005 Richard Purdie + * + * Based on Sharp's 2.4 kernel patches/lubbock.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "generic.h" + +extern void corgi_ssp_lcdtg_send (u8 adrs, u8 data); + +static void __init corgi_init_irq(void) +{ + pxa_init_irq(); +} + +static struct resource corgi_scoop_resources[] = { + [0] = { + .start = 0x10800000, + .end = 0x10800fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct scoop_config corgi_scoop_setup = { + .io_dir = CORGI_SCOOP_IO_DIR, + .io_out = CORGI_SCOOP_IO_OUT, +}; + +static struct platform_device corgiscoop_device = { + .name = "sharp-scoop", + .id = -1, + .dev = { + .platform_data = &corgi_scoop_setup, + }, + .num_resources = ARRAY_SIZE(corgi_scoop_resources), + .resource = corgi_scoop_resources, +}; + +static struct platform_device *devices[] __initdata = { + &corgiscoop_device, +}; + +static struct sharpsl_flash_param_info sharpsl_flash_param; + +void corgi_get_param(void) +{ + sharpsl_flash_param.comadj_keyword = readl(FLASH_MEM_BASE + FLASH_COMADJ_MAGIC_ADR); + sharpsl_flash_param.comadj = readl(FLASH_MEM_BASE + FLASH_COMADJ_DATA_ADR); + + sharpsl_flash_param.phad_keyword = readl(FLASH_MEM_BASE + FLASH_PHAD_MAGIC_ADR); + sharpsl_flash_param.phadadj = readl(FLASH_MEM_BASE + FLASH_PHAD_DATA_ADR); +} + +static void __init corgi_init(void) +{ + platform_add_devices(devices, ARRAY_SIZE(devices)); +} + +static void __init fixup_corgi(struct machine_desc *desc, + struct tag *tags, char **cmdline, struct meminfo *mi) +{ + corgi_get_param(); + mi->nr_banks=1; + mi->bank[0].start = 0xa0000000; + mi->bank[0].node = 0; + if (machine_is_corgi()) + mi->bank[0].size = (32*1024*1024); + else + mi->bank[0].size = (64*1024*1024); +} + +static struct map_desc corgi_io_desc[] __initdata = { +/* virtual physical length */ +/* { 0xf1000000, 0x08000000, 0x01000000, MT_DEVICE },*/ /* LCDC (readable for Qt driver) */ +/* { 0xef700000, 0x10800000, 0x00001000, MT_DEVICE },*/ /* SCOOP */ + { 0xef800000, 0x00000000, 0x00800000, MT_DEVICE }, /* Boot Flash */ +}; + +static void __init corgi_map_io(void) +{ + pxa_map_io(); + iotable_init(corgi_io_desc,ARRAY_SIZE(corgi_io_desc)); + + /* setup sleep mode values */ + PWER = 0x00000002; + PFER = 0x00000000; + PRER = 0x00000002; + PGSR0 = 0x0158C000; + PGSR1 = 0x00FF0080; + PGSR2 = 0x0001C004; + /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ + PCFR |= PCFR_OPDE; +} + +#ifdef CONFIG_MACH_CORGI +MACHINE_START(CORGI, "SHARP Corgi") + BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000)) + FIXUP(fixup_corgi) + MAPIO(corgi_map_io) + INITIRQ(corgi_init_irq) + .init_machine = corgi_init, + .timer = &pxa_timer, +MACHINE_END +#endif + +#ifdef CONFIG_MACH_SHEPHERD +MACHINE_START(SHEPHERD, "SHARP Shepherd") + BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000)) + FIXUP(fixup_corgi) + MAPIO(corgi_map_io) + INITIRQ(corgi_init_irq) + .init_machine = corgi_init, + .timer = &pxa_timer, +MACHINE_END +#endif + +#ifdef CONFIG_MACH_HUSKY +MACHINE_START(HUSKY, "SHARP Husky") + BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000)) + FIXUP(fixup_corgi) + MAPIO(corgi_map_io) + INITIRQ(corgi_init_irq) + .init_machine = corgi_init, + .timer = &pxa_timer, +MACHINE_END +#endif + diff --git a/include/asm-arm/arch-pxa/corgi.h b/include/asm-arm/arch-pxa/corgi.h new file mode 100644 index 000000000000..9cfd9c47b366 --- /dev/null +++ b/include/asm-arm/arch-pxa/corgi.h @@ -0,0 +1,133 @@ +/* + * Hardware specific definitions for SL-C7xx series of PDAs + * + * Copyright (c) 2004-2005 Richard Purdie + * + * Based on Sharp's 2.4 kernel patches + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#ifndef __ASM_ARCH_CORGI_H +#define __ASM_ARCH_CORGI_H 1 + + +/* + * Corgi GPIO definitions + */ +#define CORGI_GPIO_KEY_INT (0) /* key interrupt */ +#define CORGI_GPIO_AC_IN (1) +#define CORGI_GPIO_WAKEUP (3) +#define CORGI_GPIO_AK_INT (4) // Remote Controller +#define CORGI_GPIO_TP_INT (5) /* Touch Panel interrupt */ +#define CORGI_GPIO_nSD_CLK (6) +#define CORGI_GPIO_nSD_WP (7) +#define CORGI_GPIO_nSD_DETECT (9) +#define CORGI_GPIO_nSD_INT (10) +#define CORGI_GPIO_MAIN_BAT_LOW (11) +#define CORGI_GPIO_BAT_COVER (11) +#define CORGI_GPIO_LED_ORANGE (13) +#define CORGI_GPIO_CF_CD (14) +#define CORGI_GPIO_CHRG_FULL (16) +#define CORGI_GPIO_CF_IRQ (17) +#define CORGI_GPIO_ADC_TEMP_ON (21) +#define CORGI_GPIO_IR_ON (22) +#define CORGI_GPIO_SD_PWR (33) +#define CORGI_GPIO_CHRG_ON (38) +#define CORGI_GPIO_DISCHARGE_ON (42) +#define CORGI_GPIO_HSYNC (44) +#define CORGI_GPIO_USB_PULLUP (45) + + +/* + * Corgi Keyboard Definitions + */ +#define CORGI_KEY_STROBE_NUM (12) +#define CORGI_KEY_SENSE_NUM (8) +#define CORGI_GPIO_ALL_STROBE_BIT (0x00003ffc) +#define CORGI_GPIO_HIGH_SENSE_BIT (0xfc000000) +#define CORGI_GPIO_HIGH_SENSE_RSHIFT (26) +#define CORGI_GPIO_LOW_SENSE_BIT (0x00000003) +#define CORGI_GPIO_LOW_SENSE_LSHIFT (6) +#define CORGI_GPIO_STROBE_BIT(a) GPIO_bit(66+(a)) +#define CORGI_GPIO_SENSE_BIT(a) GPIO_bit(58+(a)) +#define CORGI_GAFR_ALL_STROBE_BIT (0x0ffffff0) +#define CORGI_GAFR_HIGH_SENSE_BIT (0xfff00000) +#define CORGI_GAFR_LOW_SENSE_BIT (0x0000000f) +#define CORGI_GPIO_KEY_SENSE(a) (58+(a)) +#define CORGI_GPIO_KEY_STROBE(a) (66+(a)) + + +/* + * Corgi Interrupts + */ +#define CORGI_IRQ_GPIO_KEY_INT IRQ_GPIO(0) +#define CORGI_IRQ_GPIO_AC_IN IRQ_GPIO(1) +#define CORGI_IRQ_GPIO_WAKEUP IRQ_GPIO(3) +#define CORGI_IRQ_GPIO_AK_INT IRQ_GPIO(4) +#define CORGI_IRQ_GPIO_TP_INT IRQ_GPIO(5) +#define CORGI_IRQ_GPIO_nSD_DETECT IRQ_GPIO(9) +#define CORGI_IRQ_GPIO_nSD_INT IRQ_GPIO(10) +#define CORGI_IRQ_GPIO_MAIN_BAT_LOW IRQ_GPIO(11) +#define CORGI_IRQ_GPIO_CF_CD IRQ_GPIO(14) +#define CORGI_IRQ_GPIO_CHRG_FULL IRQ_GPIO(16) /* Battery fully charged */ +#define CORGI_IRQ_GPIO_CF_IRQ IRQ_GPIO(17) +#define CORGI_IRQ_GPIO_KEY_SENSE(a) IRQ_GPIO(58+(a)) /* Keyboard Sense lines */ + + +/* + * Corgi SCOOP GPIOs and Config + */ +#define CORGI_SCP_LED_GREEN SCOOP_GPCR_PA11 +#define CORGI_SCP_SWA SCOOP_GPCR_PA12 /* Hinge Switch A */ +#define CORGI_SCP_SWB SCOOP_GPCR_PA13 /* Hinge Switch B */ +#define CORGI_SCP_MUTE_L SCOOP_GPCR_PA14 +#define CORGI_SCP_MUTE_R SCOOP_GPCR_PA15 +#define CORGI_SCP_AKIN_PULLUP SCOOP_GPCR_PA16 +#define CORGI_SCP_APM_ON SCOOP_GPCR_PA17 +#define CORGI_SCP_BACKLIGHT_CONT SCOOP_GPCR_PA18 +#define CORGI_SCP_MIC_BIAS SCOOP_GPCR_PA19 + +#define CORGI_SCOOP_IO_DIR ( CORGI_SCP_LED_GREEN | CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R | \ + CORGI_SCP_AKIN_PULLUP | CORGI_SCP_APM_ON | CORGI_SCP_BACKLIGHT_CONT | \ + CORGI_SCP_MIC_BIAS ) +#define CORGI_SCOOP_IO_OUT ( CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R ) + +/* + * Corgi Parameter Area Definitions + */ +#define FLASH_MEM_BASE 0xa0000a00 +#define FLASH_MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a ) + +#define FLASH_COMADJ_MAJIC FLASH_MAGIC_CHG('C','M','A','D') +#define FLASH_COMADJ_MAGIC_ADR 0x00 +#define FLASH_COMADJ_DATA_ADR 0x04 + +#define FLASH_PHAD_MAJIC FLASH_MAGIC_CHG('P','H','A','D') +#define FLASH_PHAD_MAGIC_ADR 0x38 +#define FLASH_PHAD_DATA_ADR 0x3C + +struct sharpsl_flash_param_info { + unsigned int comadj_keyword; + unsigned int comadj; + + unsigned int uuid_keyword; + unsigned char uuid[16]; + + unsigned int touch_keyword; + unsigned int touch1; + unsigned int touch2; + unsigned int touch3; + unsigned int touch4; + + unsigned int adadj_keyword; + unsigned int adadj; + + unsigned int phad_keyword; + unsigned int phadadj; +}; + +#endif /* __ASM_ARCH_CORGI_H */ + -- cgit v1.2.3