X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fmiiphyutil.c;h=7e41957185072123a81468309081ec4586730867;hb=eb04ab3492297941b285ff552645cc1c0ed72edb;hp=35ad357b95072384139679d1f3bd34a3f5ec6bc1;hpb=07c07635b4f6d4ee2a03cd508beeeaccde4b9d7e;p=oweals%2Fu-boot.git diff --git a/common/miiphyutil.c b/common/miiphyutil.c index 35ad357b95..7e41957185 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -2,23 +2,7 @@ * (C) Copyright 2001 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -27,6 +11,7 @@ */ #include +#include #include #include @@ -102,6 +87,7 @@ static int legacy_miiphy_write(struct mii_dev *bus, int addr, int devad, /***************************************************************************** * * Register read and write MII access routines for the device . + * This API is now deprecated. Please use mdio_alloc and mdio_register, instead. */ void miiphy_register(const char *name, int (*read)(const char *devname, unsigned char addr, @@ -128,6 +114,8 @@ void miiphy_register(const char *name, if (new_dev == NULL || ldev == NULL) { printf("miiphy_register: cannot allocate memory for '%s'\n", name); + free(ldev); + mdio_free(new_dev); return; } @@ -166,9 +154,14 @@ struct mii_dev *mdio_alloc(void) return bus; } +void mdio_free(struct mii_dev *bus) +{ + free(bus); +} + int mdio_register(struct mii_dev *bus) { - if (!bus || !bus->name || !bus->read || !bus->write) + if (!bus || !bus->read || !bus->write) return -1; /* check if we have unique name */ @@ -187,6 +180,20 @@ int mdio_register(struct mii_dev *bus) return 0; } +int mdio_unregister(struct mii_dev *bus) +{ + if (!bus) + return 0; + + /* delete it from the list */ + list_del(&bus->link); + + if (current_mii == bus) + current_mii = NULL; + + return 0; +} + void mdio_list_devices(void) { struct list_head *entry; @@ -281,6 +288,8 @@ static struct mii_dev *miiphy_get_active_dev(const char *devname) * Read to variable from the PHY attached to device , * use PHY address and register . * + * This API is deprecated. Use phy_read on a phy_device found via phy_connect + * * Returns: * 0 on success */ @@ -307,6 +316,8 @@ int miiphy_read(const char *devname, unsigned char addr, unsigned char reg, * Write to the PHY attached to device , * use PHY address and register . * + * This API is deprecated. Use phy_write on a phy_device found by phy_connect + * * Returns: * 0 on success */ @@ -350,6 +361,8 @@ void miiphy_listdev(void) * Model: 6 bits (unsigned char) * Revision: 4 bits (unsigned char) * + * This API is deprecated. + * * Returns: * 0 on success */ @@ -389,6 +402,9 @@ int miiphy_info(const char *devname, unsigned char addr, unsigned int *oui, /***************************************************************************** * * Reset the PHY. + * + * This API is deprecated. Use PHYLIB. + * * Returns: * 0 on success */