diff options
Diffstat (limited to 'drivers/net/wireless/libertas/mesh.c')
-rw-r--r-- | drivers/net/wireless/libertas/mesh.c | 231 |
1 files changed, 151 insertions, 80 deletions
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c index 194762ab0142..24cf06680c6b 100644 --- a/drivers/net/wireless/libertas/mesh.c +++ b/drivers/net/wireless/libertas/mesh.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
2 | |||
1 | #include <linux/delay.h> | 3 | #include <linux/delay.h> |
2 | #include <linux/etherdevice.h> | 4 | #include <linux/etherdevice.h> |
3 | #include <linux/netdevice.h> | 5 | #include <linux/netdevice.h> |
@@ -16,12 +18,15 @@ | |||
16 | * Mesh sysfs support | 18 | * Mesh sysfs support |
17 | */ | 19 | */ |
18 | 20 | ||
19 | /** | 21 | /* |
20 | * Attributes exported through sysfs | 22 | * Attributes exported through sysfs |
21 | */ | 23 | */ |
22 | 24 | ||
23 | /** | 25 | /** |
24 | * @brief Get function for sysfs attribute anycast_mask | 26 | * lbs_anycast_get - Get function for sysfs attribute anycast_mask |
27 | * @dev: the &struct device | ||
28 | * @attr: device attributes | ||
29 | * @buf: buffer where data will be returned | ||
25 | */ | 30 | */ |
26 | static ssize_t lbs_anycast_get(struct device *dev, | 31 | static ssize_t lbs_anycast_get(struct device *dev, |
27 | struct device_attribute *attr, char * buf) | 32 | struct device_attribute *attr, char * buf) |
@@ -40,7 +45,11 @@ static ssize_t lbs_anycast_get(struct device *dev, | |||
40 | } | 45 | } |
41 | 46 | ||
42 | /** | 47 | /** |
43 | * @brief Set function for sysfs attribute anycast_mask | 48 | * lbs_anycast_set - Set function for sysfs attribute anycast_mask |
49 | * @dev: the &struct device | ||
50 | * @attr: device attributes | ||
51 | * @buf: buffer that contains new attribute value | ||
52 | * @count: size of buffer | ||
44 | */ | 53 | */ |
45 | static ssize_t lbs_anycast_set(struct device *dev, | 54 | static ssize_t lbs_anycast_set(struct device *dev, |
46 | struct device_attribute *attr, const char * buf, size_t count) | 55 | struct device_attribute *attr, const char * buf, size_t count) |
@@ -62,7 +71,10 @@ static ssize_t lbs_anycast_set(struct device *dev, | |||
62 | } | 71 | } |
63 | 72 | ||
64 | /** | 73 | /** |
65 | * @brief Get function for sysfs attribute prb_rsp_limit | 74 | * lbs_prb_rsp_limit_get - Get function for sysfs attribute prb_rsp_limit |
75 | * @dev: the &struct device | ||
76 | * @attr: device attributes | ||
77 | * @buf: buffer where data will be returned | ||
66 | */ | 78 | */ |
67 | static ssize_t lbs_prb_rsp_limit_get(struct device *dev, | 79 | static ssize_t lbs_prb_rsp_limit_get(struct device *dev, |
68 | struct device_attribute *attr, char *buf) | 80 | struct device_attribute *attr, char *buf) |
@@ -85,7 +97,11 @@ static ssize_t lbs_prb_rsp_limit_get(struct device *dev, | |||
85 | } | 97 | } |
86 | 98 | ||
87 | /** | 99 | /** |
88 | * @brief Set function for sysfs attribute prb_rsp_limit | 100 | * lbs_prb_rsp_limit_set - Set function for sysfs attribute prb_rsp_limit |
101 | * @dev: the &struct device | ||
102 | * @attr: device attributes | ||
103 | * @buf: buffer that contains new attribute value | ||
104 | * @count: size of buffer | ||
89 | */ | 105 | */ |
90 | static ssize_t lbs_prb_rsp_limit_set(struct device *dev, | 106 | static ssize_t lbs_prb_rsp_limit_set(struct device *dev, |
91 | struct device_attribute *attr, const char *buf, size_t count) | 107 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -114,7 +130,10 @@ static ssize_t lbs_prb_rsp_limit_set(struct device *dev, | |||
114 | } | 130 | } |
115 | 131 | ||
116 | /** | 132 | /** |
117 | * Get function for sysfs attribute mesh | 133 | * lbs_mesh_get - Get function for sysfs attribute mesh |
134 | * @dev: the &struct device | ||
135 | * @attr: device attributes | ||
136 | * @buf: buffer where data will be returned | ||
118 | */ | 137 | */ |
119 | static ssize_t lbs_mesh_get(struct device *dev, | 138 | static ssize_t lbs_mesh_get(struct device *dev, |
120 | struct device_attribute *attr, char * buf) | 139 | struct device_attribute *attr, char * buf) |
@@ -124,7 +143,11 @@ static ssize_t lbs_mesh_get(struct device *dev, | |||
124 | } | 143 | } |
125 | 144 | ||
126 | /** | 145 | /** |
127 | * Set function for sysfs attribute mesh | 146 | * lbs_mesh_set - Set function for sysfs attribute mesh |
147 | * @dev: the &struct device | ||
148 | * @attr: device attributes | ||
149 | * @buf: buffer that contains new attribute value | ||
150 | * @count: size of buffer | ||
128 | */ | 151 | */ |
129 | static ssize_t lbs_mesh_set(struct device *dev, | 152 | static ssize_t lbs_mesh_set(struct device *dev, |
130 | struct device_attribute *attr, const char * buf, size_t count) | 153 | struct device_attribute *attr, const char * buf, size_t count) |
@@ -151,19 +174,19 @@ static ssize_t lbs_mesh_set(struct device *dev, | |||
151 | return count; | 174 | return count; |
152 | } | 175 | } |
153 | 176 | ||
154 | /** | 177 | /* |
155 | * lbs_mesh attribute to be exported per ethX interface | 178 | * lbs_mesh attribute to be exported per ethX interface |
156 | * through sysfs (/sys/class/net/ethX/lbs_mesh) | 179 | * through sysfs (/sys/class/net/ethX/lbs_mesh) |
157 | */ | 180 | */ |
158 | static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set); | 181 | static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set); |
159 | 182 | ||
160 | /** | 183 | /* |
161 | * anycast_mask attribute to be exported per mshX interface | 184 | * anycast_mask attribute to be exported per mshX interface |
162 | * through sysfs (/sys/class/net/mshX/anycast_mask) | 185 | * through sysfs (/sys/class/net/mshX/anycast_mask) |
163 | */ | 186 | */ |
164 | static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set); | 187 | static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set); |
165 | 188 | ||
166 | /** | 189 | /* |
167 | * prb_rsp_limit attribute to be exported per mshX interface | 190 | * prb_rsp_limit attribute to be exported per mshX interface |
168 | * through sysfs (/sys/class/net/mshX/prb_rsp_limit) | 191 | * through sysfs (/sys/class/net/mshX/prb_rsp_limit) |
169 | */ | 192 | */ |
@@ -246,7 +269,7 @@ int lbs_init_mesh(struct lbs_private *priv) | |||
246 | lbs_add_mesh(priv); | 269 | lbs_add_mesh(priv); |
247 | 270 | ||
248 | if (device_create_file(&dev->dev, &dev_attr_lbs_mesh)) | 271 | if (device_create_file(&dev->dev, &dev_attr_lbs_mesh)) |
249 | lbs_pr_err("cannot register lbs_mesh attribute\n"); | 272 | netdev_err(dev, "cannot register lbs_mesh attribute\n"); |
250 | 273 | ||
251 | ret = 1; | 274 | ret = 1; |
252 | } | 275 | } |
@@ -274,10 +297,10 @@ int lbs_deinit_mesh(struct lbs_private *priv) | |||
274 | 297 | ||
275 | 298 | ||
276 | /** | 299 | /** |
277 | * @brief This function closes the mshX interface | 300 | * lbs_mesh_stop - close the mshX interface |
278 | * | 301 | * |
279 | * @param dev A pointer to net_device structure | 302 | * @dev: A pointer to &net_device structure |
280 | * @return 0 | 303 | * returns: 0 |
281 | */ | 304 | */ |
282 | static int lbs_mesh_stop(struct net_device *dev) | 305 | static int lbs_mesh_stop(struct net_device *dev) |
283 | { | 306 | { |
@@ -301,10 +324,10 @@ static int lbs_mesh_stop(struct net_device *dev) | |||
301 | } | 324 | } |
302 | 325 | ||
303 | /** | 326 | /** |
304 | * @brief This function opens the mshX interface | 327 | * lbs_mesh_dev_open - open the mshX interface |
305 | * | 328 | * |
306 | * @param dev A pointer to net_device structure | 329 | * @dev: A pointer to &net_device structure |
307 | * @return 0 or -EBUSY if monitor mode active | 330 | * returns: 0 or -EBUSY if monitor mode active |
308 | */ | 331 | */ |
309 | static int lbs_mesh_dev_open(struct net_device *dev) | 332 | static int lbs_mesh_dev_open(struct net_device *dev) |
310 | { | 333 | { |
@@ -342,10 +365,10 @@ static const struct net_device_ops mesh_netdev_ops = { | |||
342 | }; | 365 | }; |
343 | 366 | ||
344 | /** | 367 | /** |
345 | * @brief This function adds mshX interface | 368 | * lbs_add_mesh - add mshX interface |
346 | * | 369 | * |
347 | * @param priv A pointer to the struct lbs_private structure | 370 | * @priv: A pointer to the &struct lbs_private structure |
348 | * @return 0 if successful, -X otherwise | 371 | * returns: 0 if successful, -X otherwise |
349 | */ | 372 | */ |
350 | int lbs_add_mesh(struct lbs_private *priv) | 373 | int lbs_add_mesh(struct lbs_private *priv) |
351 | { | 374 | { |
@@ -374,7 +397,7 @@ int lbs_add_mesh(struct lbs_private *priv) | |||
374 | /* Register virtual mesh interface */ | 397 | /* Register virtual mesh interface */ |
375 | ret = register_netdev(mesh_dev); | 398 | ret = register_netdev(mesh_dev); |
376 | if (ret) { | 399 | if (ret) { |
377 | lbs_pr_err("cannot register mshX virtual interface\n"); | 400 | pr_err("cannot register mshX virtual interface\n"); |
378 | goto err_free; | 401 | goto err_free; |
379 | } | 402 | } |
380 | 403 | ||
@@ -456,13 +479,13 @@ void lbs_mesh_set_txpd(struct lbs_private *priv, | |||
456 | */ | 479 | */ |
457 | 480 | ||
458 | /** | 481 | /** |
459 | * @brief Add or delete Mesh Blinding Table entries | 482 | * lbs_mesh_bt_add_del - Add or delete Mesh Blinding Table entries |
460 | * | 483 | * |
461 | * @param priv A pointer to struct lbs_private structure | 484 | * @priv: A pointer to &struct lbs_private structure |
462 | * @param add TRUE to add the entry, FALSE to delete it | 485 | * @add: TRUE to add the entry, FALSE to delete it |
463 | * @param addr1 Destination address to blind or unblind | 486 | * @addr1: Destination address to blind or unblind |
464 | * | 487 | * |
465 | * @return 0 on success, error on failure | 488 | * returns: 0 on success, error on failure |
466 | */ | 489 | */ |
467 | int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1) | 490 | int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1) |
468 | { | 491 | { |
@@ -493,11 +516,11 @@ int lbs_mesh_bt_add_del(struct lbs_private *priv, bool add, u8 *addr1) | |||
493 | } | 516 | } |
494 | 517 | ||
495 | /** | 518 | /** |
496 | * @brief Reset/clear the mesh blinding table | 519 | * lbs_mesh_bt_reset - Reset/clear the mesh blinding table |
497 | * | 520 | * |
498 | * @param priv A pointer to struct lbs_private structure | 521 | * @priv: A pointer to &struct lbs_private structure |
499 | * | 522 | * |
500 | * @return 0 on success, error on failure | 523 | * returns: 0 on success, error on failure |
501 | */ | 524 | */ |
502 | int lbs_mesh_bt_reset(struct lbs_private *priv) | 525 | int lbs_mesh_bt_reset(struct lbs_private *priv) |
503 | { | 526 | { |
@@ -517,17 +540,18 @@ int lbs_mesh_bt_reset(struct lbs_private *priv) | |||
517 | } | 540 | } |
518 | 541 | ||
519 | /** | 542 | /** |
520 | * @brief Gets the inverted status of the mesh blinding table | 543 | * lbs_mesh_bt_get_inverted - Gets the inverted status of the mesh |
544 | * blinding table | ||
521 | * | 545 | * |
522 | * Normally the firmware "blinds" or ignores traffic from mesh nodes in the | 546 | * Normally the firmware "blinds" or ignores traffic from mesh nodes in the |
523 | * table, but an inverted table allows *only* traffic from nodes listed in | 547 | * table, but an inverted table allows *only* traffic from nodes listed in |
524 | * the table. | 548 | * the table. |
525 | * | 549 | * |
526 | * @param priv A pointer to struct lbs_private structure | 550 | * @priv: A pointer to &struct lbs_private structure |
527 | * @param invert On success, TRUE if the blinding table is inverted, | 551 | * @inverted: On success, TRUE if the blinding table is inverted, |
528 | * FALSE if it is not inverted | 552 | * FALSE if it is not inverted |
529 | * | 553 | * |
530 | * @return 0 on success, error on failure | 554 | * returns: 0 on success, error on failure |
531 | */ | 555 | */ |
532 | int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted) | 556 | int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted) |
533 | { | 557 | { |
@@ -551,18 +575,19 @@ int lbs_mesh_bt_get_inverted(struct lbs_private *priv, bool *inverted) | |||
551 | } | 575 | } |
552 | 576 | ||
553 | /** | 577 | /** |
554 | * @brief Sets the inverted status of the mesh blinding table | 578 | * lbs_mesh_bt_set_inverted - Sets the inverted status of the mesh |
579 | * blinding table | ||
555 | * | 580 | * |
556 | * Normally the firmware "blinds" or ignores traffic from mesh nodes in the | 581 | * Normally the firmware "blinds" or ignores traffic from mesh nodes in the |
557 | * table, but an inverted table allows *only* traffic from nodes listed in | 582 | * table, but an inverted table allows *only* traffic from nodes listed in |
558 | * the table. | 583 | * the table. |
559 | * | 584 | * |
560 | * @param priv A pointer to struct lbs_private structure | 585 | * @priv: A pointer to &struct lbs_private structure |
561 | * @param invert TRUE to invert the blinding table (only traffic from | 586 | * @inverted: TRUE to invert the blinding table (only traffic from |
562 | * listed nodes allowed), FALSE to return it | 587 | * listed nodes allowed), FALSE to return it |
563 | * to normal state (listed nodes ignored) | 588 | * to normal state (listed nodes ignored) |
564 | * | 589 | * |
565 | * @return 0 on success, error on failure | 590 | * returns: 0 on success, error on failure |
566 | */ | 591 | */ |
567 | int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted) | 592 | int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted) |
568 | { | 593 | { |
@@ -574,7 +599,7 @@ int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted) | |||
574 | memset(&cmd, 0, sizeof(cmd)); | 599 | memset(&cmd, 0, sizeof(cmd)); |
575 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 600 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
576 | cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT); | 601 | cmd.action = cpu_to_le16(CMD_ACT_BT_ACCESS_SET_INVERT); |
577 | cmd.id = !!inverted; | 602 | cmd.id = cpu_to_le32(!!inverted); |
578 | 603 | ||
579 | ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd); | 604 | ret = lbs_cmd_with_response(priv, CMD_BT_ACCESS, &cmd); |
580 | 605 | ||
@@ -583,13 +608,13 @@ int lbs_mesh_bt_set_inverted(struct lbs_private *priv, bool inverted) | |||
583 | } | 608 | } |
584 | 609 | ||
585 | /** | 610 | /** |
586 | * @brief List an entry in the mesh blinding table | 611 | * lbs_mesh_bt_get_entry - List an entry in the mesh blinding table |
587 | * | 612 | * |
588 | * @param priv A pointer to struct lbs_private structure | 613 | * @priv: A pointer to &struct lbs_private structure |
589 | * @param id The ID of the entry to list | 614 | * @id: The ID of the entry to list |
590 | * @param addr1 MAC address associated with the table entry | 615 | * @addr1: MAC address associated with the table entry |
591 | * | 616 | * |
592 | * @return 0 on success, error on failure | 617 | * returns: 0 on success, error on failure |
593 | */ | 618 | */ |
594 | int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1) | 619 | int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1) |
595 | { | 620 | { |
@@ -614,14 +639,14 @@ int lbs_mesh_bt_get_entry(struct lbs_private *priv, u32 id, u8 *addr1) | |||
614 | } | 639 | } |
615 | 640 | ||
616 | /** | 641 | /** |
617 | * @brief Access the mesh forwarding table | 642 | * lbs_cmd_fwt_access - Access the mesh forwarding table |
618 | * | 643 | * |
619 | * @param priv A pointer to struct lbs_private structure | 644 | * @priv: A pointer to &struct lbs_private structure |
620 | * @param cmd_action The forwarding table action to perform | 645 | * @cmd_action: The forwarding table action to perform |
621 | * @param cmd The pre-filled FWT_ACCESS command | 646 | * @cmd: The pre-filled FWT_ACCESS command |
622 | * | 647 | * |
623 | * @return 0 on success and 'cmd' will be filled with the | 648 | * returns: 0 on success and 'cmd' will be filled with the |
624 | * firmware's response | 649 | * firmware's response |
625 | */ | 650 | */ |
626 | int lbs_cmd_fwt_access(struct lbs_private *priv, u16 cmd_action, | 651 | int lbs_cmd_fwt_access(struct lbs_private *priv, u16 cmd_action, |
627 | struct cmd_ds_fwt_access *cmd) | 652 | struct cmd_ds_fwt_access *cmd) |
@@ -774,7 +799,10 @@ static int mesh_get_default_parameters(struct device *dev, | |||
774 | } | 799 | } |
775 | 800 | ||
776 | /** | 801 | /** |
777 | * @brief Get function for sysfs attribute bootflag | 802 | * bootflag_get - Get function for sysfs attribute bootflag |
803 | * @dev: the &struct device | ||
804 | * @attr: device attributes | ||
805 | * @buf: buffer where data will be returned | ||
778 | */ | 806 | */ |
779 | static ssize_t bootflag_get(struct device *dev, | 807 | static ssize_t bootflag_get(struct device *dev, |
780 | struct device_attribute *attr, char *buf) | 808 | struct device_attribute *attr, char *buf) |
@@ -791,7 +819,11 @@ static ssize_t bootflag_get(struct device *dev, | |||
791 | } | 819 | } |
792 | 820 | ||
793 | /** | 821 | /** |
794 | * @brief Set function for sysfs attribute bootflag | 822 | * bootflag_set - Set function for sysfs attribute bootflag |
823 | * @dev: the &struct device | ||
824 | * @attr: device attributes | ||
825 | * @buf: buffer that contains new attribute value | ||
826 | * @count: size of buffer | ||
795 | */ | 827 | */ |
796 | static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, | 828 | static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, |
797 | const char *buf, size_t count) | 829 | const char *buf, size_t count) |
@@ -817,7 +849,10 @@ static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr, | |||
817 | } | 849 | } |
818 | 850 | ||
819 | /** | 851 | /** |
820 | * @brief Get function for sysfs attribute boottime | 852 | * boottime_get - Get function for sysfs attribute boottime |
853 | * @dev: the &struct device | ||
854 | * @attr: device attributes | ||
855 | * @buf: buffer where data will be returned | ||
821 | */ | 856 | */ |
822 | static ssize_t boottime_get(struct device *dev, | 857 | static ssize_t boottime_get(struct device *dev, |
823 | struct device_attribute *attr, char *buf) | 858 | struct device_attribute *attr, char *buf) |
@@ -834,7 +869,11 @@ static ssize_t boottime_get(struct device *dev, | |||
834 | } | 869 | } |
835 | 870 | ||
836 | /** | 871 | /** |
837 | * @brief Set function for sysfs attribute boottime | 872 | * boottime_set - Set function for sysfs attribute boottime |
873 | * @dev: the &struct device | ||
874 | * @attr: device attributes | ||
875 | * @buf: buffer that contains new attribute value | ||
876 | * @count: size of buffer | ||
838 | */ | 877 | */ |
839 | static ssize_t boottime_set(struct device *dev, | 878 | static ssize_t boottime_set(struct device *dev, |
840 | struct device_attribute *attr, const char *buf, size_t count) | 879 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -869,7 +908,10 @@ static ssize_t boottime_set(struct device *dev, | |||
869 | } | 908 | } |
870 | 909 | ||
871 | /** | 910 | /** |
872 | * @brief Get function for sysfs attribute channel | 911 | * channel_get - Get function for sysfs attribute channel |
912 | * @dev: the &struct device | ||
913 | * @attr: device attributes | ||
914 | * @buf: buffer where data will be returned | ||
873 | */ | 915 | */ |
874 | static ssize_t channel_get(struct device *dev, | 916 | static ssize_t channel_get(struct device *dev, |
875 | struct device_attribute *attr, char *buf) | 917 | struct device_attribute *attr, char *buf) |
@@ -886,7 +928,11 @@ static ssize_t channel_get(struct device *dev, | |||
886 | } | 928 | } |
887 | 929 | ||
888 | /** | 930 | /** |
889 | * @brief Set function for sysfs attribute channel | 931 | * channel_set - Set function for sysfs attribute channel |
932 | * @dev: the &struct device | ||
933 | * @attr: device attributes | ||
934 | * @buf: buffer that contains new attribute value | ||
935 | * @count: size of buffer | ||
890 | */ | 936 | */ |
891 | static ssize_t channel_set(struct device *dev, struct device_attribute *attr, | 937 | static ssize_t channel_set(struct device *dev, struct device_attribute *attr, |
892 | const char *buf, size_t count) | 938 | const char *buf, size_t count) |
@@ -912,13 +958,15 @@ static ssize_t channel_set(struct device *dev, struct device_attribute *attr, | |||
912 | } | 958 | } |
913 | 959 | ||
914 | /** | 960 | /** |
915 | * @brief Get function for sysfs attribute mesh_id | 961 | * mesh_id_get - Get function for sysfs attribute mesh_id |
962 | * @dev: the &struct device | ||
963 | * @attr: device attributes | ||
964 | * @buf: buffer where data will be returned | ||
916 | */ | 965 | */ |
917 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, | 966 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, |
918 | char *buf) | 967 | char *buf) |
919 | { | 968 | { |
920 | struct mrvl_mesh_defaults defs; | 969 | struct mrvl_mesh_defaults defs; |
921 | int maxlen; | ||
922 | int ret; | 970 | int ret; |
923 | 971 | ||
924 | ret = mesh_get_default_parameters(dev, &defs); | 972 | ret = mesh_get_default_parameters(dev, &defs); |
@@ -927,21 +975,23 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, | |||
927 | return ret; | 975 | return ret; |
928 | 976 | ||
929 | if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) { | 977 | if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) { |
930 | lbs_pr_err("inconsistent mesh ID length"); | 978 | dev_err(dev, "inconsistent mesh ID length\n"); |
931 | defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN; | 979 | defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN; |
932 | } | 980 | } |
933 | 981 | ||
934 | /* SSID not null terminated: reserve room for \0 + \n */ | 982 | memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len); |
935 | maxlen = defs.meshie.val.mesh_id_len + 2; | 983 | buf[defs.meshie.val.mesh_id_len] = '\n'; |
936 | maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE; | 984 | buf[defs.meshie.val.mesh_id_len + 1] = '\0'; |
937 | |||
938 | defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0'; | ||
939 | 985 | ||
940 | return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id); | 986 | return defs.meshie.val.mesh_id_len + 1; |
941 | } | 987 | } |
942 | 988 | ||
943 | /** | 989 | /** |
944 | * @brief Set function for sysfs attribute mesh_id | 990 | * mesh_id_set - Set function for sysfs attribute mesh_id |
991 | * @dev: the &struct device | ||
992 | * @attr: device attributes | ||
993 | * @buf: buffer that contains new attribute value | ||
994 | * @count: size of buffer | ||
945 | */ | 995 | */ |
946 | static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, | 996 | static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, |
947 | const char *buf, size_t count) | 997 | const char *buf, size_t count) |
@@ -983,7 +1033,10 @@ static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr, | |||
983 | } | 1033 | } |
984 | 1034 | ||
985 | /** | 1035 | /** |
986 | * @brief Get function for sysfs attribute protocol_id | 1036 | * protocol_id_get - Get function for sysfs attribute protocol_id |
1037 | * @dev: the &struct device | ||
1038 | * @attr: device attributes | ||
1039 | * @buf: buffer where data will be returned | ||
987 | */ | 1040 | */ |
988 | static ssize_t protocol_id_get(struct device *dev, | 1041 | static ssize_t protocol_id_get(struct device *dev, |
989 | struct device_attribute *attr, char *buf) | 1042 | struct device_attribute *attr, char *buf) |
@@ -1000,7 +1053,11 @@ static ssize_t protocol_id_get(struct device *dev, | |||
1000 | } | 1053 | } |
1001 | 1054 | ||
1002 | /** | 1055 | /** |
1003 | * @brief Set function for sysfs attribute protocol_id | 1056 | * protocol_id_set - Set function for sysfs attribute protocol_id |
1057 | * @dev: the &struct device | ||
1058 | * @attr: device attributes | ||
1059 | * @buf: buffer that contains new attribute value | ||
1060 | * @count: size of buffer | ||
1004 | */ | 1061 | */ |
1005 | static ssize_t protocol_id_set(struct device *dev, | 1062 | static ssize_t protocol_id_set(struct device *dev, |
1006 | struct device_attribute *attr, const char *buf, size_t count) | 1063 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -1037,7 +1094,10 @@ static ssize_t protocol_id_set(struct device *dev, | |||
1037 | } | 1094 | } |
1038 | 1095 | ||
1039 | /** | 1096 | /** |
1040 | * @brief Get function for sysfs attribute metric_id | 1097 | * metric_id_get - Get function for sysfs attribute metric_id |
1098 | * @dev: the &struct device | ||
1099 | * @attr: device attributes | ||
1100 | * @buf: buffer where data will be returned | ||
1041 | */ | 1101 | */ |
1042 | static ssize_t metric_id_get(struct device *dev, | 1102 | static ssize_t metric_id_get(struct device *dev, |
1043 | struct device_attribute *attr, char *buf) | 1103 | struct device_attribute *attr, char *buf) |
@@ -1054,7 +1114,11 @@ static ssize_t metric_id_get(struct device *dev, | |||
1054 | } | 1114 | } |
1055 | 1115 | ||
1056 | /** | 1116 | /** |
1057 | * @brief Set function for sysfs attribute metric_id | 1117 | * metric_id_set - Set function for sysfs attribute metric_id |
1118 | * @dev: the &struct device | ||
1119 | * @attr: device attributes | ||
1120 | * @buf: buffer that contains new attribute value | ||
1121 | * @count: size of buffer | ||
1058 | */ | 1122 | */ |
1059 | static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr, | 1123 | static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr, |
1060 | const char *buf, size_t count) | 1124 | const char *buf, size_t count) |
@@ -1091,7 +1155,10 @@ static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr, | |||
1091 | } | 1155 | } |
1092 | 1156 | ||
1093 | /** | 1157 | /** |
1094 | * @brief Get function for sysfs attribute capability | 1158 | * capability_get - Get function for sysfs attribute capability |
1159 | * @dev: the &struct device | ||
1160 | * @attr: device attributes | ||
1161 | * @buf: buffer where data will be returned | ||
1095 | */ | 1162 | */ |
1096 | static ssize_t capability_get(struct device *dev, | 1163 | static ssize_t capability_get(struct device *dev, |
1097 | struct device_attribute *attr, char *buf) | 1164 | struct device_attribute *attr, char *buf) |
@@ -1108,7 +1175,11 @@ static ssize_t capability_get(struct device *dev, | |||
1108 | } | 1175 | } |
1109 | 1176 | ||
1110 | /** | 1177 | /** |
1111 | * @brief Set function for sysfs attribute capability | 1178 | * capability_set - Set function for sysfs attribute capability |
1179 | * @dev: the &struct device | ||
1180 | * @attr: device attributes | ||
1181 | * @buf: buffer that contains new attribute value | ||
1182 | * @count: size of buffer | ||
1112 | */ | 1183 | */ |
1113 | static ssize_t capability_set(struct device *dev, struct device_attribute *attr, | 1184 | static ssize_t capability_set(struct device *dev, struct device_attribute *attr, |
1114 | const char *buf, size_t count) | 1185 | const char *buf, size_t count) |