Re: [PATCH v6] mmc: Add mmc CMD+ACMD passthrough ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/4/14 John Calixto <john.calixto@xxxxxxxxxxxxxx>:
[...]

> + Â Â Â /* DAT buffer */
> + Â Â Â __u32 data_ptr_size; Â/* size of the *pointer* */
> + Â Â Â __u64 data_ptr;

So... again... What's the problem with anonymous union of pointer and u64?

Example implementation:

struct mmc_ioc_cmd {
  ...
  union {
    void __user *data_ptr;
    __u64 __data_ptr_storage;
  };
};

static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
  struct mmc_ioc_cmd blk;

  if (cmd != MMC_IOC_CMD)
    return -EINVAL;

  copy_from_user((void __user *)arg, &blk) ...

  return mmc_blk_ioctl_cmd(bdev, &blk);
}

static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t
mode, unsigned int cmd, unsigned long arg)
{
  struct mmc_ioc_cmd blk;

  if (cmd != MMC_IOC_CMD)
    return -EINVAL;

  copy_from_user(compat_ptr(arg), &blk) ...
  blk.data_ptr = compat_ptr(*(__u32 *)&blk.data_ptr);

  return mmc_blk_ioctl_cmd(bdev, &blk);
}

Best Regards,
MichaÅ MirosÅaw
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux