mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jerome Pouiller <Jerome.Pouiller@silabs.com>
Subject: [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h
Date: Thu, 17 Oct 2019 09:40:05 +0000	[thread overview]
Message-ID: <20191017093954.657-2-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20191017093954.657-1-Jerome.Pouiller@silabs.com>

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

"Secure link" feature is not available in in-tree driver (because it
depends on mbedtls). Thus, secure_link.h only empty functions.

Module parameter "slk_key" and associated function wfx_fill_sl_key() had
an unjustifiable place in main.c. This patch relocate them to
secure_link.h.

BTW, content of wfx_fill_sl_key() is now useless. Just keep a warning if
user try to use "slk_key" attribute (unsupported by this driver).

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/main.c        | 29 +----------------------------
 drivers/staging/wfx/main.h        |  1 -
 drivers/staging/wfx/secure_link.h |  9 +++++++++
 3 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 157e0fc0107e..3a43f190d96a 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -44,10 +44,6 @@ static int gpio_wakeup = -2;
 module_param(gpio_wakeup, int, 0644);
 MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none.");
 
-static char *slk_key;
-module_param(slk_key, charp, 0600);
-MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexadecimal digits).");
-
 #define RATETAB_ENT(_rate, _rateid, _flags) { \
 	.bitrate  = (_rate),   \
 	.hw_value = (_rateid), \
@@ -194,29 +190,6 @@ struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *lab
 	return ret;
 }
 
-static void wfx_fill_sl_key(struct device *dev, struct wfx_platform_data *pdata)
-{
-	const char *ascii_key = NULL;
-	int ret = 0;
-
-	if (slk_key)
-		ascii_key = slk_key;
-	if (!ascii_key)
-		ret = of_property_read_string(dev->of_node, "slk_key", &ascii_key);
-	if (ret == -EILSEQ || ret == -ENODATA)
-		dev_err(dev, "ignoring malformatted key from DT\n");
-	if (!ascii_key)
-		return;
-
-	ret = hex2bin(pdata->slk_key, ascii_key, sizeof(pdata->slk_key));
-	if (ret) {
-		dev_err(dev, "ignoring malformatted key: %s\n", ascii_key);
-		memset(pdata->slk_key, 0, sizeof(pdata->slk_key));
-		return;
-	}
-	dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n");
-}
-
 /* NOTE: wfx_send_pds() destroy buf */
 int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len)
 {
@@ -334,7 +307,7 @@ struct wfx_dev *wfx_init_common(struct device *dev,
 	memcpy(&wdev->pdata, pdata, sizeof(*pdata));
 	of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds);
 	wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup");
-	wfx_fill_sl_key(dev, &wdev->pdata);
+	wfx_sl_fill_pdata(dev, &wdev->pdata);
 
 	mutex_init(&wdev->conf_mutex);
 	mutex_init(&wdev->rx_stats_lock);
diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h
index f2b07ed1627c..875f8c227803 100644
--- a/drivers/staging/wfx/main.h
+++ b/drivers/staging/wfx/main.h
@@ -22,7 +22,6 @@ struct wfx_platform_data {
 	/* Keyset and ".sec" extention will appended to this string */
 	const char *file_fw;
 	const char *file_pds;
-	unsigned char slk_key[API_KEY_VALUE_SIZE];
 	struct gpio_desc *gpio_wakeup;
 	/*
 	 * if true HIF D_out is sampled on the rising edge of the clock
diff --git a/drivers/staging/wfx/secure_link.h b/drivers/staging/wfx/secure_link.h
index e2da1c73c760..376d7bc4c0c4 100644
--- a/drivers/staging/wfx/secure_link.h
+++ b/drivers/staging/wfx/secure_link.h
@@ -5,6 +5,8 @@
 #ifndef WFX_SECURE_LINK_H
 #define WFX_SECURE_LINK_H
 
+#include <linux/of.h>
+
 #include "hif_api_general.h"
 
 struct wfx_dev;
@@ -33,6 +35,13 @@ static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, uint8_t *ncp_pubkey,
 	return -EIO;
 }
 
+static inline void wfx_sl_fill_pdata(struct device *dev,
+				     struct wfx_platform_data *pdata)
+{
+	if (of_find_property(dev->of_node, "slk_key", NULL))
+		dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n");
+}
+
 static inline int wfx_sl_init(struct wfx_dev *wdev)
 {
 	return -EIO;
-- 
2.20.1

  reply	other threads:[~2019-10-17  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
2019-10-17  9:40 ` Jerome Pouiller [this message]
2019-10-17  9:40 ` [PATCH 5/6] staging: wfx: fix setting MAC address from DT Jerome Pouiller
2019-10-17  9:40 ` [PATCH 3/6] staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y Jerome Pouiller
2019-10-17  9:40 ` [PATCH 4/6] staging: wfx: fix Oops when CONFIG_OF_NET is not set Jerome Pouiller
2019-10-17  9:40 ` [PATCH 6/6] staging: wfx: fix number of available tx_policies Jerome Pouiller

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=20191017093954.657-2-Jerome.Pouiller@silabs.com \
    --to=jerome.pouiller@silabs.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®