Lines Matching refs:block

41 	struct w1_cb_block *block;
49 * @block: block to calculate
55 static u16 w1_reply_len(struct w1_cb_block *block)
57 if (!block->cn)
59 return (u8 *)block->cn - (u8 *)block->first_cn + block->cn->len;
62 static void w1_unref_block(struct w1_cb_block *block)
64 if (atomic_sub_return(1, &block->refcnt) == 0) {
65 u16 len = w1_reply_len(block);
67 cn_netlink_send_mult(block->first_cn, len,
68 block->portid, 0,
71 kfree(block);
77 * @block: block to make space on
83 static void w1_reply_make_space(struct w1_cb_block *block, u16 space)
85 u16 len = w1_reply_len(block);
86 if (len + space >= block->maxlen) {
87 cn_netlink_send_mult(block->first_cn, len, block->portid,
89 block->first_cn->len = 0;
90 block->cn = NULL;
91 block->msg = NULL;
92 block->cmd = NULL;
97 static void w1_netlink_check_send(struct w1_cb_block *block)
99 if (!(block->request_cn.flags & W1_CN_BUNDLE) && block->cn)
100 w1_reply_make_space(block, block->maxlen);
104 * w1_netlink_setup_msg() - prepare to write block->msg
105 * @block: block to operate on
108 * block->cn will be setup with the correct ack, advancing if needed
109 * block->cn->len does not include space for block->msg
110 * block->msg advances but remains uninitialized
112 static void w1_netlink_setup_msg(struct w1_cb_block *block, u32 ack)
114 if (block->cn && block->cn->ack == ack) {
115 block->msg = (struct w1_netlink_msg *)(block->cn->data + block->cn->len);
118 if (block->cn)
119 block->cn = (struct cn_msg *)(block->cn->data +
120 block->cn->len);
122 block->cn = block->first_cn;
124 memcpy(block->cn, &block->request_cn, sizeof(*block->cn));
125 block->cn->len = 0;
126 block->cn->ack = ack;
127 block->msg = (struct w1_netlink_msg *)block->cn->data;
135 static void w1_netlink_queue_cmd(struct w1_cb_block *block,
139 w1_reply_make_space(block, sizeof(struct cn_msg) +
146 w1_netlink_setup_msg(block, block->request_cn.seq + 1);
147 memcpy(block->msg, block->cur_msg, sizeof(*block->msg));
148 block->cn->len += sizeof(*block->msg);
149 block->msg->len = 0;
150 block->cmd = (struct w1_netlink_cmd *)(block->msg->data);
153 if (block->cmd != cmd)
154 memcpy(block->cmd, cmd, space);
155 block->cn->len += space;
156 block->msg->len += space;
162 static void w1_netlink_queue_status(struct w1_cb_block *block,
167 w1_reply_make_space(block, space);
168 w1_netlink_setup_msg(block, block->request_cn.ack);
170 memcpy(block->msg, req_msg, sizeof(*req_msg));
171 block->cn->len += sizeof(*req_msg);
172 block->msg->len = 0;
173 block->msg->status = (u8)-error;
175 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)block->msg->data;
177 block->cn->len += sizeof(*cmd);
178 block->msg->len += sizeof(*cmd);
181 w1_netlink_check_send(block);
191 * Use when a block isn't available to queue the message to and cn, msg
238 struct w1_cb_block *block = dev->priv;
239 struct w1_netlink_cmd *cache_cmd = block->cmd;
242 w1_reply_make_space(block, sizeof(*data));
245 if (!block->cmd) {
247 w1_netlink_queue_cmd(block, cache_cmd);
250 data = (u64 *)(block->cmd->data + block->cmd->len);
253 block->cn->len += sizeof(*data);
254 block->msg->len += sizeof(*data);
255 block->cmd->len += sizeof(*data);
455 dev->priv = node->block;
458 node->block->cur_msg = node->msg;
470 w1_netlink_check_send(node->block);
472 w1_netlink_queue_status(node->block, node->msg, cmd, err);
481 w1_netlink_queue_status(node->block, node->msg, cmd, err);
484 * the block
497 w1_unref_block(node->block);
545 struct w1_cb_block *block = NULL;
593 /* allocate space for the block, a copy of the original message,
597 * cn->len doesn't include itself which is part of the block
599 size = /* block + original message */
605 block = kzalloc(size, GFP_KERNEL);
606 if (!block) {
614 atomic_set(&block->refcnt, 1);
615 block->portid = nsp->portid;
616 block->request_cn = *cn;
617 memcpy(block->request_cn.data, cn->data, cn->len);
618 node = (struct w1_cb_node *)(block->request_cn.data + cn->len);
629 block->maxlen = reply_size;
630 block->first_cn = (struct cn_msg *)(node + node_count);
631 memset(block->first_cn, 0, sizeof(*block->first_cn));
681 atomic_inc(&block->refcnt);
683 node->block = block;
684 node->msg = (struct w1_netlink_msg *)((u8 *)&block->request_cn +
696 /* Can't queue because that modifies block and another
712 if (block)
713 w1_unref_block(block);