remove internal netif_up/down callbacks and export them
We don't do if_up/down internally any longer, since it is depreacated. Instead we add now can_start/stop callbacks and let the user do the job themselves in threir applications. Signed-off-by: Luotao Fu <l.fu@pengutronix.de>pull/106/head^2
parent
32c72a4868
commit
1751269c33
|
|
@ -24,6 +24,8 @@
|
||||||
#include <linux/can/netlink.h>
|
#include <linux/can/netlink.h>
|
||||||
|
|
||||||
int scan_do_restart(const char *name);
|
int scan_do_restart(const char *name);
|
||||||
|
int scan_do_stop(const char *name);
|
||||||
|
int scan_do_start(const char *name);
|
||||||
|
|
||||||
int scan_set_restart_ms(const char *name, __u32 restart_ms);
|
int scan_set_restart_ms(const char *name, __u32 restart_ms);
|
||||||
int scan_set_bittiming(const char *name, struct can_bittiming *bt);
|
int scan_set_bittiming(const char *name, struct can_bittiming *bt);
|
||||||
|
|
|
||||||
|
|
@ -489,17 +489,7 @@ static int do_set_nl_link(int fd, __u8 if_state, const char *name,
|
||||||
return send_mod_request(fd, &req.n);
|
return send_mod_request(fd, &req.n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netif_up(int fd, const char *name)
|
static int set_link(const char *name, __u8 if_state, struct req_info *req_info)
|
||||||
{
|
|
||||||
return do_set_nl_link(fd, IF_UP, name, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int netif_down(int fd, const char *name)
|
|
||||||
{
|
|
||||||
return do_set_nl_link(fd, IF_DOWN, name, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int set_link(const char *name, struct req_info *req_info)
|
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
@ -508,15 +498,7 @@ static int set_link(const char *name, struct req_info *req_info)
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
err = netif_down(fd, name);
|
err = do_set_nl_link(fd, if_state, name, req_info);
|
||||||
if (err < 0)
|
|
||||||
goto close_out;
|
|
||||||
|
|
||||||
err = do_set_nl_link(fd, 0, name, req_info);
|
|
||||||
if (err < 0)
|
|
||||||
goto close_out;
|
|
||||||
|
|
||||||
err = netif_up(fd, name);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto close_out;
|
goto close_out;
|
||||||
|
|
||||||
|
|
@ -526,6 +508,17 @@ err_out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scan_do_start(const char *name)
|
||||||
|
{
|
||||||
|
return set_link(name, IF_UP, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int scan_do_stop(const char *name)
|
||||||
|
{
|
||||||
|
|
||||||
|
return set_link(name, IF_DOWN, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int scan_do_restart(const char *name)
|
int scan_do_restart(const char *name)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
@ -583,7 +576,7 @@ int scan_set_restart_ms(const char *name, __u32 restart_ms)
|
||||||
if (restart_ms == 0)
|
if (restart_ms == 0)
|
||||||
req_info.disable_autorestart = 1;
|
req_info.disable_autorestart = 1;
|
||||||
|
|
||||||
return set_link(name, &req_info);
|
return set_link(name, 0, &req_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scan_set_ctrlmode(const char *name, struct can_ctrlmode *cm)
|
int scan_set_ctrlmode(const char *name, struct can_ctrlmode *cm)
|
||||||
|
|
@ -592,7 +585,7 @@ int scan_set_ctrlmode(const char *name, struct can_ctrlmode *cm)
|
||||||
.ctrlmode = cm,
|
.ctrlmode = cm,
|
||||||
};
|
};
|
||||||
|
|
||||||
return set_link(name, &req_info);
|
return set_link(name, 0, &req_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scan_set_bittiming(const char *name, struct can_bittiming *bt)
|
int scan_set_bittiming(const char *name, struct can_bittiming *bt)
|
||||||
|
|
@ -601,7 +594,7 @@ int scan_set_bittiming(const char *name, struct can_bittiming *bt)
|
||||||
.bittiming = bt,
|
.bittiming = bt,
|
||||||
};
|
};
|
||||||
|
|
||||||
return set_link(name, &req_info);
|
return set_link(name, 0, &req_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scan_set_bitrate(const char *name, __u32 bitrate, __u32 sample_point)
|
int scan_set_bitrate(const char *name, __u32 bitrate, __u32 sample_point)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue