LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: replace custom hwaddr_aton_i() with mac_pton()
@ 2021-08-12 13:20 Michael Straube
  2021-08-12 20:48 ` Phillip Potter
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Straube @ 2021-08-12 13:20 UTC (permalink / raw)
  To: gregkh
  Cc: Larry.Finger, phil, martin, linux-staging, linux-kernel, Michael Straube

Replace custom hwaddr_aton_i() with mac_pton() in core/ioctl_linux.c
and remove the now unused functions hwaddr_aton_i() and hex2num_i().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 40 +-------------------
 1 file changed, 1 insertion(+), 39 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index d059b738b348..38ee41f9d2ba 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -89,44 +89,6 @@ static const char * const iw_operation_mode[] = {
 	"Secondary", "Monitor"
 };
 
-static int hex2num_i(char c)
-{
-	if (c >= '0' && c <= '9')
-		return c - '0';
-	if (c >= 'a' && c <= 'f')
-		return c - 'a' + 10;
-	if (c >= 'A' && c <= 'F')
-		return c - 'A' + 10;
-	return -1;
-}
-
-/**
- * hwaddr_aton - Convert ASCII string to MAC address
- * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
- * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
- * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
- */
-static int hwaddr_aton_i(const char *txt, u8 *addr)
-{
-	int i;
-
-	for (i = 0; i < 6; i++) {
-		int a, b;
-
-		a = hex2num_i(*txt++);
-		if (a < 0)
-			return -1;
-		b = hex2num_i(*txt++);
-		if (b < 0)
-			return -1;
-		*addr++ = (a << 4) | b;
-		if (i < 5 && *txt++ != ':')
-			return -1;
-	}
-
-	return 0;
-}
-
 void indicate_wx_scan_complete_event(struct adapter *padapter)
 {
 	union iwreq_data wrqu;
@@ -2512,7 +2474,7 @@ static int rtw_get_ap_info(struct net_device *dev,
 	while (phead != plist) {
 		pnetwork = container_of(plist, struct wlan_network, list);
 
-		if (hwaddr_aton_i(data, bssid)) {
+		if (!mac_pton(data, bssid)) {
 			DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data);
 			spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
 			return -EINVAL;
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: r8188eu: replace custom hwaddr_aton_i() with mac_pton()
  2021-08-12 13:20 [PATCH] staging: r8188eu: replace custom hwaddr_aton_i() with mac_pton() Michael Straube
@ 2021-08-12 20:48 ` Phillip Potter
  0 siblings, 0 replies; 2+ messages in thread
From: Phillip Potter @ 2021-08-12 20:48 UTC (permalink / raw)
  To: Michael Straube
  Cc: Greg KH, Larry Finger, Martin Kaiser, linux-staging,
	Linux Kernel Mailing List

On Thu, 12 Aug 2021 at 14:21, Michael Straube <straube.linux@gmail.com> wrote:
>
> Replace custom hwaddr_aton_i() with mac_pton() in core/ioctl_linux.c
> and remove the now unused functions hwaddr_aton_i() and hex2num_i().
>
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 40 +-------------------
>  1 file changed, 1 insertion(+), 39 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index d059b738b348..38ee41f9d2ba 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -89,44 +89,6 @@ static const char * const iw_operation_mode[] = {
>         "Secondary", "Monitor"
>  };
>
> -static int hex2num_i(char c)
> -{
> -       if (c >= '0' && c <= '9')
> -               return c - '0';
> -       if (c >= 'a' && c <= 'f')
> -               return c - 'a' + 10;
> -       if (c >= 'A' && c <= 'F')
> -               return c - 'A' + 10;
> -       return -1;
> -}
> -
> -/**
> - * hwaddr_aton - Convert ASCII string to MAC address
> - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
> - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
> - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
> - */
> -static int hwaddr_aton_i(const char *txt, u8 *addr)
> -{
> -       int i;
> -
> -       for (i = 0; i < 6; i++) {
> -               int a, b;
> -
> -               a = hex2num_i(*txt++);
> -               if (a < 0)
> -                       return -1;
> -               b = hex2num_i(*txt++);
> -               if (b < 0)
> -                       return -1;
> -               *addr++ = (a << 4) | b;
> -               if (i < 5 && *txt++ != ':')
> -                       return -1;
> -       }
> -
> -       return 0;
> -}
> -
>  void indicate_wx_scan_complete_event(struct adapter *padapter)
>  {
>         union iwreq_data wrqu;
> @@ -2512,7 +2474,7 @@ static int rtw_get_ap_info(struct net_device *dev,
>         while (phead != plist) {
>                 pnetwork = container_of(plist, struct wlan_network, list);
>
> -               if (hwaddr_aton_i(data, bssid)) {
> +               if (!mac_pton(data, bssid)) {
>                         DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data);
>                         spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
>                         return -EINVAL;
> --
> 2.32.0
>

Dear Michael,

Looks good, thanks.

Acked-by: Phillip Potter <phil@philpotter.co.uk>

Regards,
Phil

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-12 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 13:20 [PATCH] staging: r8188eu: replace custom hwaddr_aton_i() with mac_pton() Michael Straube
2021-08-12 20:48 ` Phillip Potter

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).