本文整理汇总了C++中dev_open函数的典型用法代码示例。如果您正苦于以下问题:C++ dev_open函数的具体用法?C++ dev_open怎么用?C++ dev_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dev_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: start
void start(void)
{
uint16_t count;
uint8_t index;
buffer = (char *)mos_mem_alloc((uint16_t)BUFFER_SIZE);
memset(buffer, 'X', BUFFER_SIZE);
/* For safety, erase entire FLASH */
dev_ioctl(DEV_TELOS_FLASH, TELOS_FLASH_BULK_ERASE);
/* Turn on the FLASH */
dev_mode(DEV_TELOS_FLASH, DEV_MODE_ON);
/* Acquire lock on FLASH and preliminarly
* write 64 bits of data */
dev_open(DEV_TELOS_FLASH);
count = dev_write(DEV_TELOS_FLASH, "abcdefgh", 8);
printf("%d bytes of data have been written to FLASH memory\n", count);
dev_close(DEV_TELOS_FLASH);
/* Perform experiments over R/W pointer to FLASH */
/* Experiment#1 - flash is on, lock is free; aquire lock and read
* without using any SEEK function */
dev_open(DEV_TELOS_FLASH);
count = dev_read(DEV_TELOS_FLASH, buffer, 1);
printf("#1 : %c has been read from FLASH memory\n", buffer[0]);
dev_close(DEV_TELOS_FLASH);
/* Move pointer */
dev_open(DEV_TELOS_FLASH);
dev_ioctl(DEV_TELOS_FLASH, DEV_SEEK, 3);
dev_close(DEV_TELOS_FLASH);
/* Experiment#2 - flash is on, lock is free; aquire lock, read single data,
* write single data and read multiple data from it */
dev_open(DEV_TELOS_FLASH);
dev_read(DEV_TELOS_FLASH, buffer, 1);
printf("#2 : %c has been read\n"
" : FLASH memory written\n", buffer[0]);
dev_write(DEV_TELOS_FLASH, "l", 1);
count = dev_read(DEV_TELOS_FLASH, buffer, 1);
printf(" : %d bytes have been read from FLASH memory: ", count);
for(index = 0; index < count; index++)
{
printf("%c ", buffer[index]);
}
printf("\n");
dev_close(DEV_TELOS_FLASH);
/* Release lock and free resources */
dev_close(DEV_TELOS_FLASH);
dev_mode(DEV_TELOS_FLASH, DEV_MODE_OFF);
mos_mem_free(buffer);
return;
}
开发者ID:135u5,项目名称:dynamiclinker,代码行数:58,代码来源:dev_test.c
示例2: vnet_dev_add
/** Add the interface (net device) for a vnet.
* Sets the dev field of the vnet on success.
* Does nothing if the vnet already has an interface.
*
* @param vnet vnet
* @return 0 on success, error code otherwise
*/
int vnet_dev_add(Vnet *vnet){
int err = 0;
struct net_device *dev = NULL;
if(vnet->dev) goto exit;
vnet->header_n = ETH_HLEN + sizeof(struct iphdr) + sizeof(struct etheriphdr);
if(etherip_in_udp){
vnet->header_n += sizeof(struct VnetMsgHdr);
vnet->header_n += sizeof(struct udphdr);
}
vnet->header_n = roundupto(vnet->header_n, 4);
dev = alloc_netdev(0, vnet->device, vnet_dev_init);
if(!dev){
err = -ENOMEM;
goto exit;
}
err = vnet_dev_setup(vnet, dev);
if(err) goto exit;
rtnl_lock();
dev_open(dev);
rtnl_unlock();
exit:
return err;
}
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:32,代码来源:vnet_dev.c
示例3: ota_check
BOOL ota_check(void)
{
ota_bl_info_t bl_info = {0};
charsto_cfg_t charsto_cfg = {0};
void *p_dev = NULL;
RET_CODE ret = ERR_FAILURE;
/******char storage init******/
ret = ATTACH_DRIVER(CHARSTO, warriors, default, default);
MT_ASSERT(ret == SUCCESS);
p_dev = dev_find_identifier(NULL, DEV_IDT_TYPE, SYS_DEV_TYPE_CHARSTO);
MT_ASSERT(NULL != p_dev);
charsto_cfg.size = CHARSTO_SIZE; //4
charsto_cfg.spi_clk = FLASH_C_CLK_P6;
charsto_cfg.rd_mode = SPI_FR_MODE;
//charsto_cfg.multi_io_rd = 1;
//charsto_cfg.multi_io_wd = 1;
ret = dev_open(p_dev, &charsto_cfg);
MT_ASSERT(ret == SUCCESS);
/* open uio */
uio_init();
mtos_task_delay_ms(M_TASK_DELAY_TIME);
if(mul_ota_dm_api_check_intact_picec(OTA_DM_BLOCK_PIECE_OTA_BLINFO_ID) == FALSE)
{
ui_ota_api_bootload_info_init();
}
mul_ota_dm_api_read_bootload_info(&bl_info);
OS_PRINTF("\r\n[OTA]%s:ota_tri[%d] ",__FUNCTION__, bl_info.ota_status);
/* flash burning is not finished, force ota*/
if( bl_info.destroy_flag == TRUE)
{
bl_info.ota_status = OTA_TRI_MODE_FORC;
mul_ota_dm_api_save_bootload_info(&bl_info);
return TRUE;
}
if(is_force_key_press())
{
bl_info.ota_status = OTA_TRI_MODE_AUTO;
mul_ota_dm_api_save_bootload_info(&bl_info);
return TRUE;
}
if((bl_info.ota_status == OTA_TRI_MODE_AUTO)
||(bl_info.ota_status == OTA_TRI_MODE_FORC))
{
return TRUE;
}
return FALSE;
}
开发者ID:github188,项目名称:CC6000M_LQ_V3.1_DSCA5.2,代码行数:60,代码来源:main.c
示例4: alloc_netdev
static struct net_device *ipmr_reg_vif(void)
{
struct net_device *dev;
struct in_device *in_dev;
dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
reg_vif_setup);
if (dev == NULL)
return NULL;
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if ((in_dev = inetdev_init(dev)) == NULL)
goto failure;
in_dev->cnf.rp_filter = 0;
if (dev_open(dev))
goto failure;
return dev;
failure:
unregister_netdevice(dev);
return NULL;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:31,代码来源:ipmr.c
示例5: open_network_devices
/*****************************************************************************
* Open the "real" network devices. Return the number of opened interfaces.
*****************************************************************************/
int open_network_devices(int promisc)
{
struct net_device *dev;
struct net *net;
int err = 0, cnt = 0;
DEBUG(ANKH_DEBUG_INIT, "%s() \n", __func__);
for_each_net(net) {
for_each_netdev(net, dev)
{
DEBUG(ANKH_DEBUG_INIT, "opening %s\n", dev->name);
// beam us to promiscuous mode, so that we can receive packets that
// are not meant for the NIC's MAC address --> we need that, because
// ORe clients have different MAC addresses
if (promisc && netdev_set_promisc(dev) == 0)
DEBUG(ANKH_DEBUG_INIT, "set interface to promiscuous mode.\n");
err = dev_open(dev);
if (err)
{
DEBUG(ANKH_DEBUG_INIT, "error opening %s : %d\n", dev->name, err);
return err;
}
else // success
netdev_add(dev);
cnt++;
//xmit_lock_add(dev->name);
}
}
开发者ID:KyulingLee,项目名称:L4Re,代码行数:35,代码来源:linux_glue.c
示例6: alloc_netdev
static struct net_device *ip6mr_reg_vif(struct net *net)
{
struct net_device *dev;
dev = alloc_netdev(0, "pim6reg", reg_vif_setup);
if (dev == NULL)
return NULL;
dev_net_set(dev, net);
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if (dev_open(dev))
goto failure;
dev_hold(dev);
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:30,代码来源:ip6mr.c
示例7: label_verify
/* Unused */
int label_verify(struct device *dev)
{
#pragma pack(8)
char buf[LABEL_SIZE];
#pragma pack()
struct labeller *l;
//char buf[LABEL_SIZE] __attribute((aligned(8)));
uint64_t sector;
struct lvmcache_info *info;
int r = 0;
if (!dev_open(dev)) {
if ((info = info_from_pvid(dev->pvid)))
lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
0, NULL);
return_0;
}
if (!(l = _find_labeller(dev, buf, §or, UINT64_C(0))))
goto_out;
r = l->ops->verify ? l->ops->verify(l, buf, sector) : 1;
out:
if (!dev_close(dev))
stack;
return r;
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:31,代码来源:label.c
示例8: alloc_netdev
static struct net_device *ipmr_reg_vif(void)
{
struct net_device *dev;
struct in_device *in_dev;
dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
reg_vif_setup);
if (dev == NULL)
return NULL;
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if ((in_dev = inetdev_init(dev)) == NULL)
goto failure;
in_dev->cnf.rp_filter = 0;
if (dev_open(dev))
goto failure;
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:35,代码来源:ipmr.c
示例9: rds
void rds(char *arg)
{
int c;
char *val, err[0xff];
struct pcimaxfm_rds_set rds_set;
while (*arg != '\0') {
if ((c = (getsubopt(&arg, rds_params_name, &val))) == -1)
ERROR_MSG("Invalid RDS parameter \"%s\".", val);
if (validate_rds(c, val, sizeof(err), err)) {
ERROR_MSG("%s", err);
}
dev_open();
rds_set.param = c;
rds_set.value = val;
if(ioctl(fd, PCIMAXFM_RDS_SET, &rds_set) == -1) {
ERROR_MSG("Writing RDS parameter %s = \"%s\" failed.",
rds_params_name[rds_set.param],
rds_set.value);
}
NOTICE_MSG("RDS: %-4s = \"%s\"",
rds_params_name[rds_set.param], rds_set.value);
}
}
开发者ID:dterweij,项目名称:pcimaxfm,代码行数:29,代码来源:pcimaxctl.c
示例10: power
void power(const char *arg)
{
int power;
dev_open();
if (arg) {
if (sscanf(arg, "%u", &power) < 1) {
ERROR_MSG("Invalid power level. Got \"%s\", expected integer in the range of %d-%d.", arg, PCIMAXFM_POWER_MIN, PCIMAXFM_POWER_MAX);
}
if (power < PCIMAXFM_POWER_MIN || power > PCIMAXFM_POWER_MAX) {
ERROR_MSG("Power level out of range. Got %d, expected %d-%d.", power, PCIMAXFM_POWER_MIN, PCIMAXFM_POWER_MAX);
}
if (ioctl(fd, PCIMAXFM_POWER_SET, &power) == -1) {
ERROR_MSG("Setting power level failed.");
}
} else {
if (ioctl(fd, PCIMAXFM_POWER_GET, &power) == -1) {
ERROR_MSG("Reading power level failed.");
}
if (power == PCIMAXFM_POWER_NA) {
NOTICE_MSG("Power level not set yet.");
return;
}
}
NOTICE_MSG("Power level: %d/%d", power, PCIMAXFM_POWER_MAX);
}
开发者ID:dterweij,项目名称:pcimaxfm,代码行数:30,代码来源:pcimaxctl.c
示例11: main
int main (void)
{
unsigned int mainkey;
char buf[128] = {0,};
printf("Program Start...\n");
dev_fd = dev_open("/dev/webconn", WEBCONN_MAJOR, 0);
write(dev_fd, "khkrai", 128);
read(dev_fd, &buf, 128);
printf("\n\nbuf=%s\n", buf);
printf("%x\n", IOCTL_WRITE);
printf("%x\n", IOCTL_READ);
ioctl(dev_fd, IOCTL_WRITE, 1);
ioctl(dev_fd, IOCTL_READ, 0);
close(dev_fd);
return 0;
}
开发者ID:webconnme,项目名称:wc-s,代码行数:26,代码来源:main.c
示例12: check_open_hook
/* Called whenever someone tries to open our node (even for a stat). We
delay opening the kernel device until this point, as we can usefully
return errors from here. */
static error_t
check_open_hook (struct trivfs_control *trivfs_control,
struct iouser *user,
int flags)
{
struct dev *const dev = trivfs_control->hook;
error_t err = 0;
if (!err && dev_is_readonly (dev) && (flags & O_WRITE))
return EROFS;
mutex_lock (&dev->lock);
if (dev->store == NULL)
{
/* Try and open the store. */
err = dev_open (dev);
if (err && (flags & (O_READ|O_WRITE)) == 0)
/* If we're not opening for read or write, then just ignore the
error, as this allows stat to work correctly. XXX */
err = 0;
}
mutex_unlock (&dev->lock);
return err;
}
开发者ID:diegonc,项目名称:console-xkb-support,代码行数:28,代码来源:storeio.c
示例13: __dev_get_by_name
static
struct net_device *ipmr_new_tunnel(struct net *net, struct vifctl *v)
{
struct net_device *dev;
dev = __dev_get_by_name(net, "tunl0");
if (dev) {
const struct net_device_ops *ops = dev->netdev_ops;
int err;
struct ifreq ifr;
struct ip_tunnel_parm p;
struct in_device *in_dev;
memset(&p, 0, sizeof(p));
p.iph.daddr = v->vifc_rmt_addr.s_addr;
p.iph.saddr = v->vifc_lcl_addr.s_addr;
p.iph.version = 4;
p.iph.ihl = 5;
p.iph.protocol = IPPROTO_IPIP;
sprintf(p.name, "dvmrp%d", v->vifc_vifi);
ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
if (ops->ndo_do_ioctl) {
mm_segment_t oldfs = get_fs();
set_fs(KERNEL_DS);
err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
set_fs(oldfs);
} else
err = -EOPNOTSUPP;
dev = NULL;
if (err == 0 &&
(dev = __dev_get_by_name(net, p.name)) != NULL) {
dev->flags |= IFF_MULTICAST;
in_dev = __in_dev_get_rtnl(dev);
if (in_dev == NULL)
goto failure;
ipv4_devconf_setall(in_dev);
IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0;
if (dev_open(dev))
goto failure;
dev_hold(dev);
}
}
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
开发者ID:mfleming,项目名称:linux-2.6,代码行数:60,代码来源:ipmr.c
示例14: install_drivers
void install_drivers() {
dev_t console;
// Register /proc/units
register_proc_inode("units", units_proc, NULL);
register_proc_inode("devices", devices_proc, NULL);
register_proc_inode("devstat", devstat_proc, NULL);
// Parse driver binding database
parse_bindings();
// Match bindings to units
bind_units();
// Install legacy drivers
install_legacy_drivers();
// Make sure we have a console device
console = dev_open("console");
if (console == NODEV) {
initialize_driver(NULL, "krnl.dll!console");
} else {
dev_close(console);
}
}
开发者ID:HarryR,项目名称:sanos,代码行数:25,代码来源:dev.c
示例15: label_read
/* FIXME Avoid repeated re-reading if cache lock held */
int label_read(struct device *dev, struct label **result,
uint64_t scan_sector)
{
#pragma pack(8)
char buf[LABEL_SIZE]; //__attribute((aligned(8)));
#pragma pack()
struct labeller *l;
uint64_t sector;
struct lvmcache_info *info;
int r = 0;
if (!dev_open(dev)) {
stack;
if ((info = info_from_pvid(dev->pvid)))
lvmcache_update_vgname_and_id(info, ORPHAN, ORPHAN,
0, NULL);
return r;
}
if (!(l = _find_labeller(dev, buf, §or, scan_sector)))
goto_out;
if ((r = (l->ops->read)(l, dev, buf, result)) && result && *result)
(*result)->sector = sector;
out:
if (!dev_close(dev))
stack;
return r;
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:34,代码来源:label.c
示例16: dev_open
int DeviceV4L2Base::open_dev(int color_model)
{
v4l2_lock->lock("DeviceV4L2Base::open_dev");
int result = 0;
if( !opened )
{
result = dev_open();
if( !result )
result = v4l2_open(color_model);
if( !result )
result = start_dev();
if( !result )
{
qbfrs_lock->reset();
video_lock->reset();
getq = new DeviceV4L2BufferQ(total_buffers+1);
put_thread = new DeviceV4L2Put(this);
put_thread->start();
done = 0;
Thread::start();
}
else
printf("DeviceV4L2Base::open_dev failed\n");
}
if( result )
{
printf("DeviceV4L2Base::open_dev: adaptor open failed\n");
stop_dev();
dev_close();
}
else
opened = 1;
v4l2_lock->unlock();
return result;
}
开发者ID:Cuchulain,项目名称:cinelerra,代码行数:35,代码来源:devicev4l2base.C
示例17: dev_open
struct netif *ether_netif_add(char *name, char *devname, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw) {
struct netif *netif;
struct dhcp_state *state;
dev_t devno;
// Open device
devno = dev_open(devname);
if (devno == NODEV) return NULL;
if (device(devno)->driver->type != DEV_TYPE_PACKET) return NULL;
// Attach device to network interface
netif = netif_add(name, ipaddr, netmask, gw);
if (!netif) return NULL;
netif->output = ether_output;
netif->state = (void *) devno;
dev_attach(devno, netif, ether_input);
// Obtain network parameters using DHCP
if (ip_addr_isany(ipaddr)) {
state = dhcp_start(netif);
if (state) {
if (wait_for_object(&state->binding_complete, 30000) < 0) {
kprintf(KERN_WARNING "ether: timeout waiting for dhcp to complete on %s\n", name);
}
}
}
kprintf(KERN_INFO "%s: device %s addr %a mask %a gw %a\n", name, devname, &netif->ipaddr, &netif->netmask, &netif->gw);
return netif;
}
开发者ID:HarryR,项目名称:sanos,代码行数:33,代码来源:ether.c
示例18: _dev_read_ahead_dev
static int _dev_read_ahead_dev(struct device *dev, uint32_t *read_ahead)
{
long read_ahead_long;
if (dev->read_ahead != -1) {
*read_ahead = (uint32_t) dev->read_ahead;
return 1;
}
if (!dev_open(dev))
return_0;
if (ioctl(dev->fd, BLKRAGET, &read_ahead_long) < 0) {
log_sys_error("ioctl BLKRAGET", dev_name(dev));
if (!dev_close(dev))
stack;
return 0;
}
if (!dev_close(dev))
stack;
*read_ahead = (uint32_t) read_ahead_long;
dev->read_ahead = read_ahead_long;
log_very_verbose("%s: read_ahead is %u sectors",
dev_name(dev), *read_ahead);
return 1;
}
开发者ID:Orwel,项目名称:forester,代码行数:30,代码来源:dev-io-orig.c
示例19: fork_worker
static void fork_worker(struct init_action *a)
{
int fd;
pid_t p;
a->proc.pid = fork();
if (!a->proc.pid) {
p = setsid();
fd = dev_open(a->id);
if (fd != -1)
{
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO)
close(fd);
}
ioctl(STDIN_FILENO, TIOCSCTTY, 1);
tcsetpgrp(STDIN_FILENO, p);
execvp(a->argv[0], a->argv);
ERROR("Failed to execute %s\n", a->argv[0]);
exit(-1);
}
if (a->proc.pid > 0) {
DEBUG(4, "Launched new %s action, pid=%d\n",
a->handler->name,
(int) a->proc.pid);
uloop_process_add(&a->proc);
}
}
开发者ID:unixz,项目名称:procd,代码行数:34,代码来源:inittab.c
示例20: _dev_discard_blocks
static int _dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64_t size_bytes)
{
uint64_t discard_range[2];
if (!dev_open(dev))
return_0;
discard_range[0] = offset_bytes;
discard_range[1] = size_bytes;
log_debug_devs("Discarding %" PRIu64 " bytes offset %" PRIu64 " bytes on %s.",
size_bytes, offset_bytes, dev_name(dev));
if (ioctl(dev->fd, BLKDISCARD, &discard_range) < 0) {
log_error("%s: BLKDISCARD ioctl at offset %" PRIu64 " size %" PRIu64 " failed: %s.",
dev_name(dev), offset_bytes, size_bytes, strerror(errno));
if (!dev_close(dev))
stack;
/* It doesn't matter if discard failed, so return success. */
return 1;
}
if (!dev_close(dev))
stack;
return 1;
}
开发者ID:Find7s,项目名称:Lvm_for_Android,代码行数:26,代码来源:dev-io.c
注:本文中的dev_open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论