sir mordred
sir mordred

Reputation: 161

kernel c multiple definiton of function error

I'm currently trying to compile kernel for my android device unfortunatly I faced with this compilation error and stuck with it

compiler says:

drivers/dpram/built-in.o:(.bss+0x2815c): multiple definition of `pm_dev'
drivers/net/built-in.o:(.bss+0x1ac4): first defined here

in drivers/dpram.c ı have:

struct device *pm_dev;

    pm_dev = device_create(sec_class, NULL, 0, NULL, "pm");
    if(IS_ERR(pm_dev))
        pr_err("Failed to create device(pm)!\n");
    if(device_create_file(pm_dev, &dev_attr_info) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_info.attr.name);
    if(device_create_file(pm_dev, &dev_attr_power_down) < 0)
        pr_err("Failed to create device file(%s)!\n", dev_attr_power_down.attr.name);

and in drivers/net/wireless/bcmdhd/bcmsdh_linux.c ı have:

struct device *pm_dev;

    if (!device_init_wakeup(dev, 1))
        pm_dev = dev;

    if (pm_dev) {
        device_init_wakeup(pm_dev, 0);
        pm_dev = NULL;
    }

I'm currently trying to figure it out but ı couldnt yet

Upvotes: 1

Views: 419

Answers (1)

4pie0
4pie0

Reputation: 29734

The error is caused because

struct device *pm_dev;

is a definition in C. It defines a pointer to structure device and it's name is pm_dev. It is not allowed to define variable more than once therefore you should declare pm_dev as extern in all other source files but just one in which you actually define it.

Declaration(s):

extern struct device *pm_dev;

Single definition:

struct device *pm_dev;

Upvotes: 1

Related Questions