diff mbox series

r8152: Add mac address pass-thru for lg laptops

Message ID ZvpImQ_8jh5fyorl@mikeseo-0-1 (mailing list archive)
State New
Headers show
Series r8152: Add mac address pass-thru for lg laptops | expand

Commit Message

mike Seo Sept. 30, 2024, 6:43 a.m. UTC
LG gram laptops support mac address pass-thru with usb lan adapter
rtl8153b-2 devices using Realtek USB ethernet Vendor and Product IDs.
ACPI objects of the gram laptops are safisfied to -AD.

Signed-off-by: mike.seo <mike.seo@lge.com>
---
 drivers/net/usb/r8152.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Greg Kroah-Hartman Sept. 30, 2024, 1:19 p.m. UTC | #1
On Mon, Sep 30, 2024 at 03:43:37PM +0900, mike.seo wrote:
>  LG gram laptops support mac address pass-thru with usb lan adapter
> rtl8153b-2 devices using Realtek USB ethernet Vendor and Product IDs.
> ACPI objects of the gram laptops are safisfied to -AD.
> 
> Signed-off-by: mike.seo <mike.seo@lge.com>

Please use your name, not your email alias, for this.  It also does not
match your "From:" line, so that means we can't take it either way :(

thanks,

greg k-h
kernel test robot Sept. 30, 2024, 7:14 p.m. UTC | #2
Hi mike.seo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on westeri-thunderbolt/next]
[also build test WARNING on linus/master v6.12-rc1 next-20240930]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/mike-seo/r8152-Add-mac-address-pass-thru-for-lg-laptops/20240930-144644
base:   https://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt.git next
patch link:    https://lore.kernel.org/r/ZvpImQ_8jh5fyorl%40mikeseo-0-1
patch subject: [PATCH] r8152: Add mac address pass-thru for lg laptops
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20241001/202410010249.Gzfm9BQC-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241001/202410010249.Gzfm9BQC-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410010249.Gzfm9BQC-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In function 'rtl8152_supports_lg_macpassthru',
       inlined from 'rtl8152_probe_once.isra' at drivers/net/usb/r8152.c:9881:23:
>> drivers/net/usb/r8152.c:9800:14: warning: argument 2 null where non-null expected [-Wnonnull]
    9800 |         if (!strncmp("LG Electronics", board, sizeof("LG Electronics"))) {
         |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/usb/r8152.c:9800:14: note: in a call to built-in function '__builtin_strcmp'


vim +9800 drivers/net/usb/r8152.c

  9793	
  9794	static bool rtl8152_supports_lg_macpassthru(struct usb_device *udev)
  9795	{
  9796		int product_id = le16_to_cpu(udev->descriptor.idProduct);
  9797		int vendor_id = le16_to_cpu(udev->descriptor.idVendor);
  9798		const char *board = dmi_get_system_info(DMI_BOARD_VENDOR);
  9799	
> 9800		if (!strncmp("LG Electronics", board, sizeof("LG Electronics"))) {
  9801			if (vendor_id == VENDOR_ID_REALTEK && product_id == 0x8153)
  9802				return 1;
  9803		}
  9804		return 0;
  9805	}
  9806
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a5612c799f5e..3d4ffc582730 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -29,6 +29,7 @@ 
 #include <crypto/hash.h>
 #include <linux/usb/r8152.h>
 #include <net/gso.h>
+#include <linux/dmi.h>
 
 /* Information for net-next */
 #define NETNEXT_VERSION		"12"
@@ -949,6 +950,7 @@  struct r8152 {
 
 	u32 support_2500full:1;
 	u32 lenovo_macpassthru:1;
+	u32 lg_macpassthru:1;
 	u32 dell_tb_rx_agg_bug:1;
 	u16 ocp_base;
 	u16 speed;
@@ -1724,7 +1726,7 @@  static int vendor_mac_passthru_addr_read(struct r8152 *tp, struct sockaddr *sa)
 	} else {
 		/* test for -AD variant of RTL8153 */
 		ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
-		if ((ocp_data & AD_MASK) == 0x1000) {
+		if ((ocp_data & AD_MASK) == 0x1000 || tp->lg_macpassthru) {
 			/* test for MAC address pass-through bit */
 			ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, EFUSE);
 			if ((ocp_data & PASS_THRU_MASK) != 1) {
@@ -9798,6 +9800,19 @@  static bool rtl8152_supports_lenovo_macpassthru(struct usb_device *udev)
 	return 0;
 }
 
+static bool rtl8152_supports_lg_macpassthru(struct usb_device *udev)
+{
+	int product_id = le16_to_cpu(udev->descriptor.idProduct);
+	int vendor_id = le16_to_cpu(udev->descriptor.idVendor);
+	const char *board = dmi_get_system_info(DMI_BOARD_VENDOR);
+
+	if (!strncmp("LG Electronics", board, sizeof("LG Electronics"))) {
+		if (vendor_id == VENDOR_ID_REALTEK && product_id == 0x8153)
+			return 1;
+	}
+	return 0;
+}
+
 static int rtl8152_probe_once(struct usb_interface *intf,
 			      const struct usb_device_id *id, u8 version)
 {
@@ -9872,6 +9887,7 @@  static int rtl8152_probe_once(struct usb_interface *intf,
 	}
 
 	tp->lenovo_macpassthru = rtl8152_supports_lenovo_macpassthru(udev);
+	tp->lg_macpassthru = rtl8152_supports_lg_macpassthru(udev);
 
 	if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&
 	    (!strcmp(udev->serial, "000001000000") ||