Pull novell-bugzilla-156426 into release branch
[pandora-kernel.git] / drivers / block / paride / pd.c
index fa49d62..2403721 100644 (file)
@@ -151,6 +151,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
 #include <linux/cdrom.h>       /* for the eject ioctl */
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
+#include <linux/kernel.h>
 #include <asm/uaccess.h>
 #include <linux/sched.h>
 #include <linux/workqueue.h>
@@ -275,7 +276,7 @@ static void pd_print_error(struct pd_unit *disk, char *msg, int status)
        int i;
 
        printk("%s: %s: status = 0x%x =", disk->name, msg, status);
-       for (i = 0; i < 18; i++)
+       for (i = 0; i < ARRAY_SIZE(pd_errs); i++)
                if (status & (1 << i))
                        printk(" %s", pd_errs[i]);
        printk("\n");
@@ -747,32 +748,33 @@ static int pd_open(struct inode *inode, struct file *file)
        return 0;
 }
 
+static int pd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
+{
+       struct pd_unit *disk = bdev->bd_disk->private_data;
+
+       if (disk->alt_geom) {
+               geo->heads = PD_LOG_HEADS;
+               geo->sectors = PD_LOG_SECTS;
+               geo->cylinders = disk->capacity / (geo->heads * geo->sectors);
+       } else {
+               geo->heads = disk->heads;
+               geo->sectors = disk->sectors;
+               geo->cylinders = disk->cylinders;
+       }
+
+       return 0;
+}
+
 static int pd_ioctl(struct inode *inode, struct file *file,
         unsigned int cmd, unsigned long arg)
 {
        struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
-       struct hd_geometry __user *geo = (struct hd_geometry __user *) arg;
-       struct hd_geometry g;
 
        switch (cmd) {
        case CDROMEJECT:
                if (disk->access == 1)
                        pd_special_command(disk, pd_eject);
                return 0;
-       case HDIO_GETGEO:
-               if (disk->alt_geom) {
-                       g.heads = PD_LOG_HEADS;
-                       g.sectors = PD_LOG_SECTS;
-                       g.cylinders = disk->capacity / (g.heads * g.sectors);
-               } else {
-                       g.heads = disk->heads;
-                       g.sectors = disk->sectors;
-                       g.cylinders = disk->cylinders;
-               }
-               g.start = get_start_sect(inode->i_bdev);
-               if (copy_to_user(geo, &g, sizeof(struct hd_geometry)))
-                       return -EFAULT;
-               return 0;
        default:
                return -EINVAL;
        }
@@ -815,6 +817,7 @@ static struct block_device_operations pd_fops = {
        .open           = pd_open,
        .release        = pd_release,
        .ioctl          = pd_ioctl,
+       .getgeo         = pd_getgeo,
        .media_changed  = pd_check_media,
        .revalidate_disk= pd_revalidate
 };