]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: lenovo-go: drop dead NULL check on to_usb_interface()
authorLouis Clinckx <clinckx.louis@gmail.com>
Fri, 15 May 2026 14:57:40 +0000 (14:57 +0000)
committerBenjamin Tissoires <bentiss@kernel.org>
Thu, 21 May 2026 15:12:54 +0000 (17:12 +0200)
to_usb_interface() is a container_of_const() macro: it performs
pointer arithmetic and never returns NULL. The if (!intf) and if
(intf) tests in get_endpoint_address() can never fire. Remove them
in both drivers.

No functional change.

Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Louis Clinckx <clinckx.louis@gmail.com>
Reviewed-by: Derek J. Clark <derekjoh.clark@gmail.com>
Tested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/hid-lenovo-go-s.c
drivers/hid/hid-lenovo-go.c

index 0444d84498bd566b5fe60c7500d86d936cc92849..a72f7f748cb50972fb60e99b726771f43269d31d 100644 (file)
@@ -382,11 +382,9 @@ static int get_endpoint_address(struct hid_device *hdev)
        struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
        struct usb_host_endpoint *ep;
 
-       if (intf) {
-               ep = intf->cur_altsetting->endpoint;
-               if (ep)
-                       return ep->desc.bEndpointAddress;
-       }
+       ep = intf->cur_altsetting->endpoint;
+       if (ep)
+               return ep->desc.bEndpointAddress;
 
        return -ENODEV;
 }
index 3fa1fe83f7e5e73a553e8f5b069dd3ea0cad25dd..e0c9d5ec9451bf92a2fec83993702d4d76d0eff2 100644 (file)
@@ -641,9 +641,6 @@ static int get_endpoint_address(struct hid_device *hdev)
        struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
        struct usb_host_endpoint *ep;
 
-       if (!intf)
-               return -ENODEV;
-
        ep = intf->cur_altsetting->endpoint;
        if (!ep)
                return -ENODEV;