lkml.org 
[lkml]   [2015]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH] mmc: block: Add new ioctl to send combo commands
From
On 10 September 2015 at 10:43, Jon Hunter <jonathanh@nvidia.com> wrote:
> Hi Ulf,
>
> On 09/09/15 13:42, Ulf Hansson wrote:
>
> [snip]
>
>>> +static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>>> + struct mmc_ioc_cmd __user *ic_ptr)
>>> +{
>>> + struct mmc_blk_ioc_data *idata;
>>> + struct mmc_blk_data *md;
>>> + struct mmc_card *card;
>>> + int err;
>>> +
>>> + /*
>>> + * The caller must have CAP_SYS_RAWIO, and must be calling this on the
>>> + * whole block device, not on a partition. This prevents overspray
>>> + * between sibling partitions.
>>> + */
>>> + if ((!capable(CAP_SYS_RAWIO)) || (bdev != bdev->bd_contains))
>>> + return -EPERM;
>>> +
>>> + idata = mmc_blk_ioctl_copy_from_user(ic_ptr);
>>> + if (IS_ERR(idata))
>>> + return PTR_ERR(idata);
>>> +
>>> + md = mmc_blk_get(bdev->bd_disk);
>>> + if (!md) {
>>> + err = -EINVAL;
>>> + goto cmd_err;
>>> + }
>>> +
>>> + card = md->queue.card;
>>> + if (IS_ERR(card)) {
>>> + err = PTR_ERR(card);
>>> + goto cmd_done;
>>> + }
>>> +
>>> + mmc_claim_host(card->host);
>>
>> As __mmc_blk_ioctl_cmd() already does mmc_get_card(), you don't need
>> mmc_claim_host() here.
>
> Thinking about this some more, does it make sense to have a
> mmc_get_card() above and then remove the one from __mmc_blk_ioctl_cmd()?
> The mmc_blk_ioctl_multi_cmd() needs to call mmc_get_card() before
> calling __mmc_blk_ioctl_cmd() and so currently we are calling
> mmc_get_card() twice in the case of mmc_blk_ioctl_multi_cmd() which
> seems unnecessary.

I agree.

We can follow your suggestion, but then we also need to add
mmc_get|put_card() in the case for non-multi commands.

Kind regards
Uffe


\
 
 \ /
  Last update: 2015-09-10 12:41    [W:0.258 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site