/*****************************************************************************
*
* 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,
{
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);
}
/* 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));
/* 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;
* 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
*/
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;
+
+ ret = bus->read(bus, addr, MDIO_DEVAD_NONE, reg);
+ if (ret < 0)
return 1;
- return (*value < 0) ? 1 : 0;
+ *value = (unsigned short)ret;
+ return 0;
}
/*****************************************************************************
* 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
*/
* Model: 6 bits (unsigned char)
* Revision: 4 bits (unsigned char)
*
+ * This API is deprecated.
+ *
* Returns:
* 0 on success
*/
/*****************************************************************************
*
* Reset the PHY.
+ *
+ * This API is deprecated. Use PHYLIB.
+ *
* Returns:
* 0 on success
*/