dm: Use access methods for dev/uclass private data
Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
This commit is contained in:
@@ -54,7 +54,7 @@ int eth_phy_set_mdio_bus(struct udevice *eth_dev, struct mii_dev *mdio_bus)
|
||||
for (uclass_first_device(UCLASS_ETH_PHY, &dev); dev;
|
||||
uclass_next_device(&dev)) {
|
||||
if (dev->parent == eth_dev) {
|
||||
uc_priv = (struct eth_phy_device_priv *)(dev->uclass_priv);
|
||||
uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(dev));
|
||||
|
||||
if (!uc_priv->mdio_bus)
|
||||
uc_priv->mdio_bus = mdio_bus;
|
||||
@@ -79,7 +79,7 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
|
||||
* phy_dev is shared and controlled by
|
||||
* other eth controller
|
||||
*/
|
||||
uc_priv = (struct eth_phy_device_priv *)(phy_dev->uclass_priv);
|
||||
uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev));
|
||||
if (uc_priv->mdio_bus)
|
||||
printf("Get shared mii bus on %s\n", eth_dev->name);
|
||||
else
|
||||
|
||||
@@ -547,7 +547,11 @@ static void fm_eth_halt(struct udevice *dev)
|
||||
struct fm_eth *fm_eth;
|
||||
struct fsl_enet_mac *mac;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
fm_eth = (struct fm_eth *)dev->priv;
|
||||
#else
|
||||
fm_eth = dev_get_priv(dev);
|
||||
#endif
|
||||
mac = fm_eth->mac;
|
||||
|
||||
/* graceful stop the transmission of frames */
|
||||
@@ -577,7 +581,11 @@ static int fm_eth_send(struct udevice *dev, void *buf, int len)
|
||||
u16 offset_in;
|
||||
int i;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
fm_eth = (struct fm_eth *)dev->priv;
|
||||
#else
|
||||
fm_eth = dev_get_priv(dev);
|
||||
#endif
|
||||
pram = fm_eth->tx_pram;
|
||||
txbd = fm_eth->cur_txbd;
|
||||
|
||||
@@ -664,13 +672,19 @@ static int fm_eth_recv(struct eth_device *dev)
|
||||
static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
#endif
|
||||
{
|
||||
struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
|
||||
struct fm_port_bd *rxbd = fm_eth->cur_rxbd;
|
||||
struct fm_eth *fm_eth;
|
||||
struct fm_port_bd *rxbd;
|
||||
u32 buf_lo, buf_hi;
|
||||
u16 status, len;
|
||||
int ret = -1;
|
||||
u8 *data;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
fm_eth = (struct fm_eth *)dev->priv;
|
||||
#else
|
||||
fm_eth = dev_get_priv(dev);
|
||||
#endif
|
||||
rxbd = fm_eth->cur_rxbd;
|
||||
status = muram_readw(&rxbd->status);
|
||||
|
||||
while (!(status & RxBD_EMPTY)) {
|
||||
@@ -704,7 +718,7 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
#ifdef CONFIG_DM_ETH
|
||||
static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length)
|
||||
{
|
||||
struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
|
||||
struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev);
|
||||
|
||||
fm_eth->cur_rxbd = fm_eth_free_one(fm_eth, fm_eth->cur_rxbd);
|
||||
|
||||
@@ -1004,7 +1018,7 @@ static struct udevice *fm_get_internal_mdio(struct udevice *dev)
|
||||
|
||||
static int fm_eth_probe(struct udevice *dev)
|
||||
{
|
||||
struct fm_eth *fm_eth = (struct fm_eth *)dev->priv;
|
||||
struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev);
|
||||
struct ofnode_phandle_args args;
|
||||
void *reg;
|
||||
int ret, index;
|
||||
|
||||
@@ -79,7 +79,7 @@ static void init_eth_info(struct fec_info_dma *info)
|
||||
|
||||
static void fec_halt(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_dma *info = dev->priv;
|
||||
struct fec_info_dma *info = dev_get_priv(dev);
|
||||
volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
|
||||
int counter = 0xffff;
|
||||
|
||||
@@ -230,7 +230,7 @@ static void fec_set_hwaddr(volatile fecdma_t *fecp, u8 *mac)
|
||||
|
||||
static int fec_init(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_dma *info = dev->priv;
|
||||
struct fec_info_dma *info = dev_get_priv(dev);
|
||||
volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
|
||||
int rval, i;
|
||||
uchar enetaddr[6];
|
||||
@@ -352,7 +352,7 @@ static int mcdmafec_init(struct udevice *dev)
|
||||
|
||||
static int mcdmafec_send(struct udevice *dev, void *packet, int length)
|
||||
{
|
||||
struct fec_info_dma *info = dev->priv;
|
||||
struct fec_info_dma *info = dev_get_priv(dev);
|
||||
cbd_t *p_tbd, *p_used_tbd;
|
||||
u16 phy_status;
|
||||
|
||||
@@ -412,7 +412,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length)
|
||||
|
||||
static int mcdmafec_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
{
|
||||
struct fec_info_dma *info = dev->priv;
|
||||
struct fec_info_dma *info = dev_get_priv(dev);
|
||||
volatile fecdma_t *fecp = (fecdma_t *)info->iobase;
|
||||
|
||||
cbd_t *prbd = &info->rxbd[info->rx_idx];
|
||||
@@ -496,7 +496,7 @@ static const struct eth_ops mcdmafec_ops = {
|
||||
*/
|
||||
static int mcdmafec_probe(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_dma *info = dev->priv;
|
||||
struct fec_info_dma *info = dev_get_priv(dev);
|
||||
struct eth_pdata *pdata = dev_get_plat(dev);
|
||||
int node = dev_of_offset(dev);
|
||||
int retval;
|
||||
|
||||
@@ -125,7 +125,7 @@ static void set_fec_duplex_speed(volatile fec_t *fecp, int dup_spd)
|
||||
#ifdef ET_DEBUG
|
||||
static void dbg_fec_regs(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
volatile fec_t *fecp = (fec_t *)(info->iobase);
|
||||
|
||||
printf("=====\n");
|
||||
@@ -275,7 +275,7 @@ static void dbg_fec_regs(struct udevice *dev)
|
||||
|
||||
int mcffec_init(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
volatile fec_t *fecp = (fec_t *) (info->iobase);
|
||||
int rval, i;
|
||||
uchar ea[6];
|
||||
@@ -374,7 +374,7 @@ int mcffec_init(struct udevice *dev)
|
||||
|
||||
static int mcffec_send(struct udevice *dev, void *packet, int length)
|
||||
{
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
volatile fec_t *fecp = (fec_t *)info->iobase;
|
||||
int j, rc;
|
||||
u16 phy_status;
|
||||
@@ -440,7 +440,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length)
|
||||
|
||||
static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
{
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
volatile fec_t *fecp = (fec_t *)info->iobase;
|
||||
int length = -1;
|
||||
|
||||
@@ -492,7 +492,7 @@ static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
|
||||
static void mcffec_halt(struct udevice *dev)
|
||||
{
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
|
||||
fec_reset(info);
|
||||
fecpin_setclear(info, 0);
|
||||
@@ -519,7 +519,7 @@ static const struct eth_ops mcffec_ops = {
|
||||
static int mcffec_probe(struct udevice *dev)
|
||||
{
|
||||
struct eth_pdata *pdata = dev_get_plat(dev);
|
||||
struct fec_info_s *info = dev->priv;
|
||||
struct fec_info_s *info = dev_get_priv(dev);
|
||||
int node = dev_of_offset(dev);
|
||||
int retval, fec_idx;
|
||||
const u32 *val;
|
||||
|
||||
@@ -100,7 +100,11 @@ uint mii_send(uint mii_cmd)
|
||||
|
||||
/* retrieve from register structure */
|
||||
dev = eth_get_dev();
|
||||
#ifdef CONFIG_DM_ETH
|
||||
info = dev_get_priv(dev);
|
||||
#else
|
||||
info = dev->priv;
|
||||
#endif
|
||||
|
||||
ep = (FEC_T *) info->miibase;
|
||||
|
||||
@@ -216,7 +220,11 @@ void __mii_init(void)
|
||||
|
||||
/* retrieve from register structure */
|
||||
dev = eth_get_dev();
|
||||
#ifdef CONFIG_DM_ETH
|
||||
info = dev_get_priv(dev);
|
||||
#else
|
||||
info = dev->priv;
|
||||
#endif
|
||||
|
||||
fecp = (FEC_T *) info->miibase;
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ static int pfe_eth_start(struct udevice *dev)
|
||||
|
||||
static int pfe_eth_send(struct udevice *dev, void *packet, int length)
|
||||
{
|
||||
struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev->priv;
|
||||
struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev_get_priv(dev);
|
||||
|
||||
int rc;
|
||||
int i = 0;
|
||||
|
||||
@@ -537,7 +537,7 @@ static int sunxi_emac_eth_start(struct udevice *dev)
|
||||
{
|
||||
struct eth_pdata *pdata = dev_get_plat(dev);
|
||||
|
||||
return _sunxi_emac_eth_init(dev->priv, pdata->enetaddr);
|
||||
return _sunxi_emac_eth_init(dev_get_priv(dev), pdata->enetaddr);
|
||||
}
|
||||
|
||||
static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)
|
||||
|
||||
@@ -131,11 +131,17 @@ static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac,
|
||||
static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
|
||||
#endif
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec __iomem *regs = priv->regs;
|
||||
struct tsec_private *priv;
|
||||
struct tsec __iomem *regs;
|
||||
u32 result, value;
|
||||
u8 whichbit, whichreg;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
priv = (struct tsec_private *)dev->priv;
|
||||
#else
|
||||
priv = dev_get_priv(dev);
|
||||
#endif
|
||||
regs = priv->regs;
|
||||
result = ether_crc(MAC_ADDR_LEN, mcast_mac);
|
||||
whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */
|
||||
whichreg = result >> 29; /* the 3 MSB = which reg to set it in */
|
||||
@@ -260,12 +266,18 @@ static int tsec_send(struct eth_device *dev, void *packet, int length)
|
||||
static int tsec_send(struct udevice *dev, void *packet, int length)
|
||||
#endif
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec __iomem *regs = priv->regs;
|
||||
struct tsec_private *priv;
|
||||
struct tsec __iomem *regs;
|
||||
int result = 0;
|
||||
u16 status;
|
||||
int i;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
priv = (struct tsec_private *)dev->priv;
|
||||
#else
|
||||
priv = dev_get_priv(dev);
|
||||
#endif
|
||||
regs = priv->regs;
|
||||
/* Find an empty buffer descriptor */
|
||||
for (i = 0;
|
||||
in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY;
|
||||
@@ -339,7 +351,7 @@ static int tsec_recv(struct eth_device *dev)
|
||||
#else
|
||||
static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
|
||||
struct tsec __iomem *regs = priv->regs;
|
||||
int ret = -1;
|
||||
|
||||
@@ -368,7 +380,7 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
|
||||
static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length)
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
|
||||
u16 status;
|
||||
|
||||
out_be16(&priv->rxbd[priv->rx_idx].length, 0);
|
||||
@@ -392,8 +404,14 @@ static void tsec_halt(struct eth_device *dev)
|
||||
static void tsec_halt(struct udevice *dev)
|
||||
#endif
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec __iomem *regs = priv->regs;
|
||||
struct tsec_private *priv;
|
||||
struct tsec __iomem *regs;
|
||||
#ifndef CONFIG_DM_ETH
|
||||
priv = (struct tsec_private *)dev->priv;
|
||||
#else
|
||||
priv = dev_get_priv(dev);
|
||||
#endif
|
||||
regs = priv->regs;
|
||||
|
||||
clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
|
||||
setbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
|
||||
@@ -560,16 +578,22 @@ static int tsec_init(struct eth_device *dev, struct bd_info *bd)
|
||||
static int tsec_init(struct udevice *dev)
|
||||
#endif
|
||||
{
|
||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||
struct tsec_private *priv;
|
||||
struct tsec __iomem *regs;
|
||||
#ifdef CONFIG_DM_ETH
|
||||
struct eth_pdata *pdata = dev_get_plat(dev);
|
||||
#else
|
||||
struct eth_device *pdata = dev;
|
||||
#endif
|
||||
struct tsec __iomem *regs = priv->regs;
|
||||
u32 tempval;
|
||||
int ret;
|
||||
|
||||
#ifndef CONFIG_DM_ETH
|
||||
priv = (struct tsec_private *)dev->priv;
|
||||
#else
|
||||
priv = dev_get_priv(dev);
|
||||
#endif
|
||||
regs = priv->regs;
|
||||
/* Make sure the controller is stopped */
|
||||
tsec_halt(dev);
|
||||
|
||||
@@ -865,7 +889,7 @@ int tsec_probe(struct udevice *dev)
|
||||
|
||||
int tsec_remove(struct udevice *dev)
|
||||
{
|
||||
struct tsec_private *priv = dev->priv;
|
||||
struct tsec_private *priv = dev_get_priv(dev);
|
||||
|
||||
free(priv->phydev);
|
||||
mdio_unregister(priv->bus);
|
||||
|
||||
@@ -457,7 +457,7 @@ static int emaclite_recv(struct udevice *dev, int flags, uchar **packetp)
|
||||
{
|
||||
u32 length, first_read, reg, attempt = 0;
|
||||
void *addr, *ack;
|
||||
struct xemaclite *emaclite = dev->priv;
|
||||
struct xemaclite *emaclite = dev_get_priv(dev);
|
||||
struct emaclite_regs *regs = emaclite->regs;
|
||||
struct ethernet_hdr *eth;
|
||||
struct ip_udp_hdr *ip;
|
||||
|
||||
Reference in New Issue
Block a user