Staging: heci: fix some sparse warnings
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 25 Feb 2009 21:06:49 +0000 (13:06 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Apr 2009 21:54:24 +0000 (14:54 -0700)
This resolves a lot of the more obvious sparse warnings in the code.

There still are some major problems in the ioctl handlers dealing with
user and kernel pointers that this patch does not resolve, that needs to
be addressed still.

Also, the locking seems to be a bit strange in places, which sparse
points out, that too need to be resolved.

Cc: Anas Nashif <anas.nashif@intel.com>
Cc: Marcin Obara <marcin.obara@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/heci/heci.h
drivers/staging/heci/heci_data_structures.h
drivers/staging/heci/heci_init.c
drivers/staging/heci/heci_main.c
drivers/staging/heci/io_heci.c

index 9b279f3e84a16f94f1adb295c907fa00d9a4b20e..14192e0cc22795682c178c6e23c7d20261406d1a 100644 (file)
@@ -124,12 +124,12 @@ void heci_wd_timer(unsigned long data);
  *  input output function prototype
  */
 int heci_ioctl_get_version(struct iamt_heci_device *dev, int if_num,
-                          struct heci_message_data *u_msg,
+                          struct heci_message_data __user *u_msg,
                           struct heci_message_data k_msg,
                           struct heci_file_private *file_ext);
 
 int heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
-                             struct heci_message_data *u_msg,
+                             struct heci_message_data __user *u_msg,
                              struct heci_message_data k_msg,
                              struct file *file);
 
@@ -148,7 +148,7 @@ int pthi_write(struct iamt_heci_device *dev,
               struct heci_cb_private *priv_cb);
 
 int pthi_read(struct iamt_heci_device *dev, int if_num, struct file *file,
-             char *ubuf, size_t length, loff_t *offset);
+             char __user *ubuf, size_t length, loff_t *offset);
 
 struct heci_cb_private *find_pthi_read_list_entry(
                        struct iamt_heci_device *dev,
index 14433efa42b33af8bf04b2015ce790e25012d828..575e8f8e88a3303fd0ad2253f272503dae5ef36d 100644 (file)
@@ -428,7 +428,7 @@ struct iamt_heci_device {
         */
        unsigned int mem_base;
        unsigned int mem_length;
-       char *mem_addr;
+       void __iomem *mem_addr;
        /*
         * lock for the device
         */
index dbc5af03fd59e7da6f790bb5afbd357df7db4b9b..a8a0da910cfbbe173f446bcca3a24bf186b6d0b1 100644 (file)
@@ -63,7 +63,7 @@ const __u8 heci_wd_state_independence_msg[3][4] = {
        {0x07, 0x02, 0x01, 0x10}
 };
 
-const struct guid heci_asf_guid = {
+static const struct guid heci_asf_guid = {
        0x75B30CD6, 0xA29E, 0x4AF7,
        {0xA7, 0x12, 0xE6, 0x17, 0x43, 0x93, 0xC8, 0xA6}
 };
index 3db9a03886453f61b6a5222c36846b874dbf4b95..00e44c781428b0f5632df3ac08fc5d6bd7d45f91 100644 (file)
 /*
  *  heci driver strings
  */
-char heci_driver_name[] = HECI_DRIVER_NAME;
-char heci_driver_string[] = "Intel(R) Management Engine Interface";
-char heci_driver_version[] = HECI_DRIVER_VERSION;
-char heci_copyright[] = "Copyright (c) 2003 - 2008 Intel Corporation.";
+static char heci_driver_name[] = HECI_DRIVER_NAME;
+static char heci_driver_string[] = "Intel(R) Management Engine Interface";
+static char heci_driver_version[] = HECI_DRIVER_VERSION;
+static char heci_copyright[] = "Copyright (c) 2003 - 2008 Intel Corporation.";
 
 
 #ifdef HECI_DEBUG
@@ -96,7 +96,7 @@ static int heci_major;
 /* The device pointer */
 static struct pci_dev *heci_device;
 
-struct class *heci_class;
+static struct class *heci_class;
 
 
 /* heci_pci_tbl - PCI Device ID Table */
@@ -1331,7 +1331,7 @@ static int heci_ioctl(struct inode *inode, struct file *file,
        int if_num = iminor(inode);
        struct heci_file_private *file_ext = file->private_data;
        /* in user space */
-       struct heci_message_data *u_msg = (struct heci_message_data *) data;
+       struct heci_message_data __user *u_msg;
        struct heci_message_data k_msg; /* all in kernel on the stack */
        struct iamt_heci_device *dev;
 
@@ -1353,6 +1353,7 @@ static int heci_ioctl(struct inode *inode, struct file *file,
        spin_unlock_bh(&dev->device_lock);
 
        /* first copy from user all data needed */
+       u_msg = (struct heci_message_data __user *)data;
        if (copy_from_user(&k_msg, u_msg, sizeof(k_msg))) {
                DBG("first copy from user all data needed filled\n");
                return -EFAULT;
index d7e06484f96bda984d2b3cab4d25d55544d193a2..f7544a7bbbe0998b37acf2695e280a8bc21cdedd 100644 (file)
@@ -76,7 +76,7 @@
  * returns 0 on success, <0 on failure.
  */
 int heci_ioctl_get_version(struct iamt_heci_device *dev, int if_num,
-                          struct heci_message_data *u_msg,
+                          struct heci_message_data __user *u_msg,
                           struct heci_message_data k_msg,
                           struct heci_file_private *file_ext)
 {
@@ -136,7 +136,7 @@ end:
  * returns 0 on success, <0 on failure.
  */
 int heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
-                             struct heci_message_data *u_msg,
+                             struct heci_message_data __user *u_msg,
                              struct heci_message_data k_msg,
                              struct file *file)
 {
@@ -524,7 +524,7 @@ struct heci_cb_private *find_pthi_read_list_entry(
  *  negative on failure.
  */
 int pthi_read(struct iamt_heci_device *dev, int if_num, struct file *file,
-             char *ubuf, size_t length, loff_t *offset)
+             char __user *ubuf, size_t length, loff_t *offset)
 {
        int rets = 0;
        struct heci_cb_private *priv_cb = NULL;