All of lore.kernel.org
 help / color / mirror / Atom feed
From: NamJae Jeon <linkinjeon@gmail.com>
To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Chris Ball <cjb@laptop.org>, linus.walleij@linaro.org
Subject: RFC : mmc: mmc_blk_issue_secdiscard_rq() and mmc_blk_issue_discard_rq() effectively merged into one.
Date: Wed, 24 Aug 2011 14:09:28 +0900	[thread overview]
Message-ID: <CAKYAXd9MwO-JEMNt9-0C8pzgYn5Tvtv8ovJ35TNiqqe8PWGogQ@mail.gmail.com> (raw)

Hi.

I am wordering why mmc_blk_issue_secdiscard_rq() and
mmc_blk_issue_discard_rq() is seperated.
So I try to make mmc_blk_issue_secdiscard_rq() and
mmc_blk_issue_discard_rq() effectively merged into one.

I want to know your opinion.

Thanks.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------
static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
{
        struct mmc_blk_data *md = mq->data;
        struct mmc_card *card = md->queue.card;
        unsigned int from, nr, arg;
        int err = 0;
        from = blk_rq_pos(req);
        nr = blk_rq_sectors(req);
        if (req->cmd_flags & REQ_SECURE) {
                if (!mmc_can_secure_erase_trim(card)) {
                        err = -EOPNOTSUPP;
                        goto out;
                }
                if(mmc_can_trim(card) &&
!mmc_erase_group_aligned(card, from, nr))
                        arg = MMC_SECURE_TRIM1_ARG;
                else
                        arg = MMC_SECURE_ERASE_ARG;
        }
        else {
                if (!mmc_can_erase(card)) {
                        err = -EOPNOTSUPP;
                        goto out;
                }
                if (mmc_can_trim(card))
                        arg = MMC_TRIM_ARG;
                else
                        arg = MMC_ERASE_ARG;
        }

        if (card->quirks & MMC_QUIRK_INAND_CMD38) {
                if(req->cmd_flags & REQ_SECURE)
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        NAND_CMD38_ARG_EXT_CSD,
                                        arg == MMC_SECURE_TRIM1_ARG ?
                                        INAND_CMD38_ARG_SECTRIM1 :
                                        INAND_CMD38_ARG_SECERASE,
                                        0);
                else
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        INAND_CMD38_ARG_EXT_CSD,
                                        arg == MMC_TRIM_ARG ?
                                        INAND_CMD38_ARG_TRIM :
                                        INAND_CMD38_ARG_ERASE,
                                        0);
                if (err)
                        goto out;
        }
        err = mmc_erase(card, from, nr, arg);
        if (!err && arg == MMC_SECURE_TRIM1_ARG) {
                if (card->quirks & MMC_QUIRK_INAND_CMD38) {
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         INAND_CMD38_ARG_EXT_CSD,
                                         INAND_CMD38_ARG_SECTRIM2,
                                         0);
                        if (err)
                                goto out;
                }
                err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
        }
out:
        spin_lock_irq(&md->lock);
        __blk_end_request(req, err, blk_rq_bytes(req));
        spin_unlock_irq(&md->lock);
        return err ? 0 : 1;
}


static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
{
        int ret;
        struct mmc_blk_data *md = mq->data;
        struct mmc_card *card = md->queue.card;
        mmc_claim_host(card->host);
        ret = mmc_blk_part_switch(card, md);
        if (ret) {
                ret = 0;
                goto out;
        }
        if (req->cmd_flags & REQ_DISCARD) {
                ret = mmc_blk_issue_discard_rq(mq, req);
        } else if (req->cmd_flags & REQ_FLUSH) {
                ret = mmc_blk_issue_flush(mq, req);
        } else {
                ret = mmc_blk_issue_rw_rq(mq, req);
        }
out:
        mmc_release_host(card->host);
        return ret;
}

             reply	other threads:[~2011-08-24  5:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24  5:09 NamJae Jeon [this message]
2011-08-24  5:52 ` RFC : mmc: mmc_blk_issue_secdiscard_rq() and mmc_blk_issue_discard_rq() effectively merged into one Kyungmin Park
2011-08-24 15:21   ` NamJae Jeon
2011-08-24 15:21     ` NamJae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKYAXd9MwO-JEMNt9-0C8pzgYn5Tvtv8ovJ35TNiqqe8PWGogQ@mail.gmail.com \
    --to=linkinjeon@gmail.com \
    --cc=cjb@laptop.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.