init function invocation of drivers compiled into kernel

In Linux if device drivers are built as loadable kernel modules, then upon inserting the device driver kernel module, the kernel calls the init function of the device driver as pointed out by module_init() macro.

How does this work for device drivers that are statically compiled into the kernel ? How is their init function called ?

How do I generate loadable modules during Linux kernel build?

I seem to successfully build a kernel image, but I can not generate all the modules I expect. I expect more modules since I see them enabled in the gconfig window. Here is a copy of my make session. Seems like make goes into the devices directories. I can not figure out why it is not create the .ko files. I expect to see .ko files. I have checked the Makefile in /drivers directory, and I can see that it is configured with a number of lines like

obj-$(CONFIG_PCI)               += pci/

Which directs make to build the pci module for instance. I think this implies that I should see a number .ko files. But I do not. I have seen just one .ko file for scsi module. I like to be able to build all of modules selected.

I also verified that a number of mudules are enabled when I issued:

make VARIANT_DEFCONFIG=msm8974_sec_hlte_spr_defconfig msm8974_sec_defconfig SELINUX_DEFCONFIG=selinux_defconfig gconfig

But as I said, I do not see any of them. What am I missing please?

@Subin – Thanks. I just tried make modules_install. I have to mention that I am cross compiling this for an arm target. I believe modules_install is for the purpose of installing the driver for the machine you are on? I got a message about needing to be in root, and I did not proceed. I have been wondering when I need to run it. What does it do exactly please?

Re: the make modules; I have run it before. I’ll run it again and post the result. Since I got one .ko file I figured the issue is something different between that one module, and every other one enabled in my config. Here is what I got when I ran make modules:

sansari@ubuntu:~/WORKING_DIRECTORY$ make modules
CHK     include/linux/version.h
CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL    scripts/
Building modules, stage 2.
MODPOST 1 modules

Re: your comment on the location of .ko files, I am doing a find to see if perhaps I am not looking at the right place, it only finds the one which was built. Not the other ones. Here is the output:

sansari@ubuntu:~/WORKING_DIRECTORY$ find . -type f -name "*.ko"

Should I perhaps run make v=1, in verbose mode that is? Would that provide more information on why the other modules are not built?

@Gil Hamilton – Thanks. You are right. Here is an excerpt of the .config file:

# SCSI support type (disk, tape, CD-ROM)
# CONFIG_CHR_DEV_ST is not set
# CONFIG_CHR_DEV_OSST is not set
# CONFIG_BLK_DEV_SR is not set

This entry is the only one set to ‘m’.

Insert linux kernel module statically

When building the Linux kernel from sources one could decide if a certain functioninality is statically build into the kernel or packed into a module for dynamic insertion by .config.

If on the other hand I have sources for any 3rd party module, like for example a packaged device driver, is it possible to programatically integrate this code into the kernel statically instead?

buildroot using external toolchain – rootfilesystem creating

I am trying to build my own rootfile system for RPI using buildroot.
I am new to buildroot.

I have downloaded following cross compiler folder from git :–
as mentioned in this link :–

How i will come to know what is the kernel header is used by above cross compiler ?

My installer GCC compiler is :–

crosscompiler is downloaded from git at following location:–

Please suggest what value to fill here for toolchain selection :–

Toolchain type : External toolchain
Toolchain : Custom toolchain
Toolchain origin : Pre-installed toolchain
Toolchain path : ?
Toolchain prefix : ?
external Toolchain kernel header series : ?
external toolchain c library : ?

Cross compiler not finding SDL package

i am cross compiling a small application which uses libsdl (SDL). I can compile using gcc but not able to with cross compiler. the cross compiler i am using is arm-arago-linux-gnueabi-gcc. error message come as

/arm-arago-linux-gnueabi/bin/ld: cannot find -lSDL
although libsdl1.2-dev is installed an i am getting pkg-config –cflags sdl output as -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL
and output of pkg-config –libs sdl as -lSDL.
Since my native compiler gcc is detecting SDL libs any idea why my cross compiler not able to find the libraries

Why does std::forward return static_cast and not static_cast?

Let’s have a function called Y that overloads:

void Y(int& lvalue)
{ cout << "lvalue!" << endl; }

void Y(int&& rvalue)
{ cout << "rvalue!" << endl; }

Now, let's define a template function that acts like std::forward

void f(T&& x)
   Y( static_cast(x) );   // Using static_cast(x) like in std::forward

Now look at the main()

int main()
   int i = 10;

   f(i);       // lvalue >> T = int&
   f(10);      // rvalue >> T = int&&

As expected, the output is


Now come back to the template function f() and replace static_cast(x) with static_cast(x). Let's see the output:


It's the same! Why? If they are the same, then why std::forward<> returns a cast from x to T&&?

Refactoring with C++ 11

Given the new toolset provided by c++ lots of programmers, aiming at code simplification, expressiveness, efficiency, skim through their old code and make tweaks (some pointless, some successful) to achieve their goals. Whilst trying not to loose too much time on such labors and just make non intrusive and self contained changes, what are the best practices?

Let me cross out the obvious :

  • Use auto to run iterator based loops :

    for (std::vector::const_iterator it(lala.begin()), ite(lala.end()); it != ite;     
    // becomes
    for (auto it(lala.cbegin()), ite(lala.cend()); it != ite; ++it);
  • Use tie for multiple assignments that just produce C-style rows of code ( how to assign multiple values into a struct at once? )

    a = 1;
    b = 2; 
    c = 3;
    d = 4; 
    e = 5;
    // becomes
    std::tie(a, b, c, d, e) = std::make_tuple(1, 2, 3, 4, 5);
  • To make a class non inheritable just declare it as “final” and delete the code that achieved such a behavior

  • Use the delete keyword to explicitly hide constructors/destructors instead of declaring them private (eg code to create heap based objects, non copyable objects etc)

  • Turn trivial functors created just to facillitate the execution of a single STL algorithm into lambda functions (apart from reducing code cluttering you’ll have guaranteed inlined calls)

  • Simplify RAII wrapping of an object by just using a smart pointer

  • Get rid of bind1st, bind2nd and just use bind

  • Replace hand written code for type traits (Is_ptr_but_dont_call_for_const_ptrs<> and such 🙂 ) with standard code provided by < type_traits >

  • Stop including boost headers for functionallity now implented in STL (BOOST_STATIC_ASSERT vs static_assert)

  • Provide move semantics to classes (although this wouldn’t qualify as a dirty/quick/easy change)

  • Use nullptr where possible instead of the NULL macro and get rid of the code that filled containers of pointers with 0’s casted to object type

    std::vector f(23);
    for (std::size_t i(0); i < 23; ++i)
    { f[i] = static_cast(0); }
    // becomes
    std::vector f(23, nullptr);
  • Clear the vector data accessing syntax

    std::vector vec;
    &vec[0];    // access data as a C-style array; // new way of saying the above
  • Replace throw() with noexcept (apart from avoiding the deprecated exception specifiation you get some speed benefits @ 00.29.42)

    void some_func() noexcept; // more  optimization options
    void some_func() throw();  // fewer optimization options
    void some_func() ;         // fewer optimization options
  • Replace code where you’d push a tempory in a container and hoped that the optimizer would ellide the copy away, with an “emplace” function where available, in order to perfectly forward the argument and construct directly an object into a container without temporary at all.

    vecOfPoints.push_back(Point(x,y,z)); // so '03
    vecOfPoints.emplace_back(x, y, z);   // no copy or move operations performed


The answer by Shafik Yaghmour was rightfully awarded the bounty for having the greatest acceptance by the audience.

The answer by R Sahu was my accepted one, because the combination of features it proposes captures the spirit of refactoring : making code clearer and cleaner and simpler and elegant.

Passing derived class to base function

I’m having trouble passing a derived class to a function which accepts the base class as argument. The base class is consists of “obstacles” which are to be placed on a “board” void Board::setvalue(int length, int width, Obstacle& obstacle);

However, this causes the compiler to give the “no known conversion for argument…”-error. Reading up around the site i found that i should be passing the derived object as a const, this however causes problems because a const can’t be assigned to the board (since it holds pointers to non-const Obstacles).
In turn, changing Board to hold const Obstacles causes a lot of issues elsewhere in the project, especially with the operator<< of Board and Obstacle.
I have tried passing the objects as consts and then using Obstacle ob = new obstacle(the const obstacle) but this made them generic Obstacle objects rather than Player/Barrel/Wall objects.

Is there any way to pass these objects as non-consts or assigning them as non-consts? i tried using const_cast() but this caused undefined behaviour.

An example of the function call:

Board_->setvalue(x, y, Player(data, moveable, x, y));

Here is my code:

The base class

class Obstacle
    Obstacle* _properlyinitialized;
    string Name;
    bool Moveable;
    int x;
    int y;
    Obstacle(string Name, bool Moveable, int x, int y);
    virtual ~Obstacle();
    bool properlyInitialized();
    friend std::ostream& operator<<(std::ostream& stream, Obstacle& Obstacle);

An example of the derived classes (other derived classes don't have special functions yet)

class Player: public Obstacle
    Player(string Name, bool Moveable, int x, int y):Obstacle(Name, Moveable, x, y){this->_properlyinitialized = this;};
    /*void Moveleft();
    void Moveright();
    void Moveup();
    void Movedown();*/

The Board class header

class Board
    Board* _properlyinitialized;
    int length;
    int width;
    Obstacle * * * playfield;

                "Object wasn't initialized when calling object");
    Board(int length, int width);
    bool properlyInitialized();
            "Object wasn't initialized when calling properlyinitialized");
    void clear();
    const int getLength();
    const int getWidth();
    Obstacle*** getBoard();
    Obstacle* getTile(int length, int width);
    void setvalue(int length, int width, Obstacle& obstacle);
    friend std::ostream& operator<<(std::ostream& stream, Board& Board);

std::ostream& operator<<(std::ostream& stream, Board& Board);

And finally, the setvalue function.

void Board::setvalue(int length, int width, Obstacle& obstacle)
    this->playfield[length][width] = &obstacle;//value;

I'm happy to provide more code if needed.

Unable to set TextArea value using Jquery

I am only setting one simple value in text area using jquery on radio button click. but it sets nothing.

My Code is:






What I have Tried:


Doesn’t work.

Here: if I set value using text area id, it works properly
example: $(“#Note”).val(“dummyNote”); // works fine

But I want to use “Name” not “Id”

Plz help, i am very new in Stack overflow, may be some mistake in my description. Plz let me know.

Thanks in Advance

Need to get TAG name by element name using Jquery [duplicate]

This question already has an answer here:

I have set of html elements and I named those for all input/select/textarea. Anyway the names are unique for each element.

Now I need to get the Html TAG (Input/Select/Textarea) by Element name.

For EX:

I need to get the ‘input’ TAG by using element name ‘sample’.

I dont want to mention the TAG name on selector part in jquery. I have only unique names to find the TAGs.

Please help on this.

Thanks in advance.!

How do I remove the space between inline-block elements?

Given this HTML and CSS:

span {

Foo Bar

As a result, there will be a 4 pixel wide space between the SPAN elements.


I understand why this happens, and I also know that I could get rid of that space by removing the white-space between the SPAN elements in the HTML source code, like so:

Foo Bar

However, I was hoping for a CSS solution that doesn’t require the HTML source code to be tampered with.

I know how to solve this with JavaScript – by removing the text nodes from the container element (the paragraph), like so:

// jQuery
$('p').contents().filter(function() { return this.nodeType === 3; }).remove();


But can this issue be solved with CSS alone?

How do I remove the space between inline-block elements?

Given this HTML and CSS:

span {

Foo Bar

As a result, there will be a 4 pixel wide space between the SPAN elements.


I understand why this happens, and I also know that I could get rid of that space by removing the white-space between the SPAN elements in the HTML source code, like so:

Foo Bar

However, I was hoping for a CSS solution that doesn’t require the HTML source code to be tampered with.

I know how to solve this with JavaScript – by removing the text nodes from the container element (the paragraph), like so:

// jQuery
$('p').contents().filter(function() { return this.nodeType === 3; }).remove();


But can this issue be solved with CSS alone?

Display: Inline block – What is that space? [duplicate]

This question already has an answer here:

Inline Blocks have this weird space in-between them. I could live with it, up to a point where, if I load more content with an AJAX Call, the tiny space goes away. I know I’m missing something here.

div {
    width: 100px;
    height: auto;
    border: 1px solid red;
    outline: 1px solid blue;
    margin: 0;
    padding: 0; 
    display: inline-block;

How to make the spacing consistent in Inline blocks ?

How to remove the space between list items [duplicate]

This question already has an answer here:

How to you get rid of the white space between list items? I am trying to make it so that the images are right next to each other. Even though I have set the styling to margins: 0;, they are still separated.


  margin: 20px;
  width: 410px;
  height: 320px;
  background-color: grey;
  float: left;
  list-style-type: none;

ul.frames  li {
  margin: 0;
  display: inline;
  list-style: none;

ul.frames li img {
  margin: 0 0 0 0;


  • How can I eliminate spacing between inline elements in CSS? [duplicate]

    This question already has an answer here:

    I have a div with a bunch of image tags inside, here is an example:

    Foo1 Foo2 Foo3

    Because there is whitespace between the tags, browsers will display some whitespace between the images (Chrome decides on 4px). How can I tell the browser to show NO whitespace whatsoever between the images, without placing the > and < directly next to each other? I know letter-spacing applies in addition to what the browser decides to use, so that's useless even with a negative value. Basically I'm going for something like Twitter has at the bottom of their home page. I looked at their code and they're using an unordered list. I could just do that but I'd like the technical explanation for why there appears to be no way to eliminate the white space from between these images.

    How to deserialize json to multiple types dynamically in c# [duplicate]

    This question already has an answer here:

    I have a json string like below :

    “error” : “xxxx” ,
    “data” : int type or {…other complex json object}

    I don’t know when return int or other json string from data field , and how to deserialize this ?

    when type of data is object or dynamic , the real deserialized type of data is int or Dictionary using JavaScriptSerializer.Deserialize(string json).

    the real deserialized type of data is Int64 or JContainer when using Json.Net.

    is there a elegance way to solve this ? I don’t think reflection is a good way.

    Deserialize json to anonymous C# object [duplicate]

    This question already has an answer here:

    I need to deserialize custom JSON to anonymous C# object.

    My sample JSON (can be any, even with nested properties as objects):

    var json = "{ 'Surname': 'Wick'}"; 

    And I want to be deserialized as:

    var jsonResult = new { Surname = "Wick" };

    But I end up with something like this:

    enter image description here

    C# get Image Url from JSON response [duplicate]

    This question already has an answer here:

    I am writing a C# app that is supposed to get event data from JSON

    Assuming my JSON response looks like below, how do I get the city_name, image url, date and list of owner names from the response? In JSON below, image could be null and so could be owners.

    Also, how would I download the image and show it in my Image control?

      "total_items": "24",
      "page_number": "1",
      "page_size": "10",
      "page_count": "3",
      "events": {
        "event": [
            "url": "",
            "id": "event-1",
            "city_name": "Seattle",
            "description": "car show event",
            "image": { <-- THIS COULD BE NULL, HOW TO HANDLE NULL VALUE?
              "thumb": {
                "width": "32",
                "url": "/carshow.jpg",
                "height": "32"
            "date": "2015-12-09 13:20:20",
              "owner": [
                  "name": "John Doe",
                  "id": "O12",
                  "bio": "fast track racer"
                  "name": "Tom Tomasson",
                  "id": "O513",
                  "bio": "fines collector"
            "url": "",
            "id": "event-2",
            "city_name": "Blaine",
            "description": "toyota event",
            "image": null, <-- NO IMAGE IS PROVIDED
            "date": "2015-12-09 13:20:20",
            "owners": null, <-- NO OWNER IS PROVIDED


    How to define a class whose properties change in runtime? [duplicate]

    This question already has an answer here:

    I have a class called Attributes

    public class Attributes
        public string Length { get; set; }
        public string Size { get; set; }
        public string Color { get; set; }
        public string Material { get; set; }
        public string Diameter { get; set; }

    This class is populated from a call to a web service that returns JSON. The web service returns a different set of attributes each time and it is not possible to define all the attributes at compile time as this could run into thousands.

    What is the best way to model such a class in c#?

    Deserialize array of JSON objects to c# anonymous [duplicate]

    This question already has an answer here:

    Any ideas how to achieve this?
    I have no problem deserializing a single json object like to c# anonymous type

     string json = @"{'Name':'Mike'}";


     var definition = new { Name = ""};


    var result = JsonConvert.DeserializeAnonymousType(json, definition);

    but when I have

    string jsonArray = @"[{'Name':'Mike'}, {'Name':'Ben'}, {'Name':'Razvigor'}]";

    I am stuck.

    Duplicated Records Being Returned by Web API Method

    I have created what I thought to be a simple controller selecting on a database view. However, the first record is returned multiple times in the JSON result. For example, when filtering using Odata, 7 different records are expected however, 7 of the same record are being returned.

    Here is the controller code:

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;
    using System.Web.Http.Description;
    using MyAPI.WebAPI.Models;
    using System.Web.OData;
    using System.Security.Principal;
    using System.Web;
    namespace MyAPI.WebAPI.Controllers
        public class MyViewController : ApiController
            private MyEntities db = new MyEntities();
            // GET
            [EnableQuery] // Enables OData query integration
            public IHttpActionResult GetMetrics()
                return Ok(db.ViewResults.AsQueryable());

    When using a breakpoint on the return statement, I can see where all 4000 results are being returned in the query and the OData seems to be filtering only the 7 records I need but when it is sent via JSON string it is duplicated.

    Has anyone experienced anything like this?

    Asp.Net Web Api trailing / causing odata query to fail

    I am using HttpClient to query the WebApi controller using the below code:

            var uri = new Uri(url);
            var message = new HttpRequestMessage(method, uri);
            if (content != null) message.Content = new StringContent(content, Encoding.UTF8, "application/json");
            var client = new HttpClient();
            if (content != null) Debug.WriteLine($"Payload:\n {content}");
            var response = await client.SendAsync(message);
            return response;

    The generated Url is as below:

    Note the trailing ‘/’. This causes the OData Validation (code below) to fail:

        public async Task GetRoles(ODataQueryOptions options)
            var filteredResults = await _roleService.GetRolesAsync(options);
            return Ok(filteredResults);
        public void GuardForODataException(ODataQueryOptions options)
                var validationSettings = new ODataValidationSettings();
            catch (Exception e)
                var result =
                    new ValidationFailedResult(
                            new ValidationResultModel(
                                new ValidationResult(
                                    new List { new ValidationFailure("", "Odata Query is invalid") })));
                throw new HttpResponseException(result.ExecuteAsync(default(CancellationToken)).Result);

    The exception I am getting is

    “An identifier was expected at position 9.”

    If however, I remove the trailing /, then the odata query returns the expected results.

    I wasn’t able to find much on how to construct a HttpRequestMessage without the / at the end. Has anyone encountered this before?