treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / phy / ax88796b.c
blob79bf7ef1fcfd6a210c409acb282251ef30cb1341
1 // SPDX-License-Identifier: GPL-2.0+
2 /* Driver for Asix PHYs
4 * Author: Michael Schmitz <schmitzmic@gmail.com>
5 */
6 #include <linux/kernel.h>
7 #include <linux/errno.h>
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/mii.h>
11 #include <linux/phy.h>
13 #define PHY_ID_ASIX_AX88796B 0x003b1841
15 MODULE_DESCRIPTION("Asix PHY driver");
16 MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
17 MODULE_LICENSE("GPL");
19 /**
20 * asix_soft_reset - software reset the PHY via BMCR_RESET bit
21 * @phydev: target phy_device struct
23 * Description: Perform a software PHY reset using the standard
24 * BMCR_RESET bit and poll for the reset bit to be cleared.
25 * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
26 * such as used on the Individual Computers' X-Surf 100 Zorro card.
28 * Returns: 0 on success, < 0 on failure
30 static int asix_soft_reset(struct phy_device *phydev)
32 int ret;
34 /* Asix PHY won't reset unless reset bit toggles */
35 ret = phy_write(phydev, MII_BMCR, 0);
36 if (ret < 0)
37 return ret;
39 return genphy_soft_reset(phydev);
42 static struct phy_driver asix_driver[] = { {
43 .phy_id = PHY_ID_ASIX_AX88796B,
44 .name = "Asix Electronics AX88796B",
45 .phy_id_mask = 0xfffffff0,
46 /* PHY_BASIC_FEATURES */
47 .soft_reset = asix_soft_reset,
48 } };
50 module_phy_driver(asix_driver);
52 static struct mdio_device_id __maybe_unused asix_tbl[] = {
53 { PHY_ID_ASIX_AX88796B, 0xfffffff0 },
54 { }
57 MODULE_DEVICE_TABLE(mdio, asix_tbl);