* [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv
[not found] <48C0A219.2030004@cn.fujitsu.com>
@ 2008-09-05 3:27 ` Wang Chen
2008-09-05 12:50 ` John W. Linville
2008-09-05 3:28 ` [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv Wang Chen
2008-09-05 3:29 ` [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2 siblings, 1 reply; 17+ messages in thread
From: Wang Chen @ 2008-09-05 3:27 UTC (permalink / raw)
To: David S. Miller; +Cc: Jeff Garzik, NETDEV, linville, linux-wireless
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
and I want to kill netdev->priv later, I decided to convert all the direct
reference of netdev->priv first.
Different to readonly reference of netdev->priv, in this driver, netdev->priv
was changed. I use netdev->ml_priv to replace netdev->priv.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
drivers/net/wireless/airo.c | 171 ++++++++++++++++++++++---------------------
1 files changed, 86 insertions(+), 85 deletions(-)
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index b5cd850..f65cd91 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1270,6 +1270,7 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev);
#define airo_print_err(name, fmt, args...) \
airo_print(KERN_ERR, name, fmt, ##args)
+#define AIRO_FLASH(dev) (((struct airo_info *)dev->ml_priv)->flash)
/***********************************************************************
* MIC ROUTINES *
@@ -1865,7 +1866,7 @@ static void try_auto_wep(struct airo_info *ai)
}
static int airo_open(struct net_device *dev) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int rc = 0;
if (test_bit(FLAG_FLASHING, &ai->flags))
@@ -1912,7 +1913,7 @@ static int airo_open(struct net_device *dev) {
static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) {
int npacks, pending;
unsigned long flags;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
if (!skb) {
airo_print_err(dev->name, "%s: skb == NULL!",__FUNCTION__);
@@ -1956,7 +1957,7 @@ static int mpi_send_packet (struct net_device *dev)
unsigned char *buffer;
s16 len;
__le16 *payloadLen;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
u8 *sendbuf;
/* get a packet to send */
@@ -2085,7 +2086,7 @@ static void get_tx_error(struct airo_info *ai, s32 fid)
static void airo_end_xmit(struct net_device *dev) {
u16 status;
int i;
- struct airo_info *priv = dev->priv;
+ struct airo_info *priv = dev->ml_priv;
struct sk_buff *skb = priv->xmit.skb;
int fid = priv->xmit.fid;
u32 *fids = priv->fids;
@@ -2111,7 +2112,7 @@ static void airo_end_xmit(struct net_device *dev) {
static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
s16 len;
int i, j;
- struct airo_info *priv = dev->priv;
+ struct airo_info *priv = dev->ml_priv;
u32 *fids = priv->fids;
if ( skb == NULL ) {
@@ -2150,7 +2151,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
static void airo_end_xmit11(struct net_device *dev) {
u16 status;
int i;
- struct airo_info *priv = dev->priv;
+ struct airo_info *priv = dev->ml_priv;
struct sk_buff *skb = priv->xmit11.skb;
int fid = priv->xmit11.fid;
u32 *fids = priv->fids;
@@ -2176,7 +2177,7 @@ static void airo_end_xmit11(struct net_device *dev) {
static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
s16 len;
int i, j;
- struct airo_info *priv = dev->priv;
+ struct airo_info *priv = dev->ml_priv;
u32 *fids = priv->fids;
if (test_bit(FLAG_MPI, &priv->flags)) {
@@ -2220,7 +2221,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
static void airo_read_stats(struct net_device *dev)
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
StatsRid stats_rid;
__le32 *vals = stats_rid.vals;
@@ -2254,7 +2255,7 @@ static void airo_read_stats(struct net_device *dev)
static struct net_device_stats *airo_get_stats(struct net_device *dev)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
if (!test_bit(JOB_STATS, &local->jobs)) {
/* Get stats out of the card if available */
@@ -2281,7 +2282,7 @@ static void airo_set_promisc(struct airo_info *ai) {
}
static void airo_set_multicast_list(struct net_device *dev) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
if ((dev->flags ^ ai->flags) & IFF_PROMISC) {
change_bit(FLAG_PROMISC, &ai->flags);
@@ -2299,7 +2300,7 @@ static void airo_set_multicast_list(struct net_device *dev) {
static int airo_set_mac_address(struct net_device *dev, void *p)
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
struct sockaddr *addr = p;
readConfigRid(ai, 1);
@@ -2339,7 +2340,7 @@ static void del_airo_dev(struct airo_info *ai)
}
static int airo_close(struct net_device *dev) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
netif_stop_queue(dev);
@@ -2365,7 +2366,7 @@ static int airo_close(struct net_device *dev) {
void stop_airo_card( struct net_device *dev, int freeres )
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
set_bit(FLAG_RADIO_DOWN, &ai->flags);
disable_MAC(ai, 1);
@@ -2665,7 +2666,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup);
if (!dev)
return NULL;
- dev->priv = ethdev->priv;
+ dev->ml_priv = ethdev->ml_priv;
dev->irq = ethdev->irq;
dev->base_addr = ethdev->base_addr;
dev->wireless_data = ethdev->wireless_data;
@@ -2680,7 +2681,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
}
static int reset_card( struct net_device *dev , int lock) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
if (lock && down_interruptible(&ai->sem))
return -1;
@@ -2766,7 +2767,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
return NULL;
}
- ai = dev->priv;
+ ai = dev->ml_priv = netdev_priv(dev);
ai->wifidev = NULL;
ai->flags = 1 << FLAG_RADIO_DOWN;
ai->jobs = 0;
@@ -2868,7 +2869,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
for( i = 0; i < MAX_FIDS; i++ )
ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
- if (setup_proc_entry(dev, dev->priv) < 0)
+ if (setup_proc_entry(dev, dev->ml_priv) < 0)
goto err_out_wifi;
return dev;
@@ -2917,7 +2918,7 @@ static int waitbusy (struct airo_info *ai) {
int reset_airo_card( struct net_device *dev )
{
int i;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
DECLARE_MAC_BUF(mac);
if (reset_card (dev, 1))
@@ -2942,7 +2943,7 @@ int reset_airo_card( struct net_device *dev )
EXPORT_SYMBOL(reset_airo_card);
static void airo_send_event(struct net_device *dev) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
union iwreq_data wrqu;
StatusRid status_rid;
@@ -3019,7 +3020,7 @@ out:
static int airo_thread(void *data) {
struct net_device *dev = data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int locked;
set_freezable();
@@ -3134,7 +3135,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
struct net_device *dev = dev_id;
u16 status;
u16 fid;
- struct airo_info *apriv = dev->priv;
+ struct airo_info *apriv = dev->ml_priv;
u16 savedInterrupts = 0;
int handled = 0;
@@ -4604,7 +4605,7 @@ static int proc_status_open(struct inode *inode, struct file *file)
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *apriv = dev->priv;
+ struct airo_info *apriv = dev->ml_priv;
CapabilityRid cap_rid;
StatusRid status_rid;
u16 mode;
@@ -4687,7 +4688,7 @@ static int proc_stats_rid_open( struct inode *inode,
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *apriv = dev->priv;
+ struct airo_info *apriv = dev->ml_priv;
StatsRid stats;
int i, j;
__le32 *vals = stats.vals;
@@ -4750,7 +4751,7 @@ static void proc_config_on_close(struct inode *inode, struct file *file)
struct proc_data *data = file->private_data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
char *line;
if ( !data->writelen ) return;
@@ -4962,7 +4963,7 @@ static int proc_config_open(struct inode *inode, struct file *file)
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int i;
__le16 mode;
@@ -5053,7 +5054,7 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file)
struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
SsidRid SSID_rid;
int i;
char *p = data->wbuffer;
@@ -5096,7 +5097,7 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
APListRid APList_rid;
int i;
@@ -5191,7 +5192,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int i;
char key[16];
u16 index = 0;
@@ -5233,7 +5234,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file )
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
char *ptr;
WepKeyRid wkr;
__le16 lastindex;
@@ -5282,7 +5283,7 @@ static int proc_SSID_open(struct inode *inode, struct file *file)
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int i;
char *ptr;
SsidRid SSID_rid;
@@ -5326,7 +5327,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int i;
char *ptr;
APListRid APList_rid;
@@ -5368,7 +5369,7 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
char *ptr;
BSSListRid BSSList_rid;
int rc;
@@ -5447,7 +5448,7 @@ static int proc_close( struct inode *inode, struct file *file )
associated we will check every minute to see if anything has
changed. */
static void timer_func( struct net_device *dev ) {
- struct airo_info *apriv = dev->priv;
+ struct airo_info *apriv = dev->ml_priv;
/* We don't have a link so try changing the authtype */
readConfigRid(apriv, 0);
@@ -5518,7 +5519,7 @@ static void __devexit airo_pci_remove(struct pci_dev *pdev)
static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
Cmd cmd;
Resp rsp;
@@ -5550,7 +5551,7 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
static int airo_pci_resume(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
pci_power_t prev_state = pdev->current_state;
pci_set_power_state(pdev, PCI_D0);
@@ -5729,7 +5730,7 @@ static int airo_set_freq(struct net_device *dev,
struct iw_freq *fwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int rc = -EINPROGRESS; /* Call commit handler */
/* If setting by frequency, convert to a channel */
@@ -5774,7 +5775,7 @@ static int airo_get_freq(struct net_device *dev,
struct iw_freq *fwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
StatusRid status_rid; /* Card status info */
int ch;
@@ -5805,7 +5806,7 @@ static int airo_set_essid(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
SsidRid SSID_rid; /* SSIDs */
/* Reload the list of current SSID */
@@ -5851,7 +5852,7 @@ static int airo_get_essid(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
StatusRid status_rid; /* Card status info */
readStatusRid(local, &status_rid, 1);
@@ -5879,7 +5880,7 @@ static int airo_set_wap(struct net_device *dev,
struct sockaddr *awrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
Cmd cmd;
Resp rsp;
APListRid APList_rid;
@@ -5916,7 +5917,7 @@ static int airo_get_wap(struct net_device *dev,
struct sockaddr *awrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
StatusRid status_rid; /* Card status info */
readStatusRid(local, &status_rid, 1);
@@ -5937,7 +5938,7 @@ static int airo_set_nick(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
/* Check the size of the string */
if(dwrq->length > 16) {
@@ -5960,7 +5961,7 @@ static int airo_get_nick(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
strncpy(extra, local->config.nodeName, 16);
@@ -5979,7 +5980,7 @@ static int airo_set_rate(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
CapabilityRid cap_rid; /* Card capability info */
u8 brate = 0;
int i;
@@ -6049,7 +6050,7 @@ static int airo_get_rate(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
StatusRid status_rid; /* Card status info */
readStatusRid(local, &status_rid, 1);
@@ -6071,7 +6072,7 @@ static int airo_set_rts(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int rthr = vwrq->value;
if(vwrq->disabled)
@@ -6095,7 +6096,7 @@ static int airo_get_rts(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
vwrq->value = le16_to_cpu(local->config.rtsThres);
@@ -6114,7 +6115,7 @@ static int airo_set_frag(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int fthr = vwrq->value;
if(vwrq->disabled)
@@ -6139,7 +6140,7 @@ static int airo_get_frag(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
vwrq->value = le16_to_cpu(local->config.fragThresh);
@@ -6158,7 +6159,7 @@ static int airo_set_mode(struct net_device *dev,
__u32 *uwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int reset = 0;
readConfigRid(local, 1);
@@ -6221,7 +6222,7 @@ static int airo_get_mode(struct net_device *dev,
__u32 *uwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
/* If not managed, assume it's ad-hoc */
@@ -6258,7 +6259,7 @@ static int airo_set_encode(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
CapabilityRid cap_rid; /* Card capability info */
int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 );
__le16 currentAuthType = local->config.authType;
@@ -6345,7 +6346,7 @@ static int airo_get_encode(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
CapabilityRid cap_rid; /* Card capability info */
@@ -6393,7 +6394,7 @@ static int airo_set_encodeext(struct net_device *dev,
union iwreq_data *wrqu,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
CapabilityRid cap_rid; /* Card capability info */
@@ -6479,7 +6480,7 @@ static int airo_get_encodeext(struct net_device *dev,
union iwreq_data *wrqu,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
CapabilityRid cap_rid; /* Card capability info */
@@ -6542,7 +6543,7 @@ static int airo_set_auth(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct iw_param *param = &wrqu->param;
__le16 currentAuthType = local->config.authType;
@@ -6610,7 +6611,7 @@ static int airo_get_auth(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct iw_param *param = &wrqu->param;
__le16 currentAuthType = local->config.authType;
@@ -6659,7 +6660,7 @@ static int airo_set_txpow(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
CapabilityRid cap_rid; /* Card capability info */
int i;
int rc = -EINVAL;
@@ -6696,7 +6697,7 @@ static int airo_get_txpow(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
vwrq->value = le16_to_cpu(local->config.txPower);
@@ -6716,7 +6717,7 @@ static int airo_set_retry(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
int rc = -EINVAL;
if(vwrq->disabled) {
@@ -6754,7 +6755,7 @@ static int airo_get_retry(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
vwrq->disabled = 0; /* Can't be disabled */
@@ -6785,7 +6786,7 @@ static int airo_get_range(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct iw_range *range = (struct iw_range *) extra;
CapabilityRid cap_rid; /* Card capability info */
int i;
@@ -6910,7 +6911,7 @@ static int airo_set_power(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
if (vwrq->disabled) {
@@ -6967,7 +6968,7 @@ static int airo_get_power(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
__le16 mode;
readConfigRid(local, 1);
@@ -6998,7 +6999,7 @@ static int airo_set_sens(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
local->config.rssiThreshold =
@@ -7017,7 +7018,7 @@ static int airo_get_sens(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
readConfigRid(local, 1);
vwrq->value = le16_to_cpu(local->config.rssiThreshold);
@@ -7037,7 +7038,7 @@ static int airo_get_aplist(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
struct sockaddr *address = (struct sockaddr *) extra;
struct iw_quality qual[IW_MAX_AP];
BSSListRid BSSList;
@@ -7110,7 +7111,7 @@ static int airo_set_scan(struct net_device *dev,
struct iw_param *vwrq,
char *extra)
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
Cmd cmd;
Resp rsp;
int wake = 0;
@@ -7156,7 +7157,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
char *end_buf,
BSSListRid *bss)
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
struct iw_event iwe; /* Temporary buffer */
__le16 capabilities;
char * current_val; /* For rates */
@@ -7338,7 +7339,7 @@ static int airo_get_scan(struct net_device *dev,
struct iw_point *dwrq,
char *extra)
{
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
BSSListElement *net;
int err = 0;
char *current_ev = extra;
@@ -7382,7 +7383,7 @@ static int airo_config_commit(struct net_device *dev,
void *zwrq, /* NULL */
char *extra) /* NULL */
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
if (!test_bit (FLAG_COMMIT, &local->flags))
return 0;
@@ -7527,7 +7528,7 @@ static const struct iw_handler_def airo_handler_def =
static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
int rc = 0;
- struct airo_info *ai = (struct airo_info *)dev->priv;
+ struct airo_info *ai = dev->ml_priv;
if (ai->power.event)
return 0;
@@ -7655,7 +7656,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
{
- struct airo_info *local = dev->priv;
+ struct airo_info *local = dev->ml_priv;
if (!test_bit(JOB_WSTATS, &local->jobs)) {
/* Get stats out of the card if available */
@@ -7680,7 +7681,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
unsigned short ridcode;
unsigned char *iobuf;
int len;
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
if (test_bit(FLAG_FLASHING, &ai->flags))
return -EIO;
@@ -7746,7 +7747,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) {
*/
static int writerids(struct net_device *dev, aironet_ioctl *comp) {
- struct airo_info *ai = dev->priv;
+ struct airo_info *ai = dev->ml_priv;
int ridcode;
int enabled;
static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
@@ -7869,41 +7870,41 @@ static int flashcard(struct net_device *dev, aironet_ioctl *comp) {
switch(comp->command)
{
case AIROFLSHRST:
- return cmdreset((struct airo_info *)dev->priv);
+ return cmdreset((struct airo_info *)dev->ml_priv);
case AIROFLSHSTFL:
- if (!((struct airo_info *)dev->priv)->flash &&
- (((struct airo_info *)dev->priv)->flash = kmalloc (FLASHSIZE, GFP_KERNEL)) == NULL)
+ if (!AIRO_FLASH(dev) &&
+ (AIRO_FLASH(dev) = kmalloc(FLASHSIZE, GFP_KERNEL)) == NULL)
return -ENOMEM;
- return setflashmode((struct airo_info *)dev->priv);
+ return setflashmode((struct airo_info *)dev->ml_priv);
case AIROFLSHGCHR: /* Get char from aux */
if(comp->len != sizeof(int))
return -EINVAL;
if (copy_from_user(&z,comp->data,comp->len))
return -EFAULT;
- return flashgchar((struct airo_info *)dev->priv,z,8000);
+ return flashgchar((struct airo_info *)dev->ml_priv, z, 8000);
case AIROFLSHPCHR: /* Send char to card. */
if(comp->len != sizeof(int))
return -EINVAL;
if (copy_from_user(&z,comp->data,comp->len))
return -EFAULT;
- return flashpchar((struct airo_info *)dev->priv,z,8000);
+ return flashpchar((struct airo_info *)dev->ml_priv, z, 8000);
case AIROFLPUTBUF: /* Send 32k to card */
- if (!((struct airo_info *)dev->priv)->flash)
+ if (!AIRO_FLASH(dev))
return -ENOMEM;
if(comp->len > FLASHSIZE)
return -EINVAL;
- if(copy_from_user(((struct airo_info *)dev->priv)->flash,comp->data,comp->len))
+ if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len))
return -EFAULT;
- flashputbuf((struct airo_info *)dev->priv);
+ flashputbuf((struct airo_info *)dev->ml_priv);
return 0;
case AIRORESTART:
- if(flashrestart((struct airo_info *)dev->priv,dev))
+ if (flashrestart((struct airo_info *)dev->ml_priv, dev))
return -EIO;
return 0;
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv
[not found] <48C0A219.2030004@cn.fujitsu.com>
2008-09-05 3:27 ` [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
@ 2008-09-05 3:28 ` Wang Chen
2008-09-05 17:07 ` Dan Williams
2008-09-05 3:29 ` [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2 siblings, 1 reply; 17+ messages in thread
From: Wang Chen @ 2008-09-05 3:28 UTC (permalink / raw)
To: David S. Miller; +Cc: Jeff Garzik, NETDEV, linville, linux-wireless
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
and I want to kill netdev->priv later, I decided to convert all the direct
reference of netdev->priv first.
Different to readonly reference of netdev->priv, in this driver, netdev->priv
was changed. I use netdev->ml_priv to replace netdev->priv.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
drivers/net/wireless/libertas/main.c | 36 +++++++++++++++++-----------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index bd32ac0..71c4bd8 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -223,7 +223,7 @@ u8 lbs_data_rate_to_fw_index(u32 rate)
static ssize_t lbs_anycast_get(struct device *dev,
struct device_attribute *attr, char * buf)
{
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
struct cmd_ds_mesh_access mesh_access;
int ret;
@@ -242,7 +242,7 @@ static ssize_t lbs_anycast_get(struct device *dev,
static ssize_t lbs_anycast_set(struct device *dev,
struct device_attribute *attr, const char * buf, size_t count)
{
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
struct cmd_ds_mesh_access mesh_access;
uint32_t datum;
int ret;
@@ -270,7 +270,7 @@ static void lbs_remove_mesh(struct lbs_private *priv);
static ssize_t lbs_rtap_get(struct device *dev,
struct device_attribute *attr, char * buf)
{
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
return snprintf(buf, 5, "0x%X\n", priv->monitormode);
}
@@ -281,7 +281,7 @@ static ssize_t lbs_rtap_set(struct device *dev,
struct device_attribute *attr, const char * buf, size_t count)
{
int monitor_mode;
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
sscanf(buf, "%x", &monitor_mode);
if (monitor_mode) {
@@ -330,7 +330,7 @@ static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
static ssize_t lbs_mesh_get(struct device *dev,
struct device_attribute *attr, char * buf)
{
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
}
@@ -340,7 +340,7 @@ static ssize_t lbs_mesh_get(struct device *dev,
static ssize_t lbs_mesh_set(struct device *dev,
struct device_attribute *attr, const char * buf, size_t count)
{
- struct lbs_private *priv = to_net_dev(dev)->priv;
+ struct lbs_private *priv = netdev_priv(to_net_dev(dev));
int enable;
int ret, action = CMD_ACT_MESH_CONFIG_STOP;
@@ -391,7 +391,7 @@ static struct attribute_group lbs_mesh_attr_group = {
*/
static int lbs_dev_open(struct net_device *dev)
{
- struct lbs_private *priv = (struct lbs_private *) dev->priv ;
+ struct lbs_private *priv = netdev_priv(dev) ;
int ret = 0;
lbs_deb_enter(LBS_DEB_NET);
@@ -433,7 +433,7 @@ static int lbs_dev_open(struct net_device *dev)
*/
static int lbs_mesh_stop(struct net_device *dev)
{
- struct lbs_private *priv = (struct lbs_private *) (dev->priv);
+ struct lbs_private *priv = dev->ml_priv;
lbs_deb_enter(LBS_DEB_MESH);
spin_lock_irq(&priv->driver_lock);
@@ -460,7 +460,7 @@ static int lbs_mesh_stop(struct net_device *dev)
*/
static int lbs_eth_stop(struct net_device *dev)
{
- struct lbs_private *priv = (struct lbs_private *) dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
lbs_deb_enter(LBS_DEB_NET);
@@ -477,7 +477,7 @@ static int lbs_eth_stop(struct net_device *dev)
static void lbs_tx_timeout(struct net_device *dev)
{
- struct lbs_private *priv = (struct lbs_private *) dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
lbs_deb_enter(LBS_DEB_TX);
@@ -529,7 +529,7 @@ EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
*/
static struct net_device_stats *lbs_get_stats(struct net_device *dev)
{
- struct lbs_private *priv = (struct lbs_private *) dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
lbs_deb_enter(LBS_DEB_NET);
return &priv->stats;
@@ -538,7 +538,7 @@ static struct net_device_stats *lbs_get_stats(struct net_device *dev)
static int lbs_set_mac_address(struct net_device *dev, void *addr)
{
int ret = 0;
- struct lbs_private *priv = (struct lbs_private *) dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
struct sockaddr *phwaddr = addr;
struct cmd_ds_802_11_mac_address cmd;
@@ -672,7 +672,7 @@ static void lbs_set_mcast_worker(struct work_struct *work)
static void lbs_set_multicast_list(struct net_device *dev)
{
- struct lbs_private *priv = dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
schedule_work(&priv->mcast_work);
}
@@ -688,7 +688,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
static int lbs_thread(void *data)
{
struct net_device *dev = data;
- struct lbs_private *priv = dev->priv;
+ struct lbs_private *priv = netdev_priv(dev);
wait_queue_t wait;
lbs_deb_enter(LBS_DEB_THREAD);
@@ -1116,7 +1116,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
lbs_pr_err("init ethX device failed\n");
goto done;
}
- priv = dev->priv;
+ priv = netdev_priv(dev);
if (lbs_init_adapter(priv)) {
lbs_pr_err("failed to initialize adapter structure.\n");
@@ -1351,7 +1351,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
ret = -ENOMEM;
goto done;
}
- mesh_dev->priv = priv;
+ mesh_dev->ml_priv = priv;
priv->mesh_dev = mesh_dev;
mesh_dev->open = lbs_dev_open;
@@ -1564,7 +1564,7 @@ static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev)
{
- struct lbs_private *priv = dev->priv;
+ struct lbs_private *priv = dev->ml_priv;
lbs_deb_enter(LBS_DEB_NET);
return &priv->stats;
}
@@ -1605,7 +1605,7 @@ static int lbs_add_rtap(struct lbs_private *priv)
rtap_dev->stop = lbs_rtap_stop;
rtap_dev->get_stats = lbs_rtap_get_stats;
rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit;
- rtap_dev->priv = priv;
+ rtap_dev->ml_priv = priv;
SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent);
ret = register_netdev(rtap_dev);
--
1.5.3.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv
[not found] <48C0A219.2030004@cn.fujitsu.com>
2008-09-05 3:27 ` [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2008-09-05 3:28 ` [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv Wang Chen
@ 2008-09-05 3:29 ` Wang Chen
2008-09-05 12:56 ` John W. Linville
2008-10-31 18:22 ` John W. Linville
2 siblings, 2 replies; 17+ messages in thread
From: Wang Chen @ 2008-09-05 3:29 UTC (permalink / raw)
To: David S. Miller; +Cc: Jeff Garzik, NETDEV, linville, linux-wireless
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
and I want to kill netdev->priv later, I decided to convert all the direct
reference of netdev->priv first.
Different to readonly reference of netdev->priv, in this driver, netdev->priv
was changed. I use netdev->ml_priv to replace netdev->priv.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
drivers/net/wireless/zd1201.c | 64 ++++++++++++++++++++--------------------
1 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index b16ec6e..abbf327 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -745,7 +745,7 @@ static int zd1201_join(struct zd1201 *zd, char *essid, int essidlen)
static int zd1201_net_open(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
/* Start MAC with wildcard if no essid set */
if (!zd->mac_enabled)
@@ -783,7 +783,7 @@ static int zd1201_net_stop(struct net_device *dev)
*/
static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
unsigned char *txbuf = zd->txdata;
int txbuflen, pad = 0, err;
struct urb *urb = zd->tx_urb;
@@ -833,7 +833,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
static void zd1201_tx_timeout(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
if (!zd)
return;
@@ -848,7 +848,7 @@ static void zd1201_tx_timeout(struct net_device *dev)
static int zd1201_set_mac_address(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
int err;
if (!zd)
@@ -865,21 +865,21 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)
static struct net_device_stats *zd1201_get_stats(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
return &zd->stats;
}
static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
return &zd->iwstats;
}
static void zd1201_set_multicast(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
struct dev_mc_list *mc = dev->mc_list;
unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
int i;
@@ -899,7 +899,7 @@ static void zd1201_set_multicast(struct net_device *dev)
static int zd1201_config_commit(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
return zd1201_mac_reset(zd);
}
@@ -914,7 +914,7 @@ static int zd1201_get_name(struct net_device *dev,
static int zd1201_set_freq(struct net_device *dev,
struct iw_request_info *info, struct iw_freq *freq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short channel = 0;
int err;
@@ -939,7 +939,7 @@ static int zd1201_set_freq(struct net_device *dev,
static int zd1201_get_freq(struct net_device *dev,
struct iw_request_info *info, struct iw_freq *freq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short channel;
int err;
@@ -955,7 +955,7 @@ static int zd1201_get_freq(struct net_device *dev,
static int zd1201_set_mode(struct net_device *dev,
struct iw_request_info *info, __u32 *mode, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short porttype, monitor = 0;
unsigned char buffer[IW_ESSID_MAX_SIZE+2];
int err;
@@ -1017,7 +1017,7 @@ static int zd1201_set_mode(struct net_device *dev,
static int zd1201_get_mode(struct net_device *dev,
struct iw_request_info *info, __u32 *mode, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short porttype;
int err;
@@ -1093,7 +1093,7 @@ static int zd1201_get_range(struct net_device *dev,
static int zd1201_get_wap(struct net_device *dev,
struct iw_request_info *info, struct sockaddr *ap_addr, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
unsigned char buffer[6];
if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
@@ -1121,7 +1121,7 @@ static int zd1201_set_scan(struct net_device *dev,
static int zd1201_get_scan(struct net_device *dev,
struct iw_request_info *info, struct iw_point *srq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
int err, i, j, enabled_save;
struct iw_event iwe;
char *cev = extra;
@@ -1213,7 +1213,7 @@ static int zd1201_get_scan(struct net_device *dev,
static int zd1201_set_essid(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
if (data->length > IW_ESSID_MAX_SIZE)
return -EINVAL;
@@ -1228,7 +1228,7 @@ static int zd1201_set_essid(struct net_device *dev,
static int zd1201_get_essid(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
memcpy(essid, zd->essid, zd->essidlen);
data->flags = 1;
@@ -1249,7 +1249,7 @@ static int zd1201_get_nick(struct net_device *dev, struct iw_request_info *info,
static int zd1201_set_rate(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short rate;
int err;
@@ -1282,7 +1282,7 @@ static int zd1201_set_rate(struct net_device *dev,
static int zd1201_get_rate(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short rate;
int err;
@@ -1315,7 +1315,7 @@ static int zd1201_get_rate(struct net_device *dev,
static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
int err;
short val = rts->value;
@@ -1335,7 +1335,7 @@ static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short rtst;
int err;
@@ -1352,7 +1352,7 @@ static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
int err;
short val = frag->value;
@@ -1373,7 +1373,7 @@ static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
static int zd1201_get_frag(struct net_device *dev, struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short fragt;
int err;
@@ -1402,7 +1402,7 @@ static int zd1201_get_retry(struct net_device *dev,
static int zd1201_set_encode(struct net_device *dev,
struct iw_request_info *info, struct iw_point *erq, char *key)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short i;
int err, rid;
@@ -1459,7 +1459,7 @@ static int zd1201_set_encode(struct net_device *dev,
static int zd1201_get_encode(struct net_device *dev,
struct iw_request_info *info, struct iw_point *erq, char *key)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short i;
int err;
@@ -1492,7 +1492,7 @@ static int zd1201_get_encode(struct net_device *dev,
static int zd1201_set_power(struct net_device *dev,
struct iw_request_info *info, struct iw_param *vwrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short enabled, duration, level;
int err;
@@ -1531,7 +1531,7 @@ out:
static int zd1201_get_power(struct net_device *dev,
struct iw_request_info *info, struct iw_param *vwrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short enabled, level, duration;
int err;
@@ -1618,7 +1618,7 @@ static const iw_handler zd1201_iw_handler[] =
static int zd1201_set_hostauth(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
if (!zd->ap)
return -EOPNOTSUPP;
@@ -1629,7 +1629,7 @@ static int zd1201_set_hostauth(struct net_device *dev,
static int zd1201_get_hostauth(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short hostauth;
int err;
@@ -1648,7 +1648,7 @@ static int zd1201_get_hostauth(struct net_device *dev,
static int zd1201_auth_sta(struct net_device *dev,
struct iw_request_info *info, struct sockaddr *sta, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
unsigned char buffer[10];
if (!zd->ap)
@@ -1664,7 +1664,7 @@ static int zd1201_auth_sta(struct net_device *dev,
static int zd1201_set_maxassoc(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
int err;
if (!zd->ap)
@@ -1679,7 +1679,7 @@ static int zd1201_set_maxassoc(struct net_device *dev,
static int zd1201_get_maxassoc(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = dev->ml_priv;
short maxassoc;
int err;
@@ -1779,7 +1779,7 @@ static int zd1201_probe(struct usb_interface *interface,
if (!zd->dev)
goto err_start;
- zd->dev->priv = zd;
+ zd->dev->ml_priv = zd;
zd->dev->open = zd1201_net_open;
zd->dev->stop = zd1201_net_stop;
zd->dev->get_stats = zd1201_get_stats;
--
1.5.3.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-05 3:27 ` [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
@ 2008-09-05 12:50 ` John W. Linville
2008-09-05 17:06 ` Dan Williams
0 siblings, 1 reply; 17+ messages in thread
From: John W. Linville @ 2008-09-05 12:50 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, Jeff Garzik, NETDEV, linux-wireless
On Fri, Sep 05, 2008 at 11:27:39AM +0800, Wang Chen wrote:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> Different to readonly reference of netdev->priv, in this driver, netdev->priv
> was changed. I use netdev->ml_priv to replace netdev->priv.
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Thank you for your patch. However, I do not understand why you didn't
simply replace netdev->priv with netdev_priv()? Can you explain?
Thanks,
John
--
John W. Linville
linville@tuxdriver.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-05 3:29 ` [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
@ 2008-09-05 12:56 ` John W. Linville
2008-10-31 18:22 ` John W. Linville
1 sibling, 0 replies; 17+ messages in thread
From: John W. Linville @ 2008-09-05 12:56 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, Jeff Garzik, NETDEV, linux-wireless
On Fri, Sep 05, 2008 at 11:29:36AM +0800, Wang Chen wrote:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> Different to readonly reference of netdev->priv, in this driver, netdev->priv
> was changed. I use netdev->ml_priv to replace netdev->priv.
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Same comment as the other patch.
Also, I have to be honest and say that I had never been aware of
dev->ml_priv before, so I'm not entirely sure what it is. However,
from the comment at it's definision ("mid-layer private") and it's
usage in qeth, loopback, and ppp, I'm not at all sure that you are
using it as intended.
Can you explain?
Thanks,
John
--
John W. Linville
linville@tuxdriver.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-05 12:50 ` John W. Linville
@ 2008-09-05 17:06 ` Dan Williams
2008-09-06 9:37 ` Wang Chen
0 siblings, 1 reply; 17+ messages in thread
From: Dan Williams @ 2008-09-05 17:06 UTC (permalink / raw)
To: John W. Linville
Cc: Wang Chen, David S. Miller, Jeff Garzik, NETDEV, linux-wireless
On Fri, 2008-09-05 at 08:50 -0400, John W. Linville wrote:
> On Fri, Sep 05, 2008 at 11:27:39AM +0800, Wang Chen wrote:
> > We have some reasons to kill netdev->priv:
> > 1. netdev->priv is equal to netdev_priv().
> > 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> > netdev_priv() is more flexible than netdev->priv.
> > But we cann't kill netdev->priv, because so many drivers reference to it
> > directly.
> >
> > OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> > and I want to kill netdev->priv later, I decided to convert all the direct
> > reference of netdev->priv first.
> >
> > Different to readonly reference of netdev->priv, in this driver, netdev->priv
> > was changed. I use netdev->ml_priv to replace netdev->priv.
> >
> > Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
>
> Thank you for your patch. However, I do not understand why you didn't
> simply replace netdev->priv with netdev_priv()? Can you explain?
Yeah, that would have been my first choice too...
Dan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv
2008-09-05 3:28 ` [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv Wang Chen
@ 2008-09-05 17:07 ` Dan Williams
2008-10-31 19:17 ` John W. Linville
0 siblings, 1 reply; 17+ messages in thread
From: Dan Williams @ 2008-09-05 17:07 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, Jeff Garzik, NETDEV, linville, linux-wireless
On Fri, 2008-09-05 at 11:28 +0800, Wang Chen wrote:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> Different to readonly reference of netdev->priv, in this driver, netdev->priv
> was changed. I use netdev->ml_priv to replace netdev->priv.
Same comment as the other two; any reason we can't use netdev_priv()
instead of ->ml_priv? That would be preferable.
Thanks!
Dan
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
> ---
> drivers/net/wireless/libertas/main.c | 36 +++++++++++++++++-----------------
> 1 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
> index bd32ac0..71c4bd8 100644
> --- a/drivers/net/wireless/libertas/main.c
> +++ b/drivers/net/wireless/libertas/main.c
> @@ -223,7 +223,7 @@ u8 lbs_data_rate_to_fw_index(u32 rate)
> static ssize_t lbs_anycast_get(struct device *dev,
> struct device_attribute *attr, char * buf)
> {
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
> struct cmd_ds_mesh_access mesh_access;
> int ret;
>
> @@ -242,7 +242,7 @@ static ssize_t lbs_anycast_get(struct device *dev,
> static ssize_t lbs_anycast_set(struct device *dev,
> struct device_attribute *attr, const char * buf, size_t count)
> {
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
> struct cmd_ds_mesh_access mesh_access;
> uint32_t datum;
> int ret;
> @@ -270,7 +270,7 @@ static void lbs_remove_mesh(struct lbs_private *priv);
> static ssize_t lbs_rtap_get(struct device *dev,
> struct device_attribute *attr, char * buf)
> {
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
> return snprintf(buf, 5, "0x%X\n", priv->monitormode);
> }
>
> @@ -281,7 +281,7 @@ static ssize_t lbs_rtap_set(struct device *dev,
> struct device_attribute *attr, const char * buf, size_t count)
> {
> int monitor_mode;
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
>
> sscanf(buf, "%x", &monitor_mode);
> if (monitor_mode) {
> @@ -330,7 +330,7 @@ static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
> static ssize_t lbs_mesh_get(struct device *dev,
> struct device_attribute *attr, char * buf)
> {
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
> return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
> }
>
> @@ -340,7 +340,7 @@ static ssize_t lbs_mesh_get(struct device *dev,
> static ssize_t lbs_mesh_set(struct device *dev,
> struct device_attribute *attr, const char * buf, size_t count)
> {
> - struct lbs_private *priv = to_net_dev(dev)->priv;
> + struct lbs_private *priv = netdev_priv(to_net_dev(dev));
> int enable;
> int ret, action = CMD_ACT_MESH_CONFIG_STOP;
>
> @@ -391,7 +391,7 @@ static struct attribute_group lbs_mesh_attr_group = {
> */
> static int lbs_dev_open(struct net_device *dev)
> {
> - struct lbs_private *priv = (struct lbs_private *) dev->priv ;
> + struct lbs_private *priv = netdev_priv(dev) ;
> int ret = 0;
>
> lbs_deb_enter(LBS_DEB_NET);
> @@ -433,7 +433,7 @@ static int lbs_dev_open(struct net_device *dev)
> */
> static int lbs_mesh_stop(struct net_device *dev)
> {
> - struct lbs_private *priv = (struct lbs_private *) (dev->priv);
> + struct lbs_private *priv = dev->ml_priv;
>
> lbs_deb_enter(LBS_DEB_MESH);
> spin_lock_irq(&priv->driver_lock);
> @@ -460,7 +460,7 @@ static int lbs_mesh_stop(struct net_device *dev)
> */
> static int lbs_eth_stop(struct net_device *dev)
> {
> - struct lbs_private *priv = (struct lbs_private *) dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
>
> lbs_deb_enter(LBS_DEB_NET);
>
> @@ -477,7 +477,7 @@ static int lbs_eth_stop(struct net_device *dev)
>
> static void lbs_tx_timeout(struct net_device *dev)
> {
> - struct lbs_private *priv = (struct lbs_private *) dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
>
> lbs_deb_enter(LBS_DEB_TX);
>
> @@ -529,7 +529,7 @@ EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
> */
> static struct net_device_stats *lbs_get_stats(struct net_device *dev)
> {
> - struct lbs_private *priv = (struct lbs_private *) dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
>
> lbs_deb_enter(LBS_DEB_NET);
> return &priv->stats;
> @@ -538,7 +538,7 @@ static struct net_device_stats *lbs_get_stats(struct net_device *dev)
> static int lbs_set_mac_address(struct net_device *dev, void *addr)
> {
> int ret = 0;
> - struct lbs_private *priv = (struct lbs_private *) dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
> struct sockaddr *phwaddr = addr;
> struct cmd_ds_802_11_mac_address cmd;
>
> @@ -672,7 +672,7 @@ static void lbs_set_mcast_worker(struct work_struct *work)
>
> static void lbs_set_multicast_list(struct net_device *dev)
> {
> - struct lbs_private *priv = dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
>
> schedule_work(&priv->mcast_work);
> }
> @@ -688,7 +688,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
> static int lbs_thread(void *data)
> {
> struct net_device *dev = data;
> - struct lbs_private *priv = dev->priv;
> + struct lbs_private *priv = netdev_priv(dev);
> wait_queue_t wait;
>
> lbs_deb_enter(LBS_DEB_THREAD);
> @@ -1116,7 +1116,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
> lbs_pr_err("init ethX device failed\n");
> goto done;
> }
> - priv = dev->priv;
> + priv = netdev_priv(dev);
>
> if (lbs_init_adapter(priv)) {
> lbs_pr_err("failed to initialize adapter structure.\n");
> @@ -1351,7 +1351,7 @@ static int lbs_add_mesh(struct lbs_private *priv)
> ret = -ENOMEM;
> goto done;
> }
> - mesh_dev->priv = priv;
> + mesh_dev->ml_priv = priv;
> priv->mesh_dev = mesh_dev;
>
> mesh_dev->open = lbs_dev_open;
> @@ -1564,7 +1564,7 @@ static int lbs_rtap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
>
> static struct net_device_stats *lbs_rtap_get_stats(struct net_device *dev)
> {
> - struct lbs_private *priv = dev->priv;
> + struct lbs_private *priv = dev->ml_priv;
> lbs_deb_enter(LBS_DEB_NET);
> return &priv->stats;
> }
> @@ -1605,7 +1605,7 @@ static int lbs_add_rtap(struct lbs_private *priv)
> rtap_dev->stop = lbs_rtap_stop;
> rtap_dev->get_stats = lbs_rtap_get_stats;
> rtap_dev->hard_start_xmit = lbs_rtap_hard_start_xmit;
> - rtap_dev->priv = priv;
> + rtap_dev->ml_priv = priv;
> SET_NETDEV_DEV(rtap_dev, priv->dev->dev.parent);
>
> ret = register_netdev(rtap_dev);
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-05 17:06 ` Dan Williams
@ 2008-09-06 9:37 ` Wang Chen
2008-09-26 8:37 ` Wang Chen
0 siblings, 1 reply; 17+ messages in thread
From: Wang Chen @ 2008-09-06 9:37 UTC (permalink / raw)
To: Dan Williams
Cc: John W. Linville, David S. Miller, Jeff Garzik, NETDEV,
linux-wireless
Dan Williams said the following on 2008-9-6 1:06:
> On Fri, 2008-09-05 at 08:50 -0400, John W. Linville wrote:
>> On Fri, Sep 05, 2008 at 11:27:39AM +0800, Wang Chen wrote:
>>> We have some reasons to kill netdev->priv:
>>> 1. netdev->priv is equal to netdev_priv().
>>> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
>>> netdev_priv() is more flexible than netdev->priv.
>>> But we cann't kill netdev->priv, because so many drivers reference to it
>>> directly.
>>>
>>> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
>>> and I want to kill netdev->priv later, I decided to convert all the direct
>>> reference of netdev->priv first.
>>>
>>> Different to readonly reference of netdev->priv, in this driver, netdev->priv
>>> was changed. I use netdev->ml_priv to replace netdev->priv.
>>>
>>> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
>> Thank you for your patch. However, I do not understand why you didn't
>> simply replace netdev->priv with netdev_priv()? Can you explain?
>
> Yeah, that would have been my first choice too...
>
1. Why I don't use netdev_priv() to replace netdev->priv here?
Because, here
> @@ -2665,7 +2666,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
> struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup);
> if (!dev)
> return NULL;
> - dev->priv = ethdev->priv;
> + dev->ml_priv = ethdev->ml_priv;
> @@ -2766,7 +2767,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
> return NULL;
> }
>
> - ai = dev->priv;
> + ai = dev->ml_priv = netdev_priv(dev);
netdev->priv was changed here, but it shouldn't, the memory was allocated when alloc_netdev and
netdev->priv should always pointed to that memory.
2. Why I use netdev->ml_priv here to replace netdev->priv?
In this driver, netdev->priv are shared by multi wifidevs, that means wifidevs need
mid-layer private data, which are all same as their parent netdev.
This usage is same as Dave's commit "syncppp: Fix crashes."
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-06 9:37 ` Wang Chen
@ 2008-09-26 8:37 ` Wang Chen
0 siblings, 0 replies; 17+ messages in thread
From: Wang Chen @ 2008-09-26 8:37 UTC (permalink / raw)
To: John W. Linville
Cc: Dan Williams, David S. Miller, Jeff Garzik, NETDEV,
linux-wireless
Wang Chen said the following on 2008-9-6 17:37:
>>>> We have some reasons to kill netdev->priv:
>>>> 1. netdev->priv is equal to netdev_priv().
>>>> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
>>>> netdev_priv() is more flexible than netdev->priv.
>>>> But we cann't kill netdev->priv, because so many drivers reference to it
>>>> directly.
>>>>
>>>> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
>>>> and I want to kill netdev->priv later, I decided to convert all the direct
>>>> reference of netdev->priv first.
>>>>
>>>> Different to readonly reference of netdev->priv, in this driver, netdev->priv
>>>> was changed. I use netdev->ml_priv to replace netdev->priv.
>>>>
>>>> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
>>> Thank you for your patch. However, I do not understand why you didn't
>>> simply replace netdev->priv with netdev_priv()? Can you explain?
>> Yeah, that would have been my first choice too...
>>
>
> 1. Why I don't use netdev_priv() to replace netdev->priv here?
> Because, here
>> @@ -2665,7 +2666,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
>> struct net_device *dev = alloc_netdev(0, "wifi%d", wifi_setup);
>> if (!dev)
>> return NULL;
>> - dev->priv = ethdev->priv;
>> + dev->ml_priv = ethdev->ml_priv;
>> @@ -2766,7 +2767,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
>> return NULL;
>> }
>>
>> - ai = dev->priv;
>> + ai = dev->ml_priv = netdev_priv(dev);
> netdev->priv was changed here, but it shouldn't, the memory was allocated when alloc_netdev and
> netdev->priv should always pointed to that memory.
>
> 2. Why I use netdev->ml_priv here to replace netdev->priv?
> In this driver, netdev->priv are shared by multi wifidevs, that means wifidevs need
> mid-layer private data, which are all same as their parent netdev.
> This usage is same as Dave's commit "syncppp: Fix crashes."
>
John, do you have any comments about my answer?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv
2008-09-05 3:29 ` [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2008-09-05 12:56 ` John W. Linville
@ 2008-10-31 18:22 ` John W. Linville
2008-10-31 18:48 ` [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv() John W. Linville
1 sibling, 1 reply; 17+ messages in thread
From: John W. Linville @ 2008-10-31 18:22 UTC (permalink / raw)
To: Wang Chen; +Cc: David S. Miller, Jeff Garzik, NETDEV, linux-wireless
On Fri, Sep 05, 2008 at 11:29:36AM +0800, Wang Chen wrote:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> Different to readonly reference of netdev->priv, in this driver, netdev->priv
> was changed. I use netdev->ml_priv to replace netdev->priv.
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
I don't think this is the right approach for this driver. Alternative
patch to follow...
John
--
John W. Linville Linux should be at the core
linville@tuxdriver.com of your literate lifestyle.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
2008-10-31 18:22 ` John W. Linville
@ 2008-10-31 18:48 ` John W. Linville
2008-10-31 19:00 ` Stephen Hemminger
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: John W. Linville @ 2008-10-31 18:48 UTC (permalink / raw)
To: linux-wireless
Cc: David S. Miller, Jeff Garzik, NETDEV, John W. Linville, Wang Chen
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
and I want to kill netdev->priv later, I decided to convert all the direct
reference of netdev->priv first.
(Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
changelog but using dev->ml_priv. That doesn't seem appropriate
to me for this driver, so I've revamped it to use netdev_priv()
instead. -- JWL)
Cc: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
drivers/net/wireless/zd1201.c | 115 ++++++++++++++++++++---------------------
1 files changed, 56 insertions(+), 59 deletions(-)
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index b16ec6e..1652d67 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -745,7 +745,7 @@ static int zd1201_join(struct zd1201 *zd, char *essid, int essidlen)
static int zd1201_net_open(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
/* Start MAC with wildcard if no essid set */
if (!zd->mac_enabled)
@@ -783,7 +783,7 @@ static int zd1201_net_stop(struct net_device *dev)
*/
static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
unsigned char *txbuf = zd->txdata;
int txbuflen, pad = 0, err;
struct urb *urb = zd->tx_urb;
@@ -833,7 +833,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
static void zd1201_tx_timeout(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
if (!zd)
return;
@@ -848,7 +848,7 @@ static void zd1201_tx_timeout(struct net_device *dev)
static int zd1201_set_mac_address(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
int err;
if (!zd)
@@ -865,21 +865,21 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)
static struct net_device_stats *zd1201_get_stats(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
return &zd->stats;
}
static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
return &zd->iwstats;
}
static void zd1201_set_multicast(struct net_device *dev)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
struct dev_mc_list *mc = dev->mc_list;
unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
int i;
@@ -899,7 +899,7 @@ static void zd1201_set_multicast(struct net_device *dev)
static int zd1201_config_commit(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
return zd1201_mac_reset(zd);
}
@@ -914,7 +914,7 @@ static int zd1201_get_name(struct net_device *dev,
static int zd1201_set_freq(struct net_device *dev,
struct iw_request_info *info, struct iw_freq *freq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short channel = 0;
int err;
@@ -939,7 +939,7 @@ static int zd1201_set_freq(struct net_device *dev,
static int zd1201_get_freq(struct net_device *dev,
struct iw_request_info *info, struct iw_freq *freq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short channel;
int err;
@@ -955,7 +955,7 @@ static int zd1201_get_freq(struct net_device *dev,
static int zd1201_set_mode(struct net_device *dev,
struct iw_request_info *info, __u32 *mode, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short porttype, monitor = 0;
unsigned char buffer[IW_ESSID_MAX_SIZE+2];
int err;
@@ -1017,7 +1017,7 @@ static int zd1201_set_mode(struct net_device *dev,
static int zd1201_get_mode(struct net_device *dev,
struct iw_request_info *info, __u32 *mode, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short porttype;
int err;
@@ -1093,7 +1093,7 @@ static int zd1201_get_range(struct net_device *dev,
static int zd1201_get_wap(struct net_device *dev,
struct iw_request_info *info, struct sockaddr *ap_addr, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
unsigned char buffer[6];
if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
@@ -1121,7 +1121,7 @@ static int zd1201_set_scan(struct net_device *dev,
static int zd1201_get_scan(struct net_device *dev,
struct iw_request_info *info, struct iw_point *srq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
int err, i, j, enabled_save;
struct iw_event iwe;
char *cev = extra;
@@ -1213,7 +1213,7 @@ static int zd1201_get_scan(struct net_device *dev,
static int zd1201_set_essid(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
if (data->length > IW_ESSID_MAX_SIZE)
return -EINVAL;
@@ -1228,7 +1228,7 @@ static int zd1201_set_essid(struct net_device *dev,
static int zd1201_get_essid(struct net_device *dev,
struct iw_request_info *info, struct iw_point *data, char *essid)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
memcpy(essid, zd->essid, zd->essidlen);
data->flags = 1;
@@ -1249,7 +1249,7 @@ static int zd1201_get_nick(struct net_device *dev, struct iw_request_info *info,
static int zd1201_set_rate(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short rate;
int err;
@@ -1282,7 +1282,7 @@ static int zd1201_set_rate(struct net_device *dev,
static int zd1201_get_rate(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short rate;
int err;
@@ -1315,7 +1315,7 @@ static int zd1201_get_rate(struct net_device *dev,
static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
int err;
short val = rts->value;
@@ -1335,7 +1335,7 @@ static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
struct iw_param *rts, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short rtst;
int err;
@@ -1352,7 +1352,7 @@ static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
int err;
short val = frag->value;
@@ -1373,7 +1373,7 @@ static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
static int zd1201_get_frag(struct net_device *dev, struct iw_request_info *info,
struct iw_param *frag, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short fragt;
int err;
@@ -1402,7 +1402,7 @@ static int zd1201_get_retry(struct net_device *dev,
static int zd1201_set_encode(struct net_device *dev,
struct iw_request_info *info, struct iw_point *erq, char *key)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short i;
int err, rid;
@@ -1459,7 +1459,7 @@ static int zd1201_set_encode(struct net_device *dev,
static int zd1201_get_encode(struct net_device *dev,
struct iw_request_info *info, struct iw_point *erq, char *key)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short i;
int err;
@@ -1492,7 +1492,7 @@ static int zd1201_get_encode(struct net_device *dev,
static int zd1201_set_power(struct net_device *dev,
struct iw_request_info *info, struct iw_param *vwrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short enabled, duration, level;
int err;
@@ -1531,7 +1531,7 @@ out:
static int zd1201_get_power(struct net_device *dev,
struct iw_request_info *info, struct iw_param *vwrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short enabled, level, duration;
int err;
@@ -1618,7 +1618,7 @@ static const iw_handler zd1201_iw_handler[] =
static int zd1201_set_hostauth(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
if (!zd->ap)
return -EOPNOTSUPP;
@@ -1629,7 +1629,7 @@ static int zd1201_set_hostauth(struct net_device *dev,
static int zd1201_get_hostauth(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short hostauth;
int err;
@@ -1648,7 +1648,7 @@ static int zd1201_get_hostauth(struct net_device *dev,
static int zd1201_auth_sta(struct net_device *dev,
struct iw_request_info *info, struct sockaddr *sta, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
unsigned char buffer[10];
if (!zd->ap)
@@ -1664,7 +1664,7 @@ static int zd1201_auth_sta(struct net_device *dev,
static int zd1201_set_maxassoc(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
int err;
if (!zd->ap)
@@ -1679,7 +1679,7 @@ static int zd1201_set_maxassoc(struct net_device *dev,
static int zd1201_get_maxassoc(struct net_device *dev,
struct iw_request_info *info, struct iw_param *rrq, char *extra)
{
- struct zd1201 *zd = (struct zd1201 *)dev->priv;
+ struct zd1201 *zd = netdev_priv(dev);
short maxassoc;
int err;
@@ -1731,6 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
struct zd1201 *zd;
+ struct net_device *dev;
struct usb_device *usb;
int err;
short porttype;
@@ -1738,9 +1739,12 @@ static int zd1201_probe(struct usb_interface *interface,
usb = interface_to_usbdev(interface);
- zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
- if (!zd)
+ dev = alloc_etherdev(sizeof(*zd));
+ if (!dev)
return -ENOMEM;
+ zd = netdev_priv(dev);
+ zd->dev = dev;
+
zd->ap = ap;
zd->usb = usb;
zd->removed = 0;
@@ -1775,34 +1779,29 @@ static int zd1201_probe(struct usb_interface *interface,
if (err)
goto err_start;
- zd->dev = alloc_etherdev(0);
- if (!zd->dev)
- goto err_start;
-
- zd->dev->priv = zd;
- zd->dev->open = zd1201_net_open;
- zd->dev->stop = zd1201_net_stop;
- zd->dev->get_stats = zd1201_get_stats;
- zd->dev->wireless_handlers =
+ dev->open = zd1201_net_open;
+ dev->stop = zd1201_net_stop;
+ dev->get_stats = zd1201_get_stats;
+ dev->wireless_handlers =
(struct iw_handler_def *)&zd1201_iw_handlers;
- zd->dev->hard_start_xmit = zd1201_hard_start_xmit;
- zd->dev->watchdog_timeo = ZD1201_TX_TIMEOUT;
- zd->dev->tx_timeout = zd1201_tx_timeout;
- zd->dev->set_multicast_list = zd1201_set_multicast;
- zd->dev->set_mac_address = zd1201_set_mac_address;
- strcpy(zd->dev->name, "wlan%d");
+ dev->hard_start_xmit = zd1201_hard_start_xmit;
+ dev->watchdog_timeo = ZD1201_TX_TIMEOUT;
+ dev->tx_timeout = zd1201_tx_timeout;
+ dev->set_multicast_list = zd1201_set_multicast;
+ dev->set_mac_address = zd1201_set_mac_address;
+ strcpy(dev->name, "wlan%d");
err = zd1201_getconfig(zd, ZD1201_RID_CNFOWNMACADDR,
- zd->dev->dev_addr, zd->dev->addr_len);
+ dev->dev_addr, dev->addr_len);
if (err)
- goto err_net;
+ goto err_start;
/* Set wildcard essid to match zd->essid */
*(__le16 *)buf = cpu_to_le16(0);
err = zd1201_setconfig(zd, ZD1201_RID_CNFDESIREDSSID, buf,
IW_ESSID_MAX_SIZE+2, 1);
if (err)
- goto err_net;
+ goto err_start;
if (zd->ap)
porttype = ZD1201_PORTTYPE_AP;
@@ -1810,30 +1809,28 @@ static int zd1201_probe(struct usb_interface *interface,
porttype = ZD1201_PORTTYPE_BSS;
err = zd1201_setconfig16(zd, ZD1201_RID_CNFPORTTYPE, porttype);
if (err)
- goto err_net;
+ goto err_start;
- SET_NETDEV_DEV(zd->dev, &usb->dev);
+ SET_NETDEV_DEV(dev, &usb->dev);
- err = register_netdev(zd->dev);
+ err = register_netdev(dev);
if (err)
- goto err_net;
+ goto err_start;
dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n",
- zd->dev->name);
+ dev->name);
usb_set_intfdata(interface, zd);
zd1201_enable(zd); /* zd1201 likes to startup enabled, */
zd1201_disable(zd); /* interfering with all the wifis in range */
return 0;
-err_net:
- free_netdev(zd->dev);
err_start:
/* Leave the device in reset state */
zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0);
err_zd:
usb_free_urb(zd->tx_urb);
usb_free_urb(zd->rx_urb);
- kfree(zd);
+ free_netdev(dev);
return err;
}
--
1.5.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
2008-10-31 18:48 ` [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv() John W. Linville
@ 2008-10-31 19:00 ` Stephen Hemminger
2008-11-03 2:06 ` Wang Chen
2008-12-18 6:53 ` [PATCH -next] netdevice zd1201: Use after free Wang Chen
2 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2008-10-31 19:00 UTC (permalink / raw)
To: John W. Linville
Cc: linux-wireless, David S. Miller, Jeff Garzik, NETDEV,
John W. Linville, Wang Chen
On Fri, 31 Oct 2008 14:48:16 -0400
"John W. Linville" <linville@tuxdriver.com> wrote:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> (Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
> changelog but using dev->ml_priv. That doesn't seem appropriate
> to me for this driver, so I've revamped it to use netdev_priv()
> instead. -- JWL)
>
> Cc: Wang Chen <wangchen@cn.fujitsu.com>
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> ---
> drivers/net/wireless/zd1201.c | 115 ++++++++++++++++++++---------------------
> 1 files changed, 56 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
> index b16ec6e..1652d67 100644
> --- a/drivers/net/wireless/zd1201.c
> +++ b/drivers/net/wireless/zd1201.c
> @@ -745,7 +745,7 @@ static int zd1201_join(struct zd1201 *zd, char *essid, int essidlen)
>
> static int zd1201_net_open(struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> /* Start MAC with wildcard if no essid set */
> if (!zd->mac_enabled)
> @@ -783,7 +783,7 @@ static int zd1201_net_stop(struct net_device *dev)
> */
> static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> unsigned char *txbuf = zd->txdata;
> int txbuflen, pad = 0, err;
> struct urb *urb = zd->tx_urb;
> @@ -833,7 +833,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
>
> static void zd1201_tx_timeout(struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> if (!zd)
> return;
> @@ -848,7 +848,7 @@ static void zd1201_tx_timeout(struct net_device *dev)
> static int zd1201_set_mac_address(struct net_device *dev, void *p)
> {
> struct sockaddr *addr = p;
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> int err;
>
> if (!zd)
> @@ -865,21 +865,21 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)
>
> static struct net_device_stats *zd1201_get_stats(struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> return &zd->stats;
> }
>
> static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> return &zd->iwstats;
> }
>
> static void zd1201_set_multicast(struct net_device *dev)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> struct dev_mc_list *mc = dev->mc_list;
> unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
> int i;
> @@ -899,7 +899,7 @@ static void zd1201_set_multicast(struct net_device *dev)
> static int zd1201_config_commit(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *data, char *essid)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> return zd1201_mac_reset(zd);
> }
> @@ -914,7 +914,7 @@ static int zd1201_get_name(struct net_device *dev,
> static int zd1201_set_freq(struct net_device *dev,
> struct iw_request_info *info, struct iw_freq *freq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short channel = 0;
> int err;
>
> @@ -939,7 +939,7 @@ static int zd1201_set_freq(struct net_device *dev,
> static int zd1201_get_freq(struct net_device *dev,
> struct iw_request_info *info, struct iw_freq *freq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short channel;
> int err;
>
> @@ -955,7 +955,7 @@ static int zd1201_get_freq(struct net_device *dev,
> static int zd1201_set_mode(struct net_device *dev,
> struct iw_request_info *info, __u32 *mode, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short porttype, monitor = 0;
> unsigned char buffer[IW_ESSID_MAX_SIZE+2];
> int err;
> @@ -1017,7 +1017,7 @@ static int zd1201_set_mode(struct net_device *dev,
> static int zd1201_get_mode(struct net_device *dev,
> struct iw_request_info *info, __u32 *mode, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short porttype;
> int err;
>
> @@ -1093,7 +1093,7 @@ static int zd1201_get_range(struct net_device *dev,
> static int zd1201_get_wap(struct net_device *dev,
> struct iw_request_info *info, struct sockaddr *ap_addr, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> unsigned char buffer[6];
>
> if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
> @@ -1121,7 +1121,7 @@ static int zd1201_set_scan(struct net_device *dev,
> static int zd1201_get_scan(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *srq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> int err, i, j, enabled_save;
> struct iw_event iwe;
> char *cev = extra;
> @@ -1213,7 +1213,7 @@ static int zd1201_get_scan(struct net_device *dev,
> static int zd1201_set_essid(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *data, char *essid)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> if (data->length > IW_ESSID_MAX_SIZE)
> return -EINVAL;
> @@ -1228,7 +1228,7 @@ static int zd1201_set_essid(struct net_device *dev,
> static int zd1201_get_essid(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *data, char *essid)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> memcpy(essid, zd->essid, zd->essidlen);
> data->flags = 1;
> @@ -1249,7 +1249,7 @@ static int zd1201_get_nick(struct net_device *dev, struct iw_request_info *info,
> static int zd1201_set_rate(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short rate;
> int err;
>
> @@ -1282,7 +1282,7 @@ static int zd1201_set_rate(struct net_device *dev,
> static int zd1201_get_rate(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short rate;
> int err;
>
> @@ -1315,7 +1315,7 @@ static int zd1201_get_rate(struct net_device *dev,
> static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
> struct iw_param *rts, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> int err;
> short val = rts->value;
>
> @@ -1335,7 +1335,7 @@ static int zd1201_set_rts(struct net_device *dev, struct iw_request_info *info,
> static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
> struct iw_param *rts, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short rtst;
> int err;
>
> @@ -1352,7 +1352,7 @@ static int zd1201_get_rts(struct net_device *dev, struct iw_request_info *info,
> static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
> struct iw_param *frag, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> int err;
> short val = frag->value;
>
> @@ -1373,7 +1373,7 @@ static int zd1201_set_frag(struct net_device *dev, struct iw_request_info *info,
> static int zd1201_get_frag(struct net_device *dev, struct iw_request_info *info,
> struct iw_param *frag, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short fragt;
> int err;
>
> @@ -1402,7 +1402,7 @@ static int zd1201_get_retry(struct net_device *dev,
> static int zd1201_set_encode(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *erq, char *key)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short i;
> int err, rid;
>
> @@ -1459,7 +1459,7 @@ static int zd1201_set_encode(struct net_device *dev,
> static int zd1201_get_encode(struct net_device *dev,
> struct iw_request_info *info, struct iw_point *erq, char *key)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short i;
> int err;
>
> @@ -1492,7 +1492,7 @@ static int zd1201_get_encode(struct net_device *dev,
> static int zd1201_set_power(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *vwrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short enabled, duration, level;
> int err;
>
> @@ -1531,7 +1531,7 @@ out:
> static int zd1201_get_power(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *vwrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short enabled, level, duration;
> int err;
>
> @@ -1618,7 +1618,7 @@ static const iw_handler zd1201_iw_handler[] =
> static int zd1201_set_hostauth(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
>
> if (!zd->ap)
> return -EOPNOTSUPP;
> @@ -1629,7 +1629,7 @@ static int zd1201_set_hostauth(struct net_device *dev,
> static int zd1201_get_hostauth(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short hostauth;
> int err;
>
> @@ -1648,7 +1648,7 @@ static int zd1201_get_hostauth(struct net_device *dev,
> static int zd1201_auth_sta(struct net_device *dev,
> struct iw_request_info *info, struct sockaddr *sta, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> unsigned char buffer[10];
>
> if (!zd->ap)
> @@ -1664,7 +1664,7 @@ static int zd1201_auth_sta(struct net_device *dev,
> static int zd1201_set_maxassoc(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> int err;
>
> if (!zd->ap)
> @@ -1679,7 +1679,7 @@ static int zd1201_set_maxassoc(struct net_device *dev,
> static int zd1201_get_maxassoc(struct net_device *dev,
> struct iw_request_info *info, struct iw_param *rrq, char *extra)
> {
> - struct zd1201 *zd = (struct zd1201 *)dev->priv;
> + struct zd1201 *zd = netdev_priv(dev);
> short maxassoc;
> int err;
>
> @@ -1731,6 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
> const struct usb_device_id *id)
> {
> struct zd1201 *zd;
> + struct net_device *dev;
> struct usb_device *usb;
> int err;
> short porttype;
> @@ -1738,9 +1739,12 @@ static int zd1201_probe(struct usb_interface *interface,
>
> usb = interface_to_usbdev(interface);
>
> - zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
> - if (!zd)
> + dev = alloc_etherdev(sizeof(*zd));
> + if (!dev)
> return -ENOMEM;
> + zd = netdev_priv(dev);
> + zd->dev = dev;
This also fixes a bug where the driver would crash if sysfs files were open
when module was removed. See Documentation/networking/driver.txt
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv
2008-09-05 17:07 ` Dan Williams
@ 2008-10-31 19:17 ` John W. Linville
0 siblings, 0 replies; 17+ messages in thread
From: John W. Linville @ 2008-10-31 19:17 UTC (permalink / raw)
To: Dan Williams
Cc: Wang Chen, David S. Miller, Jeff Garzik, NETDEV, linux-wireless
On Fri, Sep 05, 2008 at 01:07:45PM -0400, Dan Williams wrote:
> On Fri, 2008-09-05 at 11:28 +0800, Wang Chen wrote:
> > We have some reasons to kill netdev->priv:
> > 1. netdev->priv is equal to netdev_priv().
> > 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> > netdev_priv() is more flexible than netdev->priv.
> > But we cann't kill netdev->priv, because so many drivers reference to it
> > directly.
> >
> > OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> > and I want to kill netdev->priv later, I decided to convert all the direct
> > reference of netdev->priv first.
> >
> > Different to readonly reference of netdev->priv, in this driver, netdev->priv
> > was changed. I use netdev->ml_priv to replace netdev->priv.
>
> Same comment as the other two; any reason we can't use netdev_priv()
> instead of ->ml_priv? That would be preferable.
Actually, I think this one was OK -- the two ml_priv uses were for
the extra mesh and rtap devices, which point back to the already
allocated priv data for the main device.
John
--
John W. Linville Linux should be at the core
linville@tuxdriver.com of your literate lifestyle.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
2008-10-31 18:48 ` [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv() John W. Linville
2008-10-31 19:00 ` Stephen Hemminger
@ 2008-11-03 2:06 ` Wang Chen
2008-12-18 6:53 ` [PATCH -next] netdevice zd1201: Use after free Wang Chen
2 siblings, 0 replies; 17+ messages in thread
From: Wang Chen @ 2008-11-03 2:06 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, David S. Miller, Jeff Garzik, NETDEV
John W. Linville said the following on 2008-11-1 2:48:
> We have some reasons to kill netdev->priv:
> 1. netdev->priv is equal to netdev_priv().
> 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> netdev_priv() is more flexible than netdev->priv.
> But we cann't kill netdev->priv, because so many drivers reference to it
> directly.
>
> OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> and I want to kill netdev->priv later, I decided to convert all the direct
> reference of netdev->priv first.
>
> (Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
> changelog but using dev->ml_priv. That doesn't seem appropriate
> to me for this driver, so I've revamped it to use netdev_priv()
> instead. -- JWL)
>
> Cc: Wang Chen <wangchen@cn.fujitsu.com>
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> ---
> drivers/net/wireless/zd1201.c | 115 ++++++++++++++++++++---------------------
> 1 files changed, 56 insertions(+), 59 deletions(-)
>
snip...
> @@ -1731,6 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
> const struct usb_device_id *id)
> {
> struct zd1201 *zd;
> + struct net_device *dev;
> struct usb_device *usb;
> int err;
> short porttype;
> @@ -1738,9 +1739,12 @@ static int zd1201_probe(struct usb_interface *interface,
>
> usb = interface_to_usbdev(interface);
>
> - zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
> - if (!zd)
> + dev = alloc_etherdev(sizeof(*zd));
> + if (!dev)
> return -ENOMEM;
> + zd = netdev_priv(dev);
> + zd->dev = dev;
> +
It's ok to me.
Reviewed-by: Wang Chen <wangchen@cn.fujitsu.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH -next] netdevice zd1201: Use after free
2008-10-31 18:48 ` [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv() John W. Linville
2008-10-31 19:00 ` Stephen Hemminger
2008-11-03 2:06 ` Wang Chen
@ 2008-12-18 6:53 ` Wang Chen
2008-12-18 13:58 ` John W. Linville
2008-12-19 3:37 ` David Miller
2 siblings, 2 replies; 17+ messages in thread
From: Wang Chen @ 2008-12-18 6:53 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless, David S. Miller, Jeff Garzik, NETDEV
| commit 3d29b0c33d431ecc69ec778f8c236d382f59a85f
| Author: John W. Linville <linville@tuxdriver.com>
| Date: Fri Oct 31 14:13:12 2008 -0400
|
| netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
|
| We have some reasons to kill netdev->priv:
| 1. netdev->priv is equal to netdev_priv().
| 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
| netdev_priv() is more flexible than netdev->priv.
| But we cann't kill netdev->priv, because so many drivers reference to it
| directly.
|
| OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
| and I want to kill netdev->priv later, I decided to convert all the direct
| reference of netdev->priv first.
|
| (Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
| changelog but using dev->ml_priv. That doesn't seem appropriate
| to me for this driver, so I've revamped it to use netdev_priv()
| instead. -- JWL)
This commit changed the allocation of netdev, but didn't change
the free method of it.
This causes "zd" be used after the memory, which is pointed by "zd", being
freed by free_netdev().
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Cc: John W. Linville <linville@tuxdriver.com>
---
drivers/net/wireless/zd1201.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 3404807..b45c27d 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -1841,10 +1841,6 @@ static void zd1201_disconnect(struct usb_interface *interface)
if (!zd)
return;
usb_set_intfdata(interface, NULL);
- if (zd->dev) {
- unregister_netdev(zd->dev);
- free_netdev(zd->dev);
- }
hlist_for_each_entry_safe(frag, node, node2, &zd->fraglist, fnode) {
hlist_del_init(&frag->fnode);
@@ -1860,7 +1856,11 @@ static void zd1201_disconnect(struct usb_interface *interface)
usb_kill_urb(zd->rx_urb);
usb_free_urb(zd->rx_urb);
}
- kfree(zd);
+
+ if (zd->dev) {
+ unregister_netdev(zd->dev);
+ free_netdev(zd->dev);
+ }
}
#ifdef CONFIG_PM
--
1.5.3.4
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH -next] netdevice zd1201: Use after free
2008-12-18 6:53 ` [PATCH -next] netdevice zd1201: Use after free Wang Chen
@ 2008-12-18 13:58 ` John W. Linville
2008-12-19 3:37 ` David Miller
1 sibling, 0 replies; 17+ messages in thread
From: John W. Linville @ 2008-12-18 13:58 UTC (permalink / raw)
To: Wang Chen; +Cc: linux-wireless, David S. Miller, Jeff Garzik, NETDEV
On Thu, Dec 18, 2008 at 02:53:31PM +0800, Wang Chen wrote:
> | commit 3d29b0c33d431ecc69ec778f8c236d382f59a85f
> | Author: John W. Linville <linville@tuxdriver.com>
> | Date: Fri Oct 31 14:13:12 2008 -0400
> |
> | netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
> |
> | We have some reasons to kill netdev->priv:
> | 1. netdev->priv is equal to netdev_priv().
> | 2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
> | netdev_priv() is more flexible than netdev->priv.
> | But we cann't kill netdev->priv, because so many drivers reference to it
> | directly.
> |
> | OK, becasue Dave S. Miller said, "every direct netdev->priv usage is a bug",
> | and I want to kill netdev->priv later, I decided to convert all the direct
> | reference of netdev->priv first.
> |
> | (Original patch posted by Wang Chen <wangchen@cn.fujitsu.com> w/ above
> | changelog but using dev->ml_priv. That doesn't seem appropriate
> | to me for this driver, so I've revamped it to use netdev_priv()
> | instead. -- JWL)
>
> This commit changed the allocation of netdev, but didn't change
> the free method of it.
> This causes "zd" be used after the memory, which is pointed by "zd", being
> freed by free_netdev().
Oops...thanks!
John
--
John W. Linville Linux should be at the core
linville@tuxdriver.com of your literate lifestyle.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH -next] netdevice zd1201: Use after free
2008-12-18 6:53 ` [PATCH -next] netdevice zd1201: Use after free Wang Chen
2008-12-18 13:58 ` John W. Linville
@ 2008-12-19 3:37 ` David Miller
1 sibling, 0 replies; 17+ messages in thread
From: David Miller @ 2008-12-19 3:37 UTC (permalink / raw)
To: wangchen; +Cc: linville, linux-wireless, jgarzik, netdev
From: Wang Chen <wangchen@cn.fujitsu.com>
Date: Thu, 18 Dec 2008 14:53:31 +0800
> | commit 3d29b0c33d431ecc69ec778f8c236d382f59a85f
> | Author: John W. Linville <linville@tuxdriver.com>
> | Date: Fri Oct 31 14:13:12 2008 -0400
> |
> | netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv()
...
>
> This commit changed the allocation of netdev, but didn't change
> the free method of it.
> This causes "zd" be used after the memory, which is pointed by "zd", being
> freed by free_netdev().
>
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Patch applied to net-next-2.6, thanks!
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-12-19 3:37 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <48C0A219.2030004@cn.fujitsu.com>
2008-09-05 3:27 ` [PATCH 14/18] netdevice airo: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2008-09-05 12:50 ` John W. Linville
2008-09-05 17:06 ` Dan Williams
2008-09-06 9:37 ` Wang Chen
2008-09-26 8:37 ` Wang Chen
2008-09-05 3:28 ` [PATCH 15/18] netdevice libertas: Fix directly reference of netdev->priv Wang Chen
2008-09-05 17:07 ` Dan Williams
2008-10-31 19:17 ` John W. Linville
2008-09-05 3:29 ` [PATCH 16/18] netdevice zd1201: Convert directly reference of netdev->priv to netdev->ml_priv Wang Chen
2008-09-05 12:56 ` John W. Linville
2008-10-31 18:22 ` John W. Linville
2008-10-31 18:48 ` [PATCH] netdevice zd1201: Convert directly reference of netdev->priv to netdev_priv() John W. Linville
2008-10-31 19:00 ` Stephen Hemminger
2008-11-03 2:06 ` Wang Chen
2008-12-18 6:53 ` [PATCH -next] netdevice zd1201: Use after free Wang Chen
2008-12-18 13:58 ` John W. Linville
2008-12-19 3:37 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).