From: drozdziak1@gmail.com (Stan Drozd)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Kernelnewbies Digest, Vol 79, Issue 18
Date: Wed, 21 Jun 2017 14:11:34 +0200 [thread overview]
Message-ID: <20170621121133.GA22356@gmail.com> (raw)
In-Reply-To: <147778546-f192c7b815ebdbba65aba39b31c11c0c@pmq2v.m5r2.onet>
On Wed, Jun 21, 2017 at 12:35:54PM +0200, wiktoria.lewicka wrote:
> Thank you all, I make some changes in my code, but its still not work. When my module is loading and loading I have a problems with connection with Internet- is it a matter of configuration?
> My changes:
>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/netdevice.h>
> #include <linux/string.h>
> #define DEV_NAME "my_dev\n"
>
> struct net_device my_netdev;
>
> int init_mdev(struct net_device *dev);
>
> struct net_device_ops nops = {
> .ndo_init = init_mdev,
> /*.ndo_uninit = unin_mdev,*/
> };
>
> static int __init init_dev(void)
> {
> /*my_netdev.netdev_ops = &nops;*/
> int result;
> if(!(netdev_boot_setup_check(&my_netdev))){
> printk(KERN_ERR "NETDEV: setup error");
> return 0;
You might want to return a -1 here. Are you sure netdev_boot_setup_check()
returns 0 on *un*successful return? That's what the ! seems to suggest.
> }
> strcpy(my_netdev.name, DEV_NAME);
> if((result = register_netdev(&my_netdev)))
> printk(KERN_ERR "NETDEV: Error registering device");
> printk("NETDEV: Device registered successfully");
Both of the printk()'s above will execute on error. How about adding braces and
returning result on error?
> return 0;
> }
>
> static void __exit remove_dev(void)
> {
> unregister_netdev(&my_netdev);
> }
> int init_mdev(struct net_device *dev)
> {
> printk("INIT");
> return 0;
> }
> module_init(init_dev);
> module_exit(remove_dev);
>
It seems that your e-mail client (the Onet WebUI) keeps malforming your
indentation. This link might come in handy:
https://www.kernel.org/doc/html/v4.10/process/email-clients.html?highlight=email,
I'm sure more people will join the discussion once your style looks more
approachable.
I'm not much into network devices myself, but could you maybe try and find which
call hangs your init function e.g. with printk()'s before each call? I believe
your net_device structure might be incomplete. Once you find the problematic
call, a cross-reference source code search engine like lxr.free-electrons.com/
could help you understand which struct net_device members might need your
attention.
Stan
prev parent reply other threads:[~2017-06-21 12:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-21 10:35 Kernelnewbies Digest, Vol 79, Issue 18 wiktoria.lewicka
2017-06-21 12:11 ` Stan Drozd [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170621121133.GA22356@gmail.com \
--to=drozdziak1@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).