net: lan78xx: fix runtime PM count underflow on link stop
authorOleksij Rempel <o.rempel@pengutronix.de>
Wed, 28 Feb 2024 12:45:17 +0000 (13:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Mar 2024 08:38:59 +0000 (08:38 +0000)
commit1eecc7ab82c42133b748e1895275942a054a7f67
treee2ed6cff371785c471578d5d294a93ac4d9941c2
parent7be40883b1cb734a31a3cbfd5f8f64a97965d26f
net: lan78xx: fix runtime PM count underflow on link stop

Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
working only because this driver do not activate autosuspend by default,
so it was visible only by warning "Runtime PM usage count underflow!".

Since, with current driver, we can't use runtime PM with active link,
execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
keep ref counting high as long as interface is open.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/lan78xx.c