net: qcom/emac: Encapsulate sgmii ops under one structure
Subsystems (3)
PATCH 1/1 net: qcom/emac: Encapsulate sgmii ops under one structure
This patch introduces ops structure for sgmii, This by ensures that we do not need dummy functions in case of emulation platforms.
Signed-off-by Hemanth Puranik <[email protected]>
--- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 5 +- drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 128 ++++++++++++++---------- drivers/net/ethernet/qualcomm/emac/emac-sgmii.h | 32 +++--- drivers/net/ethernet/qualcomm/emac/emac.c | 9 +- 4 files changed, 103 insertions(+), 71 deletions(-)
drivers/net/ethernet/qualcomm/emac/emac-mac.c +2 -3
@@ -920,14 +920,13 @@ static void emac_mac_rx_descs_refill(struct emac_adapter *adpt,static void emac_adjust_link (struct net_device *netdev) {struct emac_adapter *adpt =netdev_priv (netdev); -struct emac_sgmii *sgmii = &adpt->phy;struct phy_device *phydev = netdev->phydev;if (phydev->link) {emac_mac_start (adpt); - sgmii->link_up (adpt); +emac_sgmii_link_change (adpt, true); }else { - sgmii->link_down (adpt); +emac_sgmii_link_change (adpt, false);emac_mac_stop (adpt); }
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c +77 -51
221 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac-sgmii.h +20 -12
@@ -16,36 +16,44 @@struct emac_adapter ;struct platform_device ; -typedef int (*emac_sgmii_function )(struct emac_adapter *adpt); +/** emac_sgmii - internal emac phy +* @init initialization function +* @open called when the driver is opened +* @close called when the driver is closed +* @link_change called when the link state changes +*/ +struct sgmii_ops { +int (*init)(struct emac_adapter *adpt); +int (*open)(struct emac_adapter *adpt); +void (*close)(struct emac_adapter *adpt); +int (*link_change)(struct emac_adapter *adpt,bool link_state); +void (*reset)(struct emac_adapter *adpt); +};/** emac_sgmii - internal emac phy * @base base address * @digital per-lane digital block * @irq the interrupt number * @decode_error_count reference count of consecutive decode errors -* @initialize initialization function -* @open called when the driver is opened -* @close called when the driver is closed -* @link_up called when the link comes up -* @link_down called when the link comes down +* @sgmii_ops sgmii ops */ struct emac_sgmii {void __iomem *base;void __iomem *digital;unsigned int irq;atomic_t decode_error_count; -emac_sgmii_function initialize; -emac_sgmii_function open; -emac_sgmii_function close; -emac_sgmii_function link_up; -emac_sgmii_function link_down; +struct sgmii_ops *sgmii_ops; };int emac_sgmii_config (struct platform_device *pdev,struct emac_adapter *adpt); -void emac_sgmii_reset (struct emac_adapter *adpt);int emac_sgmii_init_fsm9900 (struct emac_adapter *adpt);int emac_sgmii_init_qdf2432 (struct emac_adapter *adpt);int emac_sgmii_init_qdf2400 (struct emac_adapter *adpt); +int emac_sgmii_init (struct emac_adapter *adpt); +int emac_sgmii_open (struct emac_adapter *adpt); +void emac_sgmii_close (struct emac_adapter *adpt); +int emac_sgmii_link_change (struct emac_adapter *adpt,bool link_state); +void emac_sgmii_reset (struct emac_adapter *adpt);#endif
drivers/net/ethernet/qualcomm/emac/emac.c +4 -5
@@ -253,7 +253,7 @@ static int emac_open(struct net_device *netdev)return ret; } - ret = adpt->phy.open (adpt); + ret =emac_sgmii_open (adpt);if (ret) {emac_mac_rx_tx_rings_free_all (adpt);free_irq (irq->irq, irq);
@@ -264,7 +264,7 @@ static int emac_open(struct net_device *netdev)if (ret) {emac_mac_rx_tx_rings_free_all (adpt);free_irq (irq->irq, irq); - adpt->phy.close (adpt); +emac_sgmii_close (adpt);return ret; }
@@ -278,7 +278,7 @@ static int emac_close(struct net_device *netdev)mutex_lock (&adpt->reset_lock); - adpt->phy.close (adpt); +emac_sgmii_close (adpt);emac_mac_down (adpt);emac_mac_rx_tx_rings_free_all (adpt);
@@ -761,11 +761,10 @@ static void emac_shutdown(struct platform_device *pdev) {struct net_device *netdev =dev_get_drvdata (&pdev->dev);struct emac_adapter *adpt =netdev_priv (netdev); -struct emac_sgmii *sgmii = &adpt->phy;if (netdev->flags &IFF_UP ) {/* Closing the SGMII turns off its interrupts */ - sgmii->close (adpt); +emac_sgmii_close (adpt);/* Resetting the MAC turns off all DMA and its interrupts */ emac_mac_reset (adpt);
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 4 lines · Hemanth Puranik
This patch introduces ops structure for sgmii, This by ensures that we do not need dummy functions in case of emulation platforms.
Signed-off-by Hemanth Puranik<[email protected]>
Acked-by Timur Tabi <[email protected]>
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Hemanth Puranik <[email protected]>
Date: Wed, 16 May 2018 06:40:53 +0530
Quoted 4 lines
This patch introduces ops structure for sgmii, This by ensures that we do not need dummy functions in case of emulation platforms.
Signed-off-by Hemanth Puranik <[email protected]>
Applied to net-next.