2020. július 29., szerda 5:17 keltezéssel, Daniel Dadap <ddadap@xxxxxxxxxx> írta: > Thanks for your comments. A v2 patch will follow after I've had some > time to test it more; in the meantime, I've responded to your > suggestions inline: > > [...] > >> + > >> +static int mxds_gmux_init(void) > >> +{ > >> + int ret = 0; > >> + struct pci_dev *dev = NULL; > >> + static struct vga_switcheroo_handler handler = { > >> + .switchto = mxds_gmux_switchto, > >> + .get_client_id = mxds_gmux_get_client_id, > >> + }; > >> + > > Any reason why "handler" is inside the function and not const? > > > > You're right, it can be const. I have it in the function (with static > storage) because we don't need to reference it anywhere else. I'd think > the static storage would allow the pointer to the struct to stay alive > even after the init function exits, but if you think it would be better > to have it out of the function's scope I can move it. > I see. I think having it out of the function better signals the intention that this variable is supposed to live as long as the module is loaded. Furthermore, - although I am not sure about this, but - I think having a function static variable here prevents mxds_gmux_init() from being marked __init. Also, I forgot to mention before, but mxds_gmux_fini() is not marked __exit. Any reason why? > [...] Barnabás Pőcze