]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/miiphyutil.c
ARM: imx6: clocks: remove function local definitions of mxc_ccm_reg and anatop_regs
[karo-tx-uboot.git] / common / miiphyutil.c
index 243cae97a468111c68b3b155541b73a13e00877d..c88c28adbf4ede84eb62422557cd14c87307acba 100644 (file)
@@ -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 <common.h>
+#include <dm.h>
 #include <miiphy.h>
 #include <phy.h>
 
@@ -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 <name>.
+ * 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,
@@ -111,7 +97,8 @@ void miiphy_register(const char *name,
 {
        struct mii_dev *new_dev;
        struct legacy_mii_dev *ldev;
-       unsigned int name_len;
+
+       BUG_ON(strlen(name) >= MDIO_NAME_LEN);
 
        /* check if we have unique name */
        new_dev = miiphy_get_dev_by_name(name);
@@ -121,14 +108,6 @@ void miiphy_register(const char *name,
        }
 
        /* allocate memory */
-       name_len = strlen(name);
-       if (name_len > MDIO_NAME_LEN - 1) {
-               /* Hopefully this won't happen, but if it does, we'll know */
-               printf("miiphy_register: MDIO name was longer than %d\n",
-                       MDIO_NAME_LEN);
-               return;
-       }
-
        new_dev = mdio_alloc();
        ldev = malloc(sizeof(*ldev));
 
@@ -141,7 +120,8 @@ void miiphy_register(const char *name,
        /* initalize mii_dev struct fields */
        new_dev->read = legacy_miiphy_read;
        new_dev->write = legacy_miiphy_write;
-       sprintf(new_dev->name, name);
+       strncpy(new_dev->name, name, MDIO_NAME_LEN);
+       new_dev->name[MDIO_NAME_LEN - 1] = 0;
        ldev->read = read;
        ldev->write = write;
        new_dev->priv = ldev;
@@ -287,6 +267,8 @@ static struct mii_dev *miiphy_get_active_dev(const char *devname)
  * Read to variable <value> from the PHY attached to device <devname>,
  * use PHY address <addr> and register <reg>.
  *
+ * This API is deprecated. Use phy_read on a phy_device found via phy_connect
+ *
  * Returns:
  *   0 on success
  */
@@ -294,14 +276,18 @@ int miiphy_read(const char *devname, unsigned char addr, unsigned char reg,
                 unsigned short *value)
 {
        struct mii_dev *bus;
+       int ret;
 
        bus = miiphy_get_active_dev(devname);
-       if (bus)
-               *value = bus->read(bus, addr, MDIO_DEVAD_NONE, reg);
-       else
+       if (!bus)
                return 1;
 
-       return (*value < 0) ? 1 : 0;
+       ret = bus->read(bus, addr, MDIO_DEVAD_NONE, reg);
+       if (ret < 0)
+               return 1;
+
+       *value = (unsigned short)ret;
+       return 0;
 }
 
 /*****************************************************************************
@@ -309,6 +295,8 @@ int miiphy_read(const char *devname, unsigned char addr, unsigned char reg,
  * Write <value> to the PHY attached to device <devname>,
  * use PHY address <addr> and register <reg>.
  *
+ * This API is deprecated. Use phy_write on a phy_device found by phy_connect
+ *
  * Returns:
  *   0 on success
  */
@@ -352,6 +340,8 @@ void miiphy_listdev(void)
  * Model:    6 bits (unsigned char)
  * Revision: 4 bits (unsigned char)
  *
+ * This API is deprecated.
+ *
  * Returns:
  *   0 on success
  */
@@ -391,6 +381,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
  */