Skip to content

Commit

Permalink
omap: Fix omap_mux_init_signal not to trash muxname
Browse files Browse the repository at this point in the history
Otherwise the muxname passed to the function will get truncated.

Based on an earlier patch by rockefeller.lin@innocomm.com.

Reported-by: rockefeller.lin@innocomm.com
Signed-off-by: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Tony Lindgren committed Oct 1, 2010
1 parent 7ad0e38 commit 5a3b2f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions arch/arm/mach-omap2/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ int __init omap_mux_init_gpio(int gpio, int val)
return 0;
}

int __init omap_mux_init_signal(char *muxname, int val)
int __init omap_mux_init_signal(const char *muxname, int val)
{
struct omap_mux_entry *e;
char *m0_name = NULL, *mode_name = NULL;
int found = 0;
const char *mode_name;
int found = 0, mode0_len = 0;

mode_name = strchr(muxname, '.');
if (mode_name) {
*mode_name = '\0';
mode0_len = strlen(muxname) - strlen(mode_name);
mode_name++;
m0_name = muxname;
} else {
mode_name = muxname;
}
Expand All @@ -147,9 +146,11 @@ int __init omap_mux_init_signal(char *muxname, int val)
char *m0_entry = m->muxnames[0];
int i;

if (m0_name && strcmp(m0_name, m0_entry))
/* First check for full name in mode0.muxmode format */
if (mode0_len && strncmp(muxname, m0_entry, mode0_len))
continue;

/* Then check for muxmode only */
for (i = 0; i < OMAP_MUX_NR_MODES; i++) {
char *mode_cur = m->muxnames[i];

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int omap_mux_init_gpio(int gpio, int val);
* @muxname: Mux name in mode0_name.signal_name format
* @val: Options for the mux register value
*/
int omap_mux_init_signal(char *muxname, int val);
int omap_mux_init_signal(const char *muxname, int val);

#else

Expand Down

0 comments on commit 5a3b2f7

Please sign in to comment.