C Calling convention Question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C Calling convention Question

4,071 Views
davidzhou
Contributor V

Hi,

In kernel/drivers/fbdev/mxsfb.c (line 994): defined mxsfb_ops functions

static struct fb_ops mxsfb_ops = {
    .owner = THIS_MODULE,
    .fb_check_var = mxsfb_check_var,
    .fb_set_par = mxsfb_set_par,
    .fb_setcolreg = mxsfb_setcolreg,
    .fb_ioctl = mxsfb_ioctl,
    .fb_blank = mxsfb_blank,
    .fb_pan_display = mxsfb_pan_display,
    .fb_mmap = mxsfb_mmap,
    .fb_fillrect = cfb_fillrect,
    .fb_copyarea = cfb_copyarea,
    .fb_imageblit = cfb_imageblit,
};

Line 878: defines the function:

static int mxsfb_blank(int blank, struct fb_info *fb_info)
{
    struct mxsfb_info *host = to_imxfb_host(fb_info);

    host->cur_blank = blank;

...

}

Line 1506: calls the function:

    ret = fb_blank(fb_info, FB_BLANK_UNBLANK);

Line 1591: calls the function:

    mxsfb_blank(FB_BLANK_POWERDOWN, fb_info);

Why the parameters are passed in with different order?

Thank you,

David Zhou

0 Kudos
6 Replies

3,777 Views
zhaoqinsu
NXP Employee
NXP Employee

    Hi David ,

Can you tell me what is the role of three functions ?  as below :

    .fb_fillrect = cfb_fillrect,
    .fb_copyarea = cfb_copyarea,
    .fb_imageblit = cfb_imageblit,

Thank you !

0 Kudos

3,777 Views
davidzhou
Contributor V

Hi Calros

Here is the finding:

In the \linux\fb.h

\linux\fb.h(266):              int (*fb_blank)(int blank, struct fb_info *info);

\linux\fb.h(598):        extern int fb_blank(struct fb_info *info, int blank);

(That was confusing and not a good practice)

 

The line (266) has the same signature as

static int mxsfb_blank(int blank, struct fb_info *fb_info);

 

That explains the structure assignment for the function pointer:

.fb_blank = mxsfb_blank,

 

And the call of the function in the line 1533:

ret = fb_blank(fb_info, FB_BLANK_UNBLANK);

The function signature is defined as the line 598 (shown above)

The call to the function  fb_blank

ret = fb_blank(fb_info, FB_BLANK_UNBLANK);

It is actually defined in the ../fbdev/core/fbmem.c.

Only a little confusion that why not directly call the mxsfb_blank().

David Zhou

0 Kudos

3,777 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi David,

which kernel are you using?

0 Kudos

3,777 Views
davidzhou
Contributor V

Hi Carlos,

Thank you for your email regarding my question.

The linux kernel is version 4.1 from DIGI.

The driver passed compilation, and it seems have no problems of running. I just confused myself with the parameters passing sequence.

Thank you,

David Zhou

0 Kudos

3,777 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi David,

I find it strange too, but in this case you may contact Digi Embedded because they developed this BSP, not NXP.


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

3,776 Views
davidzhou
Contributor V

Hi Calros,

Thank you.

David

0 Kudos