22 #include <linux/slab.h>
24 #include <linux/netlink.h>
25 #include <linux/connector.h>
31 #if defined(CONFIG_W1_CON) && (defined(CONFIG_CONNECTOR) || (defined(CONFIG_CONNECTOR_MODULE) && defined(CONFIG_W1_MODULE)))
51 static void w1_send_slave(
struct w1_master *dev,
u64 rn)
53 struct cn_msg *msg = dev->priv;
61 avail = dev->priv_size - cmd->
len;
81 static int w1_process_search_command(
struct w1_master *dev,
struct cn_msg *msg,
89 dev->priv_size =
avail;
111 data = kzalloc(
sizeof(
struct cn_msg) +
118 cm = (
struct cn_msg *)(data);
141 static int w1_process_command_io(
struct w1_master *dev,
struct cn_msg *msg,
149 w1_send_read_reply(msg, hdr, cmd);
153 w1_send_read_reply(msg, hdr, cmd);
166 static int w1_process_command_master(
struct w1_master *dev,
struct cn_msg *
req_msg,
178 msg->
id = req_msg->
id;
187 hdr->id = req_hdr->
id;
196 err = w1_process_search_command(dev, msg,
202 err = w1_process_command_io(dev, req_msg, req_hdr, req_cmd);
216 static int w1_process_command_slave(
struct w1_slave *
sl,
struct cn_msg *msg,
219 dev_dbg(&sl->master->dev,
"%s: %02x.%012llx.%02x: cmd=%02x, len=%u.\n",
220 __func__, sl->reg_num.family, (
unsigned long long)sl->reg_num.id,
221 sl->reg_num.crc, cmd->
cmd, cmd->
len);
223 return w1_process_command_io(sl->master, msg, hdr, cmd);
235 __func__, msg->
id.idx, msg->
id.val, mcmd->
type, mcmd->
len);
267 w->
len +=
sizeof(*id);
268 cn->
len +=
sizeof(*id);
286 cmsg = kzalloc(
sizeof(*msg) +
sizeof(*cmd) +
sizeof(*cmsg),
GFP_KERNEL);
293 memcpy(cmsg, rcmsg,
sizeof(*cmsg));
294 cmsg->
len =
sizeof(*msg);
296 memcpy(msg, rmsg,
sizeof(*msg));
301 memcpy(cmd, rcmd,
sizeof(*cmd));
303 msg->
len +=
sizeof(*cmd);
304 cmsg->
len +=
sizeof(*cmd);
318 struct w1_master *
dev;
321 while (msg->
len && !err) {
332 printk(
"%s: %02x.%012llx.%02x: type=%02x, len=%u.\n",
347 err = w1_process_command_root(msg, m);
376 err = w1_process_command_slave(sl, msg, m, cmd);
378 err = w1_process_command_master(dev, msg, m, cmd);
380 w1_netlink_send_error(msg, m, cmd, err);
393 w1_netlink_send_error(msg, m, cmd, err);