Skip to content

Commit

Permalink
[cleanup] Remove the obsolete NO_KMOD code parts
Browse files Browse the repository at this point in the history
Kmod is pretty standard these days, so no need to support the
old style and slightly insecure modprobe stuff.

Author: Thomas Perl <m@thp.io>
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Apr 28, 2015
1 parent 0d4e131 commit b9b4ac4
Showing 1 changed file with 0 additions and 83 deletions.
83 changes: 0 additions & 83 deletions src/usb_moded-modules.c
Expand Up @@ -69,26 +69,6 @@ int usb_moded_load_module(const char *module)
{
int ret = 0;

#ifdef NO_KMOD
gchar *command;

if(!strcmp(module, MODULE_NONE))
return 0;

command = g_strconcat("modprobe ", module, NULL);
ret = system(command);
if(!strcmp(module, MODULE_MASS_STORAGE) && (ret != 0))
{
command = g_strconcat("modprobe ", MODULE_FILE_STORAGE, NULL);
ret = system(command);
}
if(!strcmp(module, MODULE_CHARGING) && (ret != 0))
{
command = g_strconcat("modprobe ", MODULE_CHARGE_FALLBACK, NULL);
ret = system(command);
}
g_free(command);
#else
const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST;
struct kmod_module *mod;
char *charging_args = NULL;
Expand Down Expand Up @@ -136,7 +116,6 @@ int usb_moded_load_module(const char *module)
}
kmod_module_unref(mod);
free(load);
#endif /* NO_KMOD */

if( ret == 0)
log_info("Module %s loaded successfully\n", module);
Expand All @@ -155,17 +134,6 @@ int usb_moded_unload_module(const char *module)
{
int ret = 0;


#ifdef NO_KMOD
gchar *command;

if(!strcmp(module, MODULE_NONE))
return 0;

command = g_strconcat("rmmod ", module, NULL);
ret = system(command);
g_free(command);
#else
struct kmod_module *mod;

if(!strcmp(module, MODULE_NONE))
Expand All @@ -175,8 +143,6 @@ int usb_moded_unload_module(const char *module)
ret = kmod_module_remove_module(mod, KMOD_REMOVE_NOWAIT);
kmod_module_unref(mod);

#endif /* NO_KMOD */

return(ret);
}

Expand Down Expand Up @@ -204,55 +170,6 @@ static int module_state_check(const char *module)
*/
const char * usb_moded_find_module(void)
{
#ifdef NO_KMOD
FILE *stream = 0;
const char *result = 0;

if( (stream = popen("lsmod", "r")) )
{
char *text = 0;
size_t size = 0;

while( getline(&text, &size, stream) >= 0 )
{
if( strstr(text, "g_file_storage") )
{
result = MODULE_FILE_STORAGE;
break;
}
if( strstr(text, "g_mass_storage") )
{
result = MODULE_MASS_STORAGE;
break;
}
if( strstr(text, "g_ether") )
{
result = MODULE_WINDOWS_NET;
break;
}
if( strstr(text, "g_ncm") )
{
result = "g_ncm";
break;
}
if( strstr(text, "g_ffs") )
{
result = MODULE_MTP;
break;
}
/* if switching without disconnect we might have some dynamic module loaded */
if(strstr(text, get_usb_module()))
{
result = get_usb_module();
break;
}
}
pclose(stream);
}

return result;
#endif /* NO_KMOD */

if(module_state_check("g_ether"))
return(MODULE_DEVELOPER);
else if(module_state_check("g_ncm"))
Expand Down

0 comments on commit b9b4ac4

Please sign in to comment.