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, GFP_KERNEL);
70 kfree(block);
76 * @block: block to make space on
82 static void w1_reply_make_space(struct w1_cb_block *block, u16 space)
84 u16 len = w1_reply_len(block);
85 if (len + space >= block->maxlen) {
86 cn_netlink_send_mult(block->first_cn, len, block->portid, 0, GFP_KERNEL);
87 block->first_cn->len = 0;
88 block->cn = NULL;
89 block->msg = NULL;
90 block->cmd = NULL;
95 static void w1_netlink_check_send(struct w1_cb_block *block)
97 if (!(block->request_cn.flags & W1_CN_BUNDLE) && block->cn)
98 w1_reply_make_space(block, block->maxlen);
102 * w1_netlink_setup_msg() - prepare to write block->msg
103 * @block: block to operate on
106 * block->cn will be setup with the correct ack, advancing if needed
107 * block->cn->len does not include space for block->msg
108 * block->msg advances but remains uninitialized
110 static void w1_netlink_setup_msg(struct w1_cb_block *block, u32 ack)
112 if (block->cn && block->cn->ack == ack) {
113 block->msg = (struct w1_netlink_msg *)(block->cn->data + block->cn->len);
116 if (block->cn)
117 block->cn = (struct cn_msg *)(block->cn->data +
118 block->cn->len);
120 block->cn = block->first_cn;
122 memcpy(block->cn, &block->request_cn, sizeof(*block->cn));
123 block->cn->len = 0;
124 block->cn->ack = ack;
125 block->msg = (struct w1_netlink_msg *)block->cn->data;
133 static void w1_netlink_queue_cmd(struct w1_cb_block *block,
137 w1_reply_make_space(block, sizeof(struct cn_msg) +
144 w1_netlink_setup_msg(block, block->request_cn.seq + 1);
145 memcpy(block->msg, block->cur_msg, sizeof(*block->msg));
146 block->cn->len += sizeof(*block->msg);
147 block->msg->len = 0;
148 block->cmd = (struct w1_netlink_cmd *)(block->msg->data);
151 if (block->cmd != cmd)
152 memcpy(block->cmd, cmd, space);
153 block->cn->len += space;
154 block->msg->len += space;
160 static void w1_netlink_queue_status(struct w1_cb_block *block,
165 w1_reply_make_space(block, space);
166 w1_netlink_setup_msg(block, block->request_cn.ack);
168 memcpy(block->msg, req_msg, sizeof(*req_msg));
169 block->cn->len += sizeof(*req_msg);
170 block->msg->len = 0;
171 block->msg->status = (u8)-error;
173 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)block->msg->data;
175 block->cn->len += sizeof(*cmd);
176 block->msg->len += sizeof(*cmd);
179 w1_netlink_check_send(block);
189 * Use when a block isn't available to queue the message to and cn, msg
236 struct w1_cb_block *block = dev->priv;
237 struct w1_netlink_cmd *cache_cmd = block->cmd;
240 w1_reply_make_space(block, sizeof(*data));
243 if (!block->cmd) {
245 w1_netlink_queue_cmd(block, cache_cmd);
248 data = (u64 *)(block->cmd->data + block->cmd->len);
251 block->cn->len += sizeof(*data);
252 block->msg->len += sizeof(*data);
253 block->cmd->len += sizeof(*data);
453 dev->priv = node->block;
456 node->block->cur_msg = node->msg;
468 w1_netlink_check_send(node->block);
470 w1_netlink_queue_status(node->block, node->msg, cmd, err);
479 w1_netlink_queue_status(node->block, node->msg, cmd, err);
482 * the block
495 w1_unref_block(node->block);
543 struct w1_cb_block *block = NULL;
591 /* allocate space for the block, a copy of the original message,
595 * cn->len doesn't include itself which is part of the block
597 size = /* block + original message */
603 block = kzalloc(size, GFP_KERNEL);
604 if (!block) {
612 atomic_set(&block->refcnt, 1);
613 block->portid = nsp->portid;
614 memcpy(&block->request_cn, cn, sizeof(*cn) + cn->len);
615 node = (struct w1_cb_node *)(block->request_cn.data + cn->len);
626 block->maxlen = reply_size;
627 block->first_cn = (struct cn_msg *)(node + node_count);
628 memset(block->first_cn, 0, sizeof(*block->first_cn));
678 atomic_inc(&block->refcnt);
680 node->block = block;
681 node->msg = (struct w1_netlink_msg *)((u8 *)&block->request_cn +
693 /* Can't queue because that modifies block and another
709 if (block)
710 w1_unref_block(block);