diff mbox

[v2] wireless: ath6kl: re-use native helper to parse MAC

Message ID 1366896682-2023-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Andy Shevchenko April 25, 2013, 1:31 p.m. UTC
There is native mac_pton() function which helps to parse MAC.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/wireless/ath/ath6kl/debug.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Andy Shevchenko May 28, 2013, 8:47 a.m. UTC | #1
On Thu, 2013-04-25 at 16:31 +0300, Andy Shevchenko wrote: 
> There is native mac_pton() function which helps to parse MAC.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/net/wireless/ath/ath6kl/debug.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
> index fe38b83..dbfd17d 100644
> --- a/drivers/net/wireless/ath/ath6kl/debug.c
> +++ b/drivers/net/wireless/ath/ath6kl/debug.c
> @@ -1240,20 +1240,14 @@ static ssize_t ath6kl_force_roam_write(struct file *file,
>  	char buf[20];
>  	size_t len;
>  	u8 bssid[ETH_ALEN];
> -	int i;
> -	int addr[ETH_ALEN];
>  
>  	len = min(count, sizeof(buf) - 1);
>  	if (copy_from_user(buf, user_buf, len))
>  		return -EFAULT;
>  	buf[len] = '\0';
>  
> -	if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
> -		   &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
> -	    != ETH_ALEN)
> +	if (!mac_pton(buf, bssid))
>  		return -EINVAL;
> -	for (i = 0; i < ETH_ALEN; i++)
> -		bssid[i] = addr[i];
>  
>  	ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
>  	if (ret)

John, do you have any comment on this one?
Kalle Valo May 28, 2013, 8:51 a.m. UTC | #2
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> On Thu, 2013-04-25 at 16:31 +0300, Andy Shevchenko wrote: 
>> There is native mac_pton() function which helps to parse MAC.
>> 
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[...]

>
> John, do you have any comment on this one?

ath6kl patches go through my tree. Sorry for not being able to look at
your patch yet as I have been very busy with something else, will do
that soon.
Kalle Valo June 1, 2013, 12:13 p.m. UTC | #3
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> There is native mac_pton() function which helps to parse MAC.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks, applied.
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index fe38b83..dbfd17d 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -1240,20 +1240,14 @@  static ssize_t ath6kl_force_roam_write(struct file *file,
 	char buf[20];
 	size_t len;
 	u8 bssid[ETH_ALEN];
-	int i;
-	int addr[ETH_ALEN];
 
 	len = min(count, sizeof(buf) - 1);
 	if (copy_from_user(buf, user_buf, len))
 		return -EFAULT;
 	buf[len] = '\0';
 
-	if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
-		   &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
-	    != ETH_ALEN)
+	if (!mac_pton(buf, bssid))
 		return -EINVAL;
-	for (i = 0; i < ETH_ALEN; i++)
-		bssid[i] = addr[i];
 
 	ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
 	if (ret)