zkkkk12 commented on code in PR #21485:
URL: https://github.com/apache/nuttx/pull/21485#discussion_r4509278031
##########
drivers/net/mdio.c:
##########
@@ -211,43 +323,204 @@ int mdio_write(FAR struct mdio_bus_s *dev, uint8_t
phyaddr, uint8_t regaddr,
* Name: mdio_reset
*
* Description:
- * Reset a PHY on the MDIO bus.
+ * Control the hardware reset line of a PHY on the MDIO bus.
*
* Input Parameters:
* dev - The MDIO bus handle.
* phyaddr - The PHY address (0-31) to reset.
+ * value - Non-zero to assert reset, zero to deassert.
*
* Returned Value:
- * Zero (OK) on success; a negated errno value on failure.
+ * Zero (OK) on success; -ENOSYS if no reset op is provided; a negated
+ * errno value on failure.
*
****************************************************************************/
-int mdio_reset(FAR struct mdio_bus_s *dev, uint8_t phyaddr)
+int mdio_reset(FAR struct mdio_bus_s *dev, uint8_t phyaddr, int value)
{
- int ret = -ENOSYS;
+ int ret;
DEBUGASSERT(dev != NULL && dev->lower != NULL);
- /* Check if the reset method is provided by the lower-half */
+ /* No reset line wired / no lower-half op: nothing to do. */
- if (dev->lower->ops->reset)
+ if (dev->lower->ops->reset == NULL)
{
- /* Take the mutex */
+ return -ENOSYS;
+ }
- ret = nxmutex_lock(&dev->lock);
- if (ret < 0)
- {
- return ret;
- }
+ ret = nxmutex_lock(&dev->lock);
+ if (ret < 0)
+ {
+ return ret;
+ }
- /* Call the lowerhalf driver's reset method */
+ /* Idempotency: skip if the requested state is already in effect. */
- ret = MDIO_RESET(dev, phyaddr);
+ if (dev->reset_state == value)
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]