From: Ken Mills <[email protected]>

Subject: [PATCH] n_gsm: Network interface name is hard coded.

The application should be able to set the network format string. Also that
string is not currently being passed down to alloc_netdev() properly.

Added a field to the gsm_netconfig structure so the network interface name 
format
string can be passed down upon network enable. If the string is null, then the
default string is "gsm%d and will be passed to alloc_netdev().

Signed-off-by: Ken Mills <[email protected]>
---
 drivers/tty/n_gsm.c    |    9 ++++++---
 include/linux/gsmmux.h |    2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 0f159f9..7f74e36 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2610,7 +2610,7 @@ static void gsm_destroy_network(struct gsm_dlci *dlci)
 
 static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
 {
-       char netname[6];
+       char *netname;
        int retval = 0;
        int channel = dlci->addr;
        struct net_device *net;
@@ -2630,8 +2630,10 @@ static int gsm_create_network(struct gsm_dlci *dlci, 
struct gsm_netconfig *nc)
                return -EPROTONOSUPPORT;
 
        pr_debug("create network interface");
-       netname[5] = 0;
-       snprintf(netname, 6, "gsm%02d", channel);
+
+       netname = "gsm%d";
+       if (nc->if_name[0] != '\0')
+               netname = nc->if_name;
        net = alloc_netdev(sizeof(struct gsm_mux_net),
                        netname,
                        gsm_mux_net_init);
@@ -2870,6 +2872,7 @@ static int gsmtty_ioctl(struct tty_struct *tty, struct 
file *filp,
        case GSMIOC_ENABLE_NET:
                if (copy_from_user(&nc, (void __user *)arg, sizeof(nc)))
                        return -EFAULT;
+               nc.if_name[NAMESIZE-1] = '\0';
                /* return net interface index or error code */
                return  gsm_create_network(dlci, &nc);
        case GSMIOC_DISABLE_NET:
diff --git a/include/linux/gsmmux.h b/include/linux/gsmmux.h
index c26e993..19a919b 100644
--- a/include/linux/gsmmux.h
+++ b/include/linux/gsmmux.h
@@ -20,12 +20,14 @@ struct gsm_config
 
 #define GSMIOC_GETCONF         _IOR('G', 0, struct gsm_config)
 #define GSMIOC_SETCONF         _IOW('G', 1, struct gsm_config)
+#define NAMESIZE 16
 
 struct gsm_netconfig
 {
        unsigned int adaption;  /* Adaption to use in network mode */
        unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */
        unsigned short unused2;
+       char if_name[NAMESIZE]; /* interface name format string */
        __u8 unused[28];        /* For future use */
 };
 
-- 
1.7.0.4
_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to