struct mmc_card *card = NULL;
struct mmc_blk_data *md = NULL;
unsigned int part_curr;
+ struct mmc_core_rpmb_req rpmb_req;
if (!emmc)
return -ENODEV;
goto err;
}
+ memset(&rpmb_req, 0, sizeof(struct mmc_core_rpmb_req));
+ rpmb_req.req = req;
/* check request */
- ret = mmc_rpmb_pre_frame(req, card);
+ ret = mmc_rpmb_pre_frame(&rpmb_req, card);
if (ret) {
pr_err("%s: prepare frame failed\n", mmc_hostname(card->host));
goto err;
mmc_claim_host(card->host);
- /* * before start, let's change to RPMB partition first
+ /*
+ * before start, let's change to RPMB partition first
*/
part_curr = md->part_type;
md->part_type = EXT_CSD_PART_CONFIG_RPMB;
goto out;
}
- ret = mmc_rpmb_partition_ops(req, card);
+ ret = mmc_rpmb_partition_ops(&rpmb_req, card);
if (ret)
pr_err("%s: failed (%d) to handle RPMB request type (%d)!\n",
mmc_hostname(card->host), ret, req->type);
}
}
mmc_release_host(card->host);
- mmc_rpmb_post_frame(req);
+ mmc_rpmb_post_frame(&rpmb_req);
err:
mmc_blk_put(md);
return 0;
}
-void mmc_rpmb_post_frame(struct mmc_rpmb_req *p_req)
+void mmc_rpmb_post_frame(struct mmc_core_rpmb_req *rpmb_req)
{
int i;
- __u8 *ptr, *buf_frame = p_req->frame;
+ struct mmc_rpmb_req *p_req = rpmb_req->req;
+ __u8 *ptr, *buf_frame = rpmb_req->frame;
- if (!p_req->ready || !buf_frame)
+ if (!rpmb_req->ready || !buf_frame)
return;
/*
* Regarding to the check rules, here is the post
}
out:
kfree(buf_frame);
- p_req->frame = NULL;
+ rpmb_req->frame = NULL;
return;
}
EXPORT_SYMBOL_GPL(mmc_rpmb_post_frame);
* convert needed bytes
* return how many frames will be prepared
*/
-int mmc_rpmb_pre_frame(struct mmc_rpmb_req *p_req,
+int mmc_rpmb_pre_frame(struct mmc_core_rpmb_req *rpmb_req,
struct mmc_card *card)
{
int i, j, ret;
+ struct mmc_rpmb_req *p_req = rpmb_req->req;
__u8 *ptr = NULL, *buf_frame;
- __u8 *data = p_req->data;
__u16 blk_cnt, addr, type;
__u32 w_counter;
+ if (!p_req) {
+ pr_err("%s: mmc_rpmb_req is NULL. Wrong parameter\n",
+ mmc_hostname(card->host));
+ return -EINVAL;
+ }
+
/*
* make sure these two items are clear
*/
- p_req->ready = 0;
- p_req->frame = NULL;
+ rpmb_req->ready = 0;
+ rpmb_req->frame = NULL;
ret = mmc_rpmb_request_check(card, p_req);
if (ret)
for (i = 0; i < 16; i++, ptr--)
*ptr = p_req->nonce[i];
} else if (p_req->type == RPMB_WRITE_DATA) {
+ __u8 *data = p_req->data;
/*
* multiple package prepared
* This request nees blk_cnt, addr, write_counter,
kfree(buf_frame);
return -EINVAL;
}
- p_req->ready = 1;
- p_req->frame = buf_frame;
+ rpmb_req->ready = 1;
+ rpmb_req->frame = buf_frame;
return 0;
}
EXPORT_SYMBOL_GPL(mmc_rpmb_pre_frame);
-int mmc_rpmb_partition_ops(struct mmc_rpmb_req *p_req,
+int mmc_rpmb_partition_ops(struct mmc_core_rpmb_req *rpmb_req,
struct mmc_card *card)
{
int err = 0;
+ struct mmc_rpmb_req *p_req = rpmb_req->req;
__u16 type, blks;
- __u8 *buf_frame = p_req->frame;
+ __u8 *buf_frame = rpmb_req->frame;
- if (!p_req->ready || !buf_frame) {
+ if (!p_req || !rpmb_req->ready || !buf_frame) {
pr_err("%s: mmc_rpmb_req is not prepared\n",
mmc_hostname(card->host));
return -EINVAL;
};
/*
- * RPMB frame structure
+ * RPMB frame structure for external user
*/
struct mmc_rpmb_req {
__u16 type; /* RPMB request type */
__u8 *nonce; /* Ramdom number */
__u8 *data; /* Buffer of the user data */
__u8 *mac; /* Message Authentication Code */
+};
+
+/*
+ * RPMB frame structure for MMC core stack
+ */
+struct mmc_core_rpmb_req {
+ struct mmc_rpmb_req *req;
__u8 *frame;
bool ready;
};
struct mmc_command *, int);
extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
-extern int mmc_rpmb_partition_ops(struct mmc_rpmb_req *,
+extern int mmc_rpmb_partition_ops(struct mmc_core_rpmb_req *,
struct mmc_card *);
-extern int mmc_rpmb_pre_frame(struct mmc_rpmb_req *, struct mmc_card *);
-extern void mmc_rpmb_post_frame(struct mmc_rpmb_req *);
+extern int mmc_rpmb_pre_frame(struct mmc_core_rpmb_req *, struct mmc_card *);
+extern void mmc_rpmb_post_frame(struct mmc_core_rpmb_req *);
#define MMC_ERASE_ARG 0x00000000
#define MMC_SECURE_ERASE_ARG 0x80000000