From: Joe Perches <joe@perches.com>
To: Srinivasan Raju <srini.raju@purelifi.com>
Cc: mostafa.afgani@purelifi.com, Kalle Valo <kvalo@codeaurora.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Rob Herring <robh@kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:NETWORKING DRIVERS (WIRELESS)"
<linux-wireless@vger.kernel.org>,
"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>
Subject: Re: [PATCH] [v2] wireless: Initial driver submission for pureLiFi devices
Date: Mon, 28 Sep 2020 05:07:19 -0700 [thread overview]
Message-ID: <c75638782a5a4bc141008c6c3dcec4fd1567da79.camel@perches.com> (raw)
In-Reply-To: <20200928102008.32568-1-srini.raju@purelifi.com>
On Mon, 2020-09-28 at 15:49 +0530, Srinivasan Raju wrote:
> This introduces the pureLiFi LiFi driver for LiFi-X, LiFi-XC
> and LiFi-XL USB devices, which provide lightweight, highspeed secure and
> fully networked wireless communications via light.
trivial notes:
> diff --git a/drivers/net/wireless/purelifi/chip.c b/drivers/net/wireless/purelifi/chip.c
[]
> +static void print_chip_info(struct purelifi_chip *chip)
> +{
> + u8 *addr = purelifi_mac_get_perm_addr(purelifi_chip_to_mac(chip));
> + struct usb_device *udev = interface_to_usbdev(chip->usb.intf);
> +
> + pr_info("purelifi chip %04hx:%04hx v%04hx %02x-%02x-%02x %s\n",
You don't need to use %04hx for u16's
any more than you need to use %02hhx for u8's.
pr_info("purelifi chip %04x:%04x v%04x %02x-%02x-%02x %s\n",
> + le16_to_cpu(udev->descriptor.idVendor),
> + le16_to_cpu(udev->descriptor.idProduct),
> + le16_to_cpu(udev->descriptor.bcdDevice),
> + addr[0], addr[1], addr[2],
> + speed(udev->speed));
> +}
>
> +static inline void purelifi_mc_add_addr(struct purelifi_mc_hash *hash,
> + u8 *addr
> + )
Can you use normal close parenthesis locations?
> diff --git a/drivers/net/wireless/purelifi/def.h b/drivers/net/wireless/purelifi/def.h
> new file mode 100644
> index 000000000000..295dfb45b568
> --- /dev/null
> +++ b/drivers/net/wireless/purelifi/def.h
> @@ -0,0 +1,46 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _PURELIFI_DEF_H
> +#define _PURELIFI_DEF_H
> +
> +#include <linux/kernel.h>
> +#include <linux/stringify.h>
> +#include <linux/device.h>
> +
> +typedef u16 __nocast purelifi_addr_t;
> +
> +#define dev_printk_f(level, dev, fmt, args...) \
> + dev_printk(level, dev, "%s() " fmt, __func__, ##args)
If you _really_w want __func__ output you could use
#define dev_fmt "%s(): " fmt, __func__
> +
> +#ifdef DEBUG
> +# define dev_dbg_f(dev, fmt, args...) \
> + dev_printk_f(KERN_DEBUG, dev, fmt, ## args)
> +# define dev_dbg_f_limit(dev, fmt, args...) do { \
> + if (net_ratelimit()) \
> + dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
> +} while (0)
> +# define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \
> + bool __cond = !!(cond); \
> + if (unlikely(__cond)) \
> + dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
> +})
> +#else
> +# define dev_dbg_f(dev, fmt, args...) (void)(dev)
no_printk
> +# define dev_dbg_f_limit(dev, fmt, args...) (void)(dev)
> +# define dev_dbg_f_cond(dev, cond, fmt, args...) (void)(dev)
> +#endif /* DEBUG */
>
[]
> +++ b/drivers/net/wireless/purelifi/log.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _PURELIFI_LOG
> +#define _PURELIFI_LOG
> +
> +#ifdef PL_DEBUG
> +#define pl_dev_info(dev, fmt, arg...) dev_info(dev, fmt, ##arg)
> +#define pl_dev_warn(dev, fmt, arg...) dev_warn(dev, fmt, ##arg)
> +#define pl_dev_err(dev, fmt, arg...) dev_err(dev, fmt, ##arg)
Seems completely pointless.
Debugging output should be at KERN_DEBUG
> +#else
> +#define pl_dev_info(dev, fmt, arg...) (void)(dev)
> +#define pl_dev_warn(dev, fmt, arg...) (void)(dev)
> +#define pl_dev_err(dev, fmt, arg...) (void)(dev)
> +#endif
> +#endif
> diff --git a/drivers/net/wireless/purelifi/mac.c b/drivers/net/wireless/purelifi/mac.c
[]
> +int purelifi_mac_init_hw(struct ieee80211_hw *hw)
> +{
> + int r;
> + struct purelifi_mac *mac = purelifi_hw_mac(hw);
> + struct purelifi_chip *chip = &mac->chip;
> +
> + r = purelifi_chip_init_hw(chip);
> + if (r) {
> + pl_dev_warn(purelifi_mac_dev(mac), "%s::purelifi_chip_init_hw failed. (%d)\n",
> + __func__, r);
Odd double colon with odd spacing too.
> + goto out;
> + }
> + PURELIFI_ASSERT(!irqs_disabled());
> +
> + r = regulatory_hint(hw->wiphy, "CA");
> +out:
> + return r;
> +}
> +
> +void purelifi_mac_release(struct purelifi_mac *mac)
> +{
> + purelifi_chip_release(&mac->chip);
> + lockdep_assert_held(&mac->lock);
> +}
> +
> +int purelifi_op_start(struct ieee80211_hw *hw)
> +{
> + regulatory_hint(hw->wiphy, "EU");
> + purelifi_hw_mac(hw)->chip.usb.initialized = 1;
> + return 0;
> +}
> +
> +void purelifi_op_stop(struct ieee80211_hw *hw)
> +{
> + struct purelifi_mac *mac = purelifi_hw_mac(hw);
> + struct purelifi_chip *chip = &mac->chip;
> + struct sk_buff *skb;
> + struct sk_buff_head *ack_wait_queue = &mac->ack_wait_queue;
> +
> + pl_dev_info(purelifi_mac_dev(mac), "%s", __func__);
Unnecessary as ftrace works well
[]
> +static int fill_ctrlset(struct purelifi_mac *mac, struct sk_buff *skb)
> +{
> + unsigned int frag_len = skb->len;
> + unsigned int tmp;
> + struct purelifi_ctrlset *cs;
> +
> + if (skb_headroom(skb) >= sizeof(struct purelifi_ctrlset)) {
> + cs = (struct purelifi_ctrlset *)skb_push(skb,
> + sizeof(struct purelifi_ctrlset));
> + } else {
> + pl_dev_info(purelifi_mac_dev(mac), "Not enough hroom(1)\n");
> + return 1;
> + }
Reverse the test please
if (skb_headroom(skb) < sizeof(struct purelifi_ctrlset)) {
pl_dev_info(purelifi_mac_dev(mac), "Not enough hroom(1)\n");
return 1;
}
cs = (struct purelifi_ctrlset *)skb_push(skb, sizeof(struct purelifi_ctrlset));
> +
> + cs->id = USB_REQ_DATA_TX;
> + cs->payload_len_nw = frag_len;
> + cs->len = cs->payload_len_nw + sizeof(struct purelifi_ctrlset)
> + - sizeof(cs->id) - sizeof(cs->len);
[]
> + /*check if 32 bit aligned */
> + tmp = skb->len & 3;
> + if (tmp) {
> + if (skb_tailroom(skb) >= (3 - tmp)) {
> + skb_put(skb, 4 - tmp);
> + } else {
> + if (skb_headroom(skb) >= 4 - tmp) {
> + u8 len;
> + u8 *src_pt;
> + u8 *dest_pt;
> +
> + len = skb->len;
> + src_pt = skb->data;
> + dest_pt = skb_push(skb, 4 - tmp);
> + memcpy(dest_pt, src_pt, len);
> + } else {
> + return 1;
and reverse the test here and use and unindent
> + }
> + }
> + cs->len += 4 - tmp;
> + }
> +
> + //check if not multiple of 512
> + tmp = skb->len & 0x1ff;
> + if (!tmp) {
> + if (skb_tailroom(skb) >= 4) {
> + skb_put(skb, 4);
> + } else {
> + if (skb_headroom(skb) >= 4) {
> + u8 len = skb->len;
> + u8 *src_pt = skb->data;
> + u8 *dest_pt = skb_push(skb, 4);
> +
> + memcpy(dest_pt, src_pt, len);
> + } else {
> + /* should never happen b/c
> + * sufficient headroom was reserved
> + */
> + return 1;
> + }
> + }
> +
and here
[]
> +static int purelifi_op_add_interface(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif)
> +{
> + struct purelifi_mac *mac = purelifi_hw_mac(hw);
> +
> + pl_dev_info(purelifi_mac_dev(mac), "%s\n", __func__);
> +
> + if (mac->type != NL80211_IFTYPE_UNSPECIFIED)
> + return -EOPNOTSUPP;
> +
> + switch (vif->type) {
> + case NL80211_IFTYPE_MONITOR:
> + pl_dev_info(purelifi_mac_dev(mac),
> + "%s::NL80211_IFTYPE_MONITOR\n",
> + __func__);
> + break;
> + case NL80211_IFTYPE_MESH_POINT:
> + pl_dev_info(purelifi_mac_dev(mac),
> + "%s::NL80211_IFTYPE_MESH_POINT\n",
> + __func__);
> + break;
> + case NL80211_IFTYPE_STATION:
> + pl_dev_info(purelifi_mac_dev(mac),
> + "%s::NL80211_IFTYPE_STATION\n",
> + __func__);
> + break;
> + case NL80211_IFTYPE_ADHOC:
> + pl_dev_info(purelifi_mac_dev(mac),
> + "%s::NL80211_IFTYPE_ADHOC\n",
> + __func__);
> + break;
> + case NL80211_IFTYPE_AP:
> + pl_dev_info(purelifi_mac_dev(mac),
> + "%s::vif->type=NL80211_IFTYPE_AP\n",
> + __func__);
> + break;
Create and use a lookup table and use a single
output
> + default:
> + return -EOPNOTSUPP;
> + }
> + mac->type = vif->type;
> + mac->vif = vif;
> + return 0;
> +}
>
[]
> +static void purelifi_get_et_stats(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif,
> + struct ethtool_stats *stats, u64 *data)
odd alignment.
Didn't look at the rest
next prev parent reply other threads:[~2020-09-28 12:07 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 15:18 [PATCH] staging: Initial driver submission for pureLiFi devices Srinivasan Raju
2020-09-24 15:36 ` Greg Kroah-Hartman
2020-09-24 17:24 ` Srinivasan Raju
2020-09-24 17:29 ` Greg Kroah-Hartman
2020-09-28 10:25 ` Srinivasan Raju
2020-09-24 15:37 ` Greg Kroah-Hartman
2020-09-24 18:28 ` Randy Dunlap
2020-09-28 10:27 ` Srinivasan Raju
2020-09-24 19:07 ` Dan Carpenter
2020-09-28 10:26 ` Srinivasan Raju
2020-09-28 10:19 ` [PATCH] [v2] wireless: " Srinivasan Raju
2020-09-28 12:07 ` Joe Perches [this message]
2020-09-28 12:53 ` Srinivasan Raju
2020-09-30 5:16 ` Leon Romanovsky
2020-09-30 5:29 ` Srinivasan Raju
2020-09-30 8:01 ` Kalle Valo
2020-09-30 9:55 ` Leon Romanovsky
2020-09-30 10:11 ` Johannes Berg
2020-09-30 10:44 ` Leon Romanovsky
2020-10-16 8:23 ` Kalle Valo
2020-09-30 8:05 ` Kalle Valo
2020-09-30 10:04 ` Leon Romanovsky
2020-10-14 6:19 ` [PATCH] [PATCH] [v3] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2020-10-14 10:17 ` kernel test robot
2020-10-15 22:35 ` Joe Perches
2020-10-16 6:36 ` Srinivasan Raju
2020-10-16 6:34 ` [PATCH] [v4] " Srinivasan Raju
2020-10-16 8:58 ` Joe Perches
2020-10-16 10:13 ` Srinivasan Raju
2020-10-19 3:17 ` [PATCH] [v5] " Srinivasan Raju
2020-10-19 4:55 ` Joe Perches
2020-10-19 6:05 ` Srinivasan Raju
2020-10-19 8:38 ` [PATCH] [v6] " Srinivasan Raju
2020-10-19 16:07 ` Krishna Chaitanya
2020-10-19 16:40 ` Srinivasan Raju
2020-10-19 16:54 ` Joe Perches
2020-10-19 17:05 ` Srinivasan Raju
2020-11-16 9:22 ` [PATCH] [v7] " Srinivasan Raju
2020-11-16 20:45 ` Joe Perches
2020-11-18 3:24 ` Srinivasan Raju
2020-11-24 14:44 ` Kalle Valo
[not found] ` <20201124144448.4E95EC43460@smtp.codeaurora.org>
2020-11-26 5:01 ` Srinivasan Raju
2020-12-03 4:43 ` Srinivasan Raju
2020-12-03 15:58 ` Kalle Valo
2020-12-03 16:50 ` Srinivasan Raju
2020-12-19 13:15 ` Kalle Valo
2020-12-03 4:38 ` [PATCH] [v8] " Srinivasan Raju
2020-12-03 5:09 ` [PATCH] [v9] " Srinivasan Raju
2020-12-03 7:53 ` Joe Perches
2020-12-08 5:53 ` [PATCH] [v10] " Srinivasan Raju
2020-12-08 11:57 ` [PATCH] [v11] " Srinivasan Raju
2020-12-08 14:37 ` Kalle Valo
2020-12-19 12:51 ` Kalle Valo
2020-12-19 13:06 ` Kalle Valo
2020-12-19 13:14 ` Kalle Valo
2020-12-21 5:52 ` Srinivasan Raju
2020-12-21 5:57 ` Kalle Valo
2021-01-15 12:13 ` Srinivasan Raju
2021-01-05 13:19 ` [PATCH] [PATCH] [v12] " Srinivasan Raju
2021-02-12 11:49 ` [PATCH] [v13] " Srinivasan Raju
2021-02-12 13:44 ` Johannes Berg
2021-02-17 10:05 ` Kalle Valo
2021-02-19 5:15 ` Srinivasan Raju
2021-02-19 8:25 ` Johannes Berg
2021-02-24 10:41 ` Srinivasan Raju
2021-02-12 15:06 ` kernel test robot
2021-02-12 17:57 ` kernel test robot
2021-02-17 10:02 ` Kalle Valo
2021-02-17 10:13 ` Kalle Valo
2021-02-17 10:16 ` Srinivasan Raju
2021-02-17 10:09 ` Kalle Valo
2021-02-17 10:19 ` Kalle Valo
2021-02-24 10:44 ` Srinivasan Raju
2021-02-26 13:07 ` [PATCH] [v14] " Srinivasan Raju
2021-04-19 11:52 ` Srinivasan Raju
2021-08-10 13:02 ` Srinivasan Raju
2021-08-21 13:42 ` Kalle Valo
2021-08-18 14:13 ` [PATCH] [v15] " Srinivasan Raju
2021-09-20 13:05 ` Kalle Valo
[not found] ` <CWLP265MB3217BB5AA5F102629A3AD204E0A19@CWLP265MB3217.GBRP265.PROD.OUTLOOK.COM>
2021-09-21 12:30 ` [EXTERNAL] " Kalle Valo
2021-09-22 7:33 ` Johannes Berg
2021-09-24 13:27 ` [EXTERNAL] " Srinivasan Raju
2021-09-20 14:11 ` Kalle Valo
2021-09-24 11:11 ` Kalle Valo
2021-09-24 13:26 ` [PATCH] [v16] wireless: Initial driver submission for pureLiFi LiFi Station Srinivasan Raju
2021-09-24 13:40 ` Kalle Valo
2021-10-05 11:22 ` [PATCH] [v17] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2021-10-05 11:26 ` Johannes Berg
2021-10-05 12:30 ` [PATCH] [v18 1/2] nl80211: Add LC placeholder band definition to enum nl80211_band Srinivasan Raju
2021-10-05 12:31 ` [PATCH] [v18 2/2] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2021-10-05 22:09 ` Jeff Johnson
2021-10-06 10:04 ` [PATCH] [v19 " Srinivasan Raju
2021-10-11 6:16 ` Kalle Valo
2021-10-12 12:50 ` [PATCH 0/2] wireless: New Driver " Srinivasan Raju
2021-10-12 12:50 ` [PATCH 1/2] [v19 1/2] nl80211: Add LC placeholder band definition to enum nl80211_band Srinivasan Raju
2021-10-12 12:50 ` [PATCH 2/2] [v19 2/2] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2021-10-14 6:03 ` kernel test robot
2021-10-24 17:58 ` kernel test robot
2021-10-18 10:00 ` [PATCH v20 0/2] wireless: New Driver " Srinivasan Raju
2021-10-18 10:00 ` [PATCH v20 1/2] nl80211: Add LC placeholder band definition to nl80211_band Srinivasan Raju
2021-10-18 10:00 ` [PATCH v20 2/2] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2021-10-25 9:59 ` Kari Argillander
[not found] ` <CWLP265MB321780AB502EF147F6AAF197E0839@CWLP265MB3217.GBRP265.PROD.OUTLOOK.COM>
2021-10-25 12:17 ` [EXTERNAL] " Kalle Valo
2021-10-27 11:34 ` kernel test robot
2021-10-27 12:38 ` Kari Argillander
2021-10-28 7:24 ` Kalle Valo
2021-10-31 13:10 ` [PATCH v21 0/2] wireless: New Driver " Srinivasan Raju
2021-10-31 13:10 ` [PATCH 1/2] nl80211: Add LC placeholder band definition to nl80211_band Srinivasan Raju
2021-10-31 13:10 ` [PATCH 2/2] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2021-12-20 19:13 ` Kalle Valo
2022-02-24 15:35 ` Kalle Valo
2022-02-24 18:20 ` [PATCH v22 0/2] wireless: New Driver " Srinivasan Raju
2022-02-24 18:20 ` [PATCH v22 1/2] nl80211: Add LC placeholder band definition to nl80211_band Srinivasan Raju
2022-02-25 9:52 ` Kalle Valo
2022-02-24 18:20 ` [PATCH v22 1/2] wireless: Initial driver submission for pureLiFi STA devices Srinivasan Raju
2022-04-25 13:06 ` Kalle Valo
[not found] ` <CWLP265MB32173F6188304F6B2CB90C79E0F89@CWLP265MB3217.GBRP265.PROD.OUTLOOK.COM>
2022-04-26 4:17 ` [EXTERNAL] " Kalle Valo
2022-04-27 4:55 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c75638782a5a4bc141008c6c3dcec4fd1567da79.camel@perches.com \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=mostafa.afgani@purelifi.com \
--cc=netdev@vger.kernel.org \
--cc=robh@kernel.org \
--cc=srini.raju@purelifi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).