Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14
Oh, I see. I didn't think init_netdev would be a static function. A bit strange really, isn't it? Anyway, restore the old line there and do this change instead, then: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    Oh, I see. I didn't think init_netdev would be a static function. A bit strange really, isn't it? Anyway, restore the old line there and do this change instead, then:

    Original code:
    Code:
    	if (!(Adapter->net = init_etherdev(NULL, 0))) {
    		MOD_DEC_USE_COUNT;
    		kfree(Adapter);
    		usb_dec_dev_use(dev);
    		return NULL;
    	}
    
    	ether_setup(Adapter->net);
    Change to (just one line added):
    Code:
    	if (!(Adapter->net = init_etherdev(NULL, 0))) {
    		MOD_DEC_USE_COUNT;
    		kfree(Adapter);
    		usb_dec_dev_use(dev);
    		return NULL;
    	}
    	dev_alloc_name(Adapter->net, "wlan%d");
    
    	ether_setup(Adapter->net);
    And yes, it is a little bit ugly, but so little that noone will notice. I wouldn't choose it as a permanent solution for the official driver code, of course, but IMHO it doesn't hurt here.

  2. #12
    Just Joined!
    Join Date
    May 2003
    Location
    UK-Heart of Cheshire
    Posts
    31
    Over my head but I will give it a try.

    Too many question to ask here like what is a symbol and what is a static function and what other type are there? (I am a newbie to c-got as far as comiling kernel-not jet to the error resolution stage and debug stage yet )

  3. #13
    Just Joined!
    Join Date
    May 2003
    Location
    UK-Heart of Cheshire
    Posts
    31
    What a star . Works fine once I had changed all the if settings!

    Can you explain (in newbie language) what the code means and does (new to c but do have an understanding of programming)

    Thanks

  4. #14
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I'm glad that it worked!

    I'll try to answer some of the questions.
    A symbol is basically a name for a memory address. The address can be for example a function or a variable. Say if a module wants to use a function in the kernel, it only has the function's name before it's loaded into the kernel. While the module is being into the kernel, all the symbol names are resolved to get the actual memory address at which the function resides, so that it can be called. If a symbol name can't be found in the kernel (such as was the case with init_netdev), it cannot be resolved, and therefore modprobe will return an error saying that there were unresolved symbols.
    A static function in C is a function that exists and has a symbol, so that other functions in the same source file can use it. When the source file is compiled, however, the symbol isn't exported, so other soruce files can't use it. init_netdev is such a function; it's only used in the source file in which it exists. The reason that you would want to make a function static is that since the symbol won't be exported, other files can export that symbol instead. A certain symbol can only be exported once in the files that are linked together. Therefore, a static symbol doesn't take up space in the namespace.
    I doubt that you get all of that, since I didn't really explain it very well. I'm not very good at explaining these things.

    The difference that this code made is that it renames the network interface after it has been initialized. That's why I said it was a bit ugly. If I had done it properly, I would have made the module name the interface wlan0 directly instead of first naming it eth0 and then renaming it to wlan0. It's only that that would have taken many more lines of code.

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •