[<prev] [next>] [day] [month] [year] [list]
Message-ID: <337cd4d2f179130826339cc40491345e1ee84957.camel@microchip.com>
Date: Mon, 29 Jun 2020 13:13:44 +0000
From: <Andre.Edich@...rochip.com>
To: <netdev@...r.kernel.org>, <UNGLinuxDriver@...rochip.com>,
<steve.glendinning@...well.net>
CC: <Parthiban.Veerasooran@...rochip.com>
Subject: [PATCH net-next 8/8] smsc95xx: use usbnet->driver_priv
Using `void *driver_priv` instead of `unsigned long data[]` is more
straightforward way to recover the `struct smsc95xx_priv *` from the
`struct net_device *`.
Signed-off-by: Andre Edich <andre.edich@...rochip.com>
---
drivers/net/usb/smsc95xx.c | 61 +++++++++++++++++---------------------
1 file changed, 28 insertions(+), 33 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 06fcc2518305..76d03652477d 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -463,7 +463,7 @@ static unsigned int smsc95xx_hash(char
addr[ETH_ALEN])
static void smsc95xx_set_multicast(struct net_device *netdev)
{
struct usbnet *dev = netdev_priv(netdev);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
unsigned long flags;
int ret;
@@ -558,7 +558,7 @@ static int smsc95xx_phy_update_flowcontrol(struct
usbnet *dev, u8 duplex,
static int smsc95xx_link_reset(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
struct ethtool_link_ksettings cmd;
unsigned long flags;
u16 lcladv, rmtadv;
@@ -716,7 +716,7 @@ static void smsc95xx_ethtool_get_wol(struct
net_device *net,
struct ethtool_wolinfo *wolinfo)
{
struct usbnet *dev = netdev_priv(net);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
wolinfo->supported = SUPPORTED_WAKE;
wolinfo->wolopts = pdata->wolopts;
@@ -726,7 +726,7 @@ static int smsc95xx_ethtool_set_wol(struct
net_device *net,
struct ethtool_wolinfo *wolinfo)
{
struct usbnet *dev = netdev_priv(net);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
int ret;
if (wolinfo->wolopts & ~SUPPORTED_WAKE)
@@ -744,7 +744,7 @@ static int smsc95xx_ethtool_set_wol(struct
net_device *net,
static int get_mdix_status(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val;
int buf;
@@ -766,7 +766,7 @@ static int get_mdix_status(struct net_device *net)
static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl)
{
struct usbnet *dev = netdev_priv(net);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
int buf;
if (pdata->mdix_ctrl == mdix_ctrl)
@@ -810,7 +810,7 @@ static int smsc95xx_get_link_ksettings(struct
net_device *net,
struct ethtool_link_ksettings
*cmd)
{
struct usbnet *dev = netdev_priv(net);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
int retval;
retval = phy_ethtool_get_link_ksettings(net, cmd);
@@ -903,7 +903,7 @@ static int smsc95xx_set_mac_address(struct usbnet
*dev)
/* starts the TX path */
static int smsc95xx_start_tx_path(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
unsigned long flags;
int ret;
@@ -923,7 +923,7 @@ static int smsc95xx_start_tx_path(struct usbnet
*dev)
/* Starts the Receive path */
static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
unsigned long flags;
spin_lock_irqsave(&pdata->mac_cr_lock, flags);
@@ -935,7 +935,7 @@ static int smsc95xx_start_rx_path(struct usbnet
*dev, int in_pm)
static int smsc95xx_reset(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 read_buf, write_buf, burst_cap;
int ret = 0, timeout;
@@ -1148,7 +1148,7 @@ static void smsc95xx_handle_link_change(struct
net_device *net)
static int smsc95xx_start_phy(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
struct net_device *net = dev->net;
int ret;
@@ -1194,7 +1194,7 @@ static const struct net_device_ops
smsc95xx_netdev_ops = {
static int smsc95xx_bind(struct usbnet *dev, struct usb_interface
*intf)
{
- struct smsc95xx_priv *pdata = NULL;
+ struct smsc95xx_priv *pdata;
u32 val;
int ret;
@@ -1206,13 +1206,12 @@ static int smsc95xx_bind(struct usbnet *dev,
struct usb_interface *intf)
return ret;
}
- dev->data[0] = (unsigned long)kzalloc(sizeof(struct
smsc95xx_priv),
- GFP_KERNEL);
-
- pdata = (struct smsc95xx_priv *)(dev->data[0]);
+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
+ dev->driver_priv = pdata;
+
spin_lock_init(&pdata->mac_cr_lock);
/* LAN95xx devices do not alter the computed checksum of 0 to
0xffff.
@@ -1311,16 +1310,12 @@ static int smsc95xx_bind(struct usbnet *dev,
struct usb_interface *intf)
static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface
*intf)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
- if (pdata) {
- mdiobus_unregister(pdata->mdiobus);
- mdiobus_free(pdata->mdiobus);
- netif_dbg(dev, ifdown, dev->net, "free pdata\n");
- kfree(pdata);
- pdata = NULL;
- dev->data[0] = 0;
- }
+ mdiobus_unregister(pdata->mdiobus);
+ mdiobus_free(pdata->mdiobus);
+ netif_dbg(dev, ifdown, dev->net, "free pdata\n");
+ kfree(pdata);
}
static u32 smsc_crc(const u8 *buffer, size_t len, int filter)
@@ -1370,7 +1365,7 @@ static int smsc95xx_link_ok_nopm(struct usbnet
*dev)
static int smsc95xx_enter_suspend0(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val;
int ret;
@@ -1409,7 +1404,7 @@ static int smsc95xx_enter_suspend0(struct usbnet
*dev)
static int smsc95xx_enter_suspend1(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val;
int ret;
@@ -1456,7 +1451,7 @@ static int smsc95xx_enter_suspend1(struct usbnet
*dev)
static int smsc95xx_enter_suspend2(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val;
int ret;
@@ -1478,7 +1473,7 @@ static int smsc95xx_enter_suspend2(struct usbnet
*dev)
static int smsc95xx_enter_suspend3(struct usbnet *dev)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val;
int ret;
@@ -1517,7 +1512,7 @@ static int smsc95xx_enter_suspend3(struct usbnet
*dev)
static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
int ret;
if (!netif_running(dev->net)) {
@@ -1565,7 +1560,7 @@ static int smsc95xx_autosuspend(struct usbnet
*dev, u32 link_up)
static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t
message)
{
struct usbnet *dev = usb_get_intfdata(intf);
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
u32 val, link_up;
int ret;
@@ -1830,7 +1825,7 @@ static int smsc95xx_resume(struct usb_interface
*intf)
u32 val;
BUG_ON(!dev);
- pdata = (struct smsc95xx_priv *)(dev->data[0]);
+ pdata = dev->driver_priv;
suspend_flags = pdata->suspend_flags;
netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n",
suspend_flags);
@@ -2050,7 +2045,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct
usbnet *dev,
static int smsc95xx_manage_power(struct usbnet *dev, int on)
{
- struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev-
>data[0]);
+ struct smsc95xx_priv *pdata = dev->driver_priv;
dev->intf->needs_remote_wakeup = on;
Powered by blists - more mailing lists