本文整理汇总了C++中DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ DBG函数的具体用法?C++ DBG怎么用?C++ DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mt_usb_set_vbus
void mt_usb_set_vbus(struct musb *musb, int is_on)
{
DBG(0, "mt65xx_usb20_vbus++,is_on=%d\r\n", is_on);
#ifndef FPGA_PLATFORM
if (is_on) {
/* power on VBUS, implement later... */
#ifdef CONFIG_MTK_FAN5405_SUPPORT
fan5405_set_opa_mode(1);
fan5405_set_otg_pl(1);
fan5405_set_otg_en(1);
#elif defined(CONFIG_MTK_BQ24261_SUPPORT)
bq24261_set_en_boost(1);
#elif defined(CONFIG_MTK_BQ24296_SUPPORT)
bq24296_set_otg_config(0x1); /* OTG */
bq24296_set_boostv(0x7); /* boost voltage 4.998V */
bq24296_set_boost_lim(0x1); /* 1.5A on VBUS */
bq24296_set_en_hiz(0x0);
#elif defined(CONFIG_MTK_BQ24196_SUPPORT)
bq24196_set_otg_config(0x01); /* OTG */
bq24196_set_boost_lim(0x01); /* 1.3A on VBUS */
#elif defined(CONFIG_MTK_NCP1854_SUPPORT)
ncp1854_set_otg_en(0);
ncp1854_set_chg_en(0);
ncp1854_set_otg_en(1);
#else
#ifdef CONFIG_OF
#if defined(CONFIG_MTK_LEGACY)
mt_set_gpio_mode(drvvbus_pin, drvvbus_pin_mode);
mt_set_gpio_out(drvvbus_pin, GPIO_OUT_ONE);
#else
pr_debug("****%s:%d Drive VBUS HIGH KS!!!!!\n", __func__, __LINE__);
pinctrl_select_state(pinctrl, pinctrl_drvvbus_high);
#endif
#else
mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN, GPIO_OTG_DRVVBUS_PIN_M_GPIO);
mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ONE);
#endif
#endif
} else {
/* power off VBUS, implement later... */
#ifdef CONFIG_MTK_FAN5405_SUPPORT
fan5405_reg_config_interface(0x01, 0x30);
fan5405_reg_config_interface(0x02, 0x8e);
#elif defined(CONFIG_MTK_BQ24261_SUPPORT)
bq24261_set_en_boost(0);
#elif defined(CONFIG_MTK_BQ24296_SUPPORT)
bq24296_set_otg_config(0);
#elif defined(CONFIG_MTK_BQ24196_SUPPORT)
bq24196_set_otg_config(0x0); /* OTG disabled */
#elif defined(CONFIG_MTK_NCP1854_SUPPORT)
ncp1854_set_otg_en(0x0);
#else
#ifdef CONFIG_OF
#if defined(CONFIG_MTK_LEGACY)
mt_set_gpio_mode(drvvbus_pin, drvvbus_pin_mode);
mt_set_gpio_out(drvvbus_pin, GPIO_OUT_ZERO);
#else
pr_debug("****%s:%d Drive VBUS LOW KS!!!!!\n", __func__, __LINE__);
pinctrl_select_state(pinctrl, pinctrl_drvvbus_low);
#endif
#else
mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN, GPIO_OTG_DRVVBUS_PIN_M_GPIO);
mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ZERO);
#endif
#endif
}
#endif
}
示例2: cleanup_devices
static void cleanup_devices(void)
{
/*
* Check what interfaces are currently up and if connman is
* suppose to handle the interface, then cleanup the mess
* related to that interface. There might be weird routes etc
* that are related to that interface and that might confuse
* connmand. So in this case we just turn the interface down
* so that kernel removes routes/addresses automatically and
* then proceed the startup.
*
* Note that this cleanup must be done before rtnl/detect code
* has activated interface watches.
*/
char **interfaces;
int i;
interfaces = __connman_inet_get_running_interfaces();
if (!interfaces)
return;
for (i = 0; interfaces[i]; i++) {
bool filtered;
int index;
struct sockaddr_in sin_addr, sin_mask;
filtered = __connman_device_isfiltered(interfaces[i]);
if (filtered)
continue;
index = connman_inet_ifindex(interfaces[i]);
if (index < 0)
continue;
if (!__connman_inet_get_address_netmask(index, &sin_addr,
&sin_mask)) {
char *address = g_strdup(inet_ntoa(sin_addr.sin_addr));
char *netmask = g_strdup(inet_ntoa(sin_mask.sin_addr));
if (__connman_config_address_provisioned(address,
netmask)) {
DBG("Skip %s which is already provisioned "
"with %s/%s", interfaces[i], address,
netmask);
g_free(address);
g_free(netmask);
continue;
}
g_free(address);
g_free(netmask);
}
DBG("cleaning up %s index %d", interfaces[i], index);
connman_inet_ifdown(index);
/*
* ConnMan will turn the interface UP automatically so
* no need to do it here.
*/
}
g_strfreev(interfaces);
}
示例3: dns_resolv
/**
* Resolve name using DNS
*
* @v resolv Name resolution interface
* @v name Name to resolve
* @v sa Socket address to fill in
* @ret rc Return status code
*/
static int dns_resolv ( struct resolv_interface *resolv,
const char *name, struct sockaddr *sa ) {
struct dns_request *dns;
char *fqdn;
int rc;
/* Fail immediately if no DNS servers */
if ( ! nameserver.st_family ) {
DBG ( "DNS not attempting to resolve \"%s\": "
"no DNS servers\n", name );
rc = -ENXIO;
goto err_no_nameserver;
}
/* Ensure fully-qualified domain name if DHCP option was given */
fqdn = dns_qualify_name ( name );
if ( ! fqdn ) {
rc = -ENOMEM;
goto err_qualify_name;
}
/* Allocate DNS structure */
dns = zalloc ( sizeof ( *dns ) );
if ( ! dns ) {
rc = -ENOMEM;
goto err_alloc_dns;
}
ref_init ( &dns->refcnt, NULL );
resolv_init ( &dns->resolv, &null_resolv_ops, &dns->refcnt );
xfer_init ( &dns->socket, &dns_socket_operations, &dns->refcnt );
timer_init ( &dns->timer, dns_timer_expired );
memcpy ( &dns->sa, sa, sizeof ( dns->sa ) );
/* Create query */
dns->query.dns.flags = htons ( DNS_FLAG_QUERY | DNS_FLAG_OPCODE_QUERY |
DNS_FLAG_RD );
dns->query.dns.qdcount = htons ( 1 );
dns->qinfo = ( void * ) dns_make_name ( fqdn, dns->query.payload );
dns->qinfo->qtype = htons ( DNS_TYPE_A );
dns->qinfo->qclass = htons ( DNS_CLASS_IN );
/* Open UDP connection */
if ( ( rc = xfer_open_socket ( &dns->socket, SOCK_DGRAM,
( struct sockaddr * ) &nameserver,
NULL ) ) != 0 ) {
DBGC ( dns, "DNS %p could not open socket: %s\n",
dns, strerror ( rc ) );
goto err_open_socket;
}
/* Send first DNS packet */
dns_send_packet ( dns );
/* Attach parent interface, mortalise self, and return */
resolv_plug_plug ( &dns->resolv, resolv );
ref_put ( &dns->refcnt );
free ( fqdn );
return 0;
err_open_socket:
err_alloc_dns:
ref_put ( &dns->refcnt );
err_qualify_name:
free ( fqdn );
err_no_nameserver:
return rc;
}
示例4: print_fixup_f_2
static int print_fixup_f_2(void **param, int param_no) {
DBG("print: print_fixup_f_2('%s')\n", (char*)*param);
return print_fixup_f(param, param_no);
}
示例5: recv_handler
static int8 recv_handler(void)
{
uint8 *cur, *end;
uint8 recv_ip[4], opt_len, msg_type;
int32 recv_len;
uint16 recv_port;
recv_len = GetSocketRxRecvBufferSize(di.sock);
if(recv_len == 0) return RET_NOK;
else memset(&dm, 0, sizeof(struct dhcp_msg));
recv_len = UDPRecv(di.sock, (int8*)&dm, sizeof(struct dhcp_msg), recv_ip, &recv_port);
if(recv_len < 0) {
ERRA("UDPRecv fail - ret(%d)", recv_len);
return RET_NOK;
}
DBGA("DHCP_SIP:%d.%d.%d.%d",di.srv_ip[0],di.srv_ip[1],di.srv_ip[2],di.srv_ip[3]);
DBGA("DHCP_RIP:%d.%d.%d.%d",di.srv_ip_real[0],di.srv_ip_real[1],di.srv_ip_real[2],di.srv_ip_real[3]);
DBGA("recv_ip:%d.%d.%d.%d",recv_ip[0],recv_ip[1],recv_ip[2],recv_ip[3]);
if(dm.op != DHCP_BOOTREPLY || recv_port != DHCP_SERVER_PORT) {
if(dm.op != DHCP_BOOTREPLY) DBG("DHCP : NO DHCP MSG");
if(recv_port != DHCP_SERVER_PORT) DBG("DHCP : WRONG PORT");
return RET_NOK;
}
if(memcmp(dm.chaddr, storage.Mac, 6) != 0 || dm.xid != htonl(di.xid)) {
DBG("No My DHCP Message. This message is ignored.");
DBGA("SRC_MAC_ADDR(%02X:%02X:%02X:%02X:%02X:%02X)",
storage.Mac[0], storage.Mac[1], storage.Mac[2],
storage.Mac[3], storage.Mac[4], storage.Mac[5]);
DBGA("chaddr(%02X:%02X:%02X:%02X:%02X:%02X)", dm.chaddr[0],
dm.chaddr[1], dm.chaddr[2], dm.chaddr[3], dm.chaddr[4], dm.chaddr[5]);
DBGA("DHCP_XID(%08lX), xid(%08lX), yiaddr(%d.%d.%d.%d)", htonl(di.xid),
dm.xid, dm.yiaddr[0], dm.yiaddr[1], dm.yiaddr[2], dm.yiaddr[3]);
return RET_NOK;
}
if( *((uint32*)di.srv_ip) != 0x00000000 ) {
if( *((uint32*)di.srv_ip_real) != *((uint32*)recv_ip) &&
*((uint32*)di.srv_ip) != *((uint32*)recv_ip) ) {
DBG("Another DHCP sever send a response message. This is ignored.");
DBGA("IP:%d.%d.%d.%d",recv_ip[0],recv_ip[1],recv_ip[2],recv_ip[3]);
return RET_NOK;
}
}
memcpy(workinfo.IP, dm.yiaddr, 4);
DBG("DHCP MSG received..");
DBGA("yiaddr : %d.%d.%d.%d",workinfo.IP[0],workinfo.IP[1],workinfo.IP[2],workinfo.IP[3]);
msg_type = 0;
cur = (uint8 *)(&dm.op);
cur = cur + 240;
end = cur + (recv_len - 240); //printf("cur : 0x%08X end : 0x%08X recv_len : %d\r\n", cur, end, recv_len);
while ( cur < end )
{
switch ( *cur++ )
{
case padOption:
break;
case endOption:
return msg_type;
case dhcpMessageType:
opt_len = *cur++;
msg_type = *cur;
DBGA("dhcpMessageType : %x", msg_type);
break;
case subnetMask:
opt_len =* cur++;
memcpy(workinfo.SN,cur,4);
DBGA("subnetMask : %d.%d.%d.%d",
workinfo.SN[0],workinfo.SN[1],workinfo.SN[2],workinfo.SN[3]);
break;
case routersOnSubnet:
opt_len = *cur++;
memcpy(workinfo.GW,cur,4);
DBGA("routersOnSubnet : %d.%d.%d.%d",
workinfo.GW[0],workinfo.GW[1],workinfo.GW[2],workinfo.GW[3]);
break;
case dns:
opt_len = *cur++;
memcpy(workinfo.DNS,cur,4);
break;
case dhcpIPaddrLeaseTime:
opt_len = *cur++;
di.lease_time = ntohl(*((uint32*)cur));
di.renew_time = di.lease_time / 2; // 0.5
di.rebind_time = di.lease_time / 8 * 7; // 0.875
DBGA("lease(%d), renew(%d), rebind(%d)", di.lease_time, di.renew_time, di.rebind_time);
break;
case dhcpServerIdentifier:
opt_len = *cur++;
DBGA("DHCP_SIP : %d.%d.%d.%d", di.srv_ip[0], di.srv_ip[1], di.srv_ip[2], di.srv_ip[3]);
if( *((uint32*)di.srv_ip) == 0 || *((uint32*)di.srv_ip_real) == *((uint32*)recv_ip) ||
*((uint32*)di.srv_ip) == *((uint32*)recv_ip) ) {
memcpy(di.srv_ip,cur,4);
memcpy(di.srv_ip_real,recv_ip,4); // Copy the real ip address of my DHCP server
DBGA("My dhcpServerIdentifier : %d.%d.%d.%d",
//.........这里部分代码省略.........
示例6: etna_screen_get_timestamp
static uint64_t etna_screen_get_timestamp(struct pipe_screen *screen)
{
DBG("unimplemented etna_screen_get_timestamp");
return 0;
}
示例7: hatm_ioctl
/*
* IOCTL handler
*/
int
hatm_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
struct ifreq *ifr = (struct ifreq *)data;
struct ifaddr *ifa = (struct ifaddr *)data;
struct hatm_softc *sc = ifp->if_softc;
struct atmio_vcctable *vtab;
int error = 0;
switch (cmd) {
case SIOCSIFADDR:
mtx_lock(&sc->mtx);
ifp->if_flags |= IFF_UP;
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
hatm_initialize(sc);
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
case AF_INET6:
ifa->ifa_rtrequest = atm_rtrequest;
break;
#endif
default:
break;
}
mtx_unlock(&sc->mtx);
break;
case SIOCSIFFLAGS:
mtx_lock(&sc->mtx);
if (ifp->if_flags & IFF_UP) {
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
hatm_initialize(sc);
}
} else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
hatm_stop(sc);
}
}
mtx_unlock(&sc->mtx);
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd);
break;
case SIOCSIFMTU:
/*
* Set the interface MTU.
*/
if (ifr->ifr_mtu > ATMMTU)
error = EINVAL;
else
ifp->if_mtu = ifr->ifr_mtu;
break;
case SIOCATMGVCCS:
/* return vcc table */
vtab = atm_getvccs((struct atmio_vcc **)sc->vccs,
HE_MAX_VCCS, sc->open_vccs, &sc->mtx, 1);
error = copyout(vtab, ifr->ifr_data, sizeof(*vtab) +
vtab->count * sizeof(vtab->vccs[0]));
free(vtab, M_DEVBUF);
break;
case SIOCATMGETVCCS: /* netgraph internal use */
vtab = atm_getvccs((struct atmio_vcc **)sc->vccs,
HE_MAX_VCCS, sc->open_vccs, &sc->mtx, 0);
if (vtab == NULL) {
error = ENOMEM;
break;
}
*(void **)data = vtab;
break;
case SIOCATMOPENVCC: /* kernel internal use */
error = hatm_open_vcc(sc, (struct atmio_openvcc *)data);
break;
case SIOCATMCLOSEVCC: /* kernel internal use */
error = hatm_close_vcc(sc, (struct atmio_closevcc *)data);
break;
default:
DBG(sc, IOCTL, ("cmd=%08lx arg=%p", cmd, data));
error = EINVAL;
break;
}
return (error);
}
示例8: hatm_open_vcc
/*
* Try to open the given VCC.
*/
static int
hatm_open_vcc(struct hatm_softc *sc, struct atmio_openvcc *arg)
{
u_int cid;
struct hevcc *vcc;
int error = 0;
DBG(sc, VCC, ("Open VCC: %u.%u flags=%#x", arg->param.vpi,
arg->param.vci, arg->param.flags));
if ((arg->param.vpi & ~HE_VPI_MASK) ||
(arg->param.vci & ~HE_VCI_MASK) ||
(arg->param.vci == 0))
return (EINVAL);
cid = HE_CID(arg->param.vpi, arg->param.vci);
if ((arg->param.flags & ATMIO_FLAG_NOTX) &&
(arg->param.flags & ATMIO_FLAG_NORX))
return (EINVAL);
vcc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO);
if (vcc == NULL)
return (ENOMEM);
mtx_lock(&sc->mtx);
if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) {
error = EIO;
goto done;
}
if (sc->vccs[cid] != NULL) {
error = EBUSY;
goto done;
}
vcc->param = arg->param;
vcc->rxhand = arg->rxhand;
switch (vcc->param.aal) {
case ATMIO_AAL_0:
case ATMIO_AAL_5:
case ATMIO_AAL_RAW:
break;
default:
error = EINVAL;
goto done;
}
switch (vcc->param.traffic) {
case ATMIO_TRAFFIC_UBR:
case ATMIO_TRAFFIC_CBR:
case ATMIO_TRAFFIC_ABR:
break;
default:
error = EINVAL;
goto done;
}
vcc->ntpds = 0;
vcc->chain = vcc->last = NULL;
vcc->ibytes = vcc->ipackets = 0;
vcc->obytes = vcc->opackets = 0;
if (!(vcc->param.flags & ATMIO_FLAG_NOTX) &&
(error = hatm_tx_vcc_can_open(sc, cid, vcc)) != 0)
goto done;
/* ok - go ahead */
sc->vccs[cid] = vcc;
hatm_load_vc(sc, cid, 0);
/* don't free below */
vcc = NULL;
sc->open_vccs++;
done:
mtx_unlock(&sc->mtx);
if (vcc != NULL)
uma_zfree(sc->vcc_zone, vcc);
return (error);
}
示例9: headset_interrupt
//1
static irqreturn_t headset_interrupt(int irq, void *dev_id)
{
struct rk_headset_pdata *pdata = headset_info->pdata;
static unsigned int old_status = 0;
int i,level = 0;
int adc_value = 0;
wake_lock(&headset_info->headset_on_wake);
if(headset_info->heatset_irq_working == BUSY || headset_info->heatset_irq_working == WAIT)
return IRQ_HANDLED;
DBG("In the headset_interrupt for read headset level wake_lock headset_on_wake\n");
headset_info->heatset_irq_working = BUSY;
msleep(150);
for(i=0; i<3; i++)
{
level = gpio_get_value(pdata->Headset_gpio);
if(level < 0)
{
printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,pdata->Headset_gpio,i);
msleep(1);
continue;
}
else
break;
}
if(level < 0)
{
printk("%s:get pin level err!\n",__FUNCTION__);
goto out;
}
old_status = headset_info->headset_status;
switch(pdata->headset_in_type)
{
case HEADSET_IN_HIGH:
if(level > 0)
headset_info->headset_status = HEADSET_IN;
else if(level == 0)
headset_info->headset_status = HEADSET_OUT;
break;
case HEADSET_IN_LOW:
if(level == 0)
headset_info->headset_status = HEADSET_IN;
else if(level > 0)
headset_info->headset_status = HEADSET_OUT;
break;
default:
DBG("---- ERROR: on headset headset_in_type error -----\n");
break;
}
if(old_status == headset_info->headset_status)
{
DBG("Read Headset IO level old status == now status\n");
goto out;
}
DBG("(headset in is %s)headset status is %s\n",
pdata->headset_in_type?"high level":"low level",
headset_info->headset_status?"in":"out");
if(headset_info->headset_status == HEADSET_IN)
{
#if 0
while(1)
{
if(adc_sync_read(headset_info->client) > HOOK_DEFAULT_VAL
|| adc_sync_read(headset_info->client) < 0)
{
printk("headset is showly inside\n");
}
else
break;
msleep(50);
if(pdata->headset_in_type == HEADSET_IN_HIGH)
old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_IN:HEADSET_OUT;
else
old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_OUT:HEADSET_IN;
if(headset_info->headset_status == HEADSET_OUT)
goto out1;
msleep(5);
}
#endif
if(pdata->Hook_adc_chn>=0 && 3>=pdata->Hook_adc_chn)
{
// wait for find Hook key
//#ifdef CONFIG_SND_SOC_RT5625
CHECK_AGAIN:
//headset_info->isMic = rt5625_headset_mic_detect(true);
#ifdef CONFIG_SND_SOC_WM8994
wm8994_headset_mic_detect(true);
#endif
#if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
rt3261_headset_mic_detect(true);
#endif
#ifdef CONFIG_SND_SOC_RT5631_PHONE
rt5631_headset_mic_detect(true);
#endif
//mdelay(400);
adc_value = adc_sync_read(headset_info->client);
if(adc_value >= 0 && adc_value < HOOK_LEVEL_LOW)
//.........这里部分代码省略.........
示例10: DBG
void SMPTE::SampleToTime()
{
//
// make a temporary copy of the sample number
//
ulong tmp_sample = sample_number;
//
// keep track of the actual rates in use in doubles.
//
double the_smpte_rate = smpte_smpte_rates[ smpte_rate ];
double the_sample_rate = smpte_sample_rates[ sample_rate ];
//
// keep track of the maximum frame number for this smpte format.
//
uchar max_frame = smpte_max_frames[ smpte_rate ];
//
// Calculate the number of samples per frame.
//
double samples_per_frame = smpte_sample_rates[ sample_rate ] / smpte_smpte_rates[ smpte_rate ];
//
// if the smpte rate is a drop frame type, calculate the number
// of frames that must be dropped.
//
if ( smpte_rate == SMPTE_RATE_30DF || smpte_rate == SMPTE_RATE_2997DF )
{
//
// Calculate number of minutes that have gone by
//
// short num_minutes = (short)((double)tmp_sample/(smpte_sample_rates[sample_rate]))/60;
int num_minutes = tmp_sample / ( 48000 * 60 );
DBG ( printf ( "num_minutes=%d\n", ( int ) num_minutes ) );
//
// Calculate the number of tens of minutes that have gone by, including minute 00
//
int ten_minutes = num_minutes / 10;
DBG ( printf ( "ten_minutes=%d\n", ( int ) ten_minutes ) );
//
// Calculate the number of frames that are dropped by this
// time.
//
int drops = ( num_minutes - ten_minutes ) * 2;
DBG ( printf ( "drops=%d\n", ( int ) drops ) );
//
// Offset the tmp_sample number by this amount of frames.
//
DBG ( printf ( "tmp_sample before drops=%ld\n", ( long ) tmp_sample ) );
tmp_sample += ( ulong ) ( drops * samples_per_frame );
DBG ( printf ( "tmp_sample after drops=%ld\n", ( long ) tmp_sample ) );
}
//
// Calculate the time in sub frames, frames, seconds, minutes, hours
//
ulong rounded_sub_frames = ( ulong ) ( ( tmp_sample * the_smpte_rate * 100 ) / the_sample_rate + .5 );
DBG ( printf ( "rounded_sub_frames = %ld\n", rounded_sub_frames ) );
sub_frames = ( uchar ) ( ( rounded_sub_frames ) % 100 );
frames = ( uchar ) ( ( rounded_sub_frames / 100 ) % max_frame );
seconds = ( uchar ) ( ( rounded_sub_frames / ( 100L * max_frame ) ) % 60 );
minutes = ( uchar ) ( ( rounded_sub_frames / ( 100L * 60L * max_frame ) ) % 60 );
hours = ( uchar ) ( ( rounded_sub_frames / ( 100L * 60L * 24L * max_frame ) ) % 24 );
}
示例11: cops_list_cb
static void cops_list_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
ofono_netreg_operator_list_cb_t cb = cbd->cb;
struct ofono_network_operator *list;
GAtResultIter iter;
int num = 0;
struct ofono_error error;
decode_at_error(&error, g_at_result_final_response(result));
if (!ok) {
cb(&error, 0, NULL, cbd->data);
return;
}
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+COPS:")) {
while (g_at_result_iter_skip_next(&iter))
num += 1;
}
DBG("Got %d elements", num);
list = g_try_new0(struct ofono_network_operator, num);
if (list == NULL) {
CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd->data);
return;
}
num = 0;
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+COPS:")) {
int status, tech, plmn;
const char *l, *s, *n;
gboolean have_long = FALSE;
while (1) {
if (!g_at_result_iter_open_list(&iter))
break;
if (!g_at_result_iter_next_number(&iter, &status))
break;
list[num].status = status;
if (!g_at_result_iter_next_string(&iter, &l))
break;
if (strlen(l) > 0) {
have_long = TRUE;
strncpy(list[num].name, l,
OFONO_MAX_OPERATOR_NAME_LENGTH);
}
if (!g_at_result_iter_next_string(&iter, &s))
break;
if (strlen(s) > 0 && !have_long)
strncpy(list[num].name, s,
OFONO_MAX_OPERATOR_NAME_LENGTH);
list[num].name[OFONO_MAX_OPERATOR_NAME_LENGTH] = '\0';
if (!g_at_result_iter_next_string(&iter, &n))
break;
extract_mcc_mnc(n, list[num].mcc, list[num].mnc);
if (!g_at_result_iter_next_number(&iter, &tech))
tech = ACCESS_TECHNOLOGY_GSM;
list[num].tech = tech;
if (!g_at_result_iter_next_number(&iter, &plmn))
plmn = 0;
if (!g_at_result_iter_close_list(&iter))
break;
num += 1;
}
}
DBG("Got %d operators", num);
{
int i = 0;
for (; i < num; i++) {
DBG("Operator: %s, %s, %s, status: %d, %d",
list[i].name, list[i].mcc, list[i].mnc,
list[i].status, list[i].tech);
}
}
cb(&error, num, list, cbd->data);
//.........这里部分代码省略.........
示例12: tx_complete
static void tx_complete(struct usb_ep *ep, struct usb_request *req)
{
struct sk_buff *skb = req->context;
struct eth_dev *dev = ep->driver_data;
struct net_device *net = dev->net;
struct usb_request *new_req;
struct usb_ep *in;
int length;
int retval;
switch (req->status) {
default:
dev->net->stats.tx_errors++;
VDBG(dev, "tx err %d\n", req->status);
/* FALLTHROUGH */
case -ECONNRESET: /* unlink */
case -ESHUTDOWN: /* disconnect etc */
break;
case 0:
if (!req->zero)
dev->net->stats.tx_bytes += req->length-1;
else
dev->net->stats.tx_bytes += req->length;
}
dev->net->stats.tx_packets++;
spin_lock(&dev->req_lock);
list_add_tail(&req->list, &dev->tx_reqs);
if (dev->port_usb->multi_pkt_xfer) {
dev->no_tx_req_used--;
req->length = 0;
in = dev->port_usb->in_ep;
if (!list_empty(&dev->tx_reqs)) {
new_req = container_of(dev->tx_reqs.next,
struct usb_request, list);
list_del(&new_req->list);
spin_unlock(&dev->req_lock);
if (new_req->length > 0) {
length = new_req->length;
/* NCM requires no zlp if transfer is
* dwNtbInMaxSize */
if (dev->port_usb->is_fixed &&
length == dev->port_usb->fixed_in_len &&
(length % in->maxpacket) == 0)
new_req->zero = 0;
else
new_req->zero = 1;
/* use zlp framing on tx for strict CDC-Ether
* conformance, though any robust network rx
* path ignores extra padding. and some hardware
* doesn't like to write zlps.
*/
if (new_req->zero && !dev->zlp &&
(length % in->maxpacket) == 0) {
new_req->zero = 0;
length++;
}
new_req->length = length;
retval = usb_ep_queue(in, new_req, GFP_ATOMIC);
switch (retval) {
default:
DBG(dev, "tx queue err %d\n", retval);
break;
case 0:
spin_lock(&dev->req_lock);
dev->no_tx_req_used++;
spin_unlock(&dev->req_lock);
net->trans_start = jiffies;
}
} else {
spin_lock(&dev->req_lock);
list_add(&new_req->list, &dev->tx_reqs);
spin_unlock(&dev->req_lock);
}
} else {
示例13: dhcp_run
static void dhcp_run(void)
{
static bool udp_open_fail = FALSE;
if(di.state == DHCP_STATE_INIT && di.action != DHCP_ACT_START) {
DBG("wrong attempt");
return;
} else if(GetUDPSocketStatus(di.sock) == SOCKSTAT_CLOSED) {
if(udp_open_fail == TRUE && !IS_TIME_PASSED(dhcp_run_tick, DHCP_RETRY_DELAY))
goto RET_ALARM;
if(UDPOpen(di.sock, DHCP_CLIENT_PORT) == RET_OK) {
if(dhcp_async) sockwatch_open(di.sock, dhcp_async_cb);
udp_open_fail = FALSE;
dhcp_run_tick = wizpf_get_systick();
dhcp_run_cnt = 0;
} else {
ERR("UDPOpen fail");
udp_open_fail = TRUE;
dhcp_run_tick = wizpf_get_systick();
goto RET_ALARM;
}
}
switch(di.state) {
case DHCP_STATE_INIT:
if(dhcp_run_cnt==0 && !IS_TIME_PASSED(dhcp_run_tick, DHCP_OPEN_DELAY))
goto RET_ALARM;
if(dhcp_run_cnt < DHCP_SEND_RETRY_COUNT) {
dhcp_run_cnt++;
if(send_discover() == RET_OK) { // Discover ok
if(dhcp_async) {
DBG("DHCP Discovery Send Async");
sockwatch_set(di.sock, WATCH_SOCK_UDP_SEND);
return; // alarm set is not needed
} else {
DBG("DHCP Discovery Sent");
SET_STATE(DHCP_STATE_SEARCHING);
dhcp_run_tick = wizpf_get_systick();
}
} else {
ERRA("DHCP Discovery SEND fail - (%d)times", dhcp_run_cnt);
dhcp_run_tick = wizpf_get_systick();
}
} else {
ERRA("DHCP Discovery SEND fail - (%d)times", dhcp_run_cnt);
dhcp_run_cnt = 0;
UDPClose(di.sock);
if(dhcp_async) sockwatch_close(di.sock);
dhcp_fail();
return; // alarm set is not needed
}
break;
case DHCP_STATE_SEARCHING:
if(!IS_TIME_PASSED(dhcp_run_tick, DHCP_RETRY_DELAY)) {
int8 ret = recv_handler();
if(ret == DHCP_MSG_OFFER) {
SET_STATE(DHCP_STATE_SELECTING);
dhcp_run_tick = wizpf_get_systick();
dhcp_run_cnt = 0;
} else if(ret != RET_NOK) DBGCRTCA(TRUE, "recv wrong packet(%d)", ret);
} else {
ERRA("DHCP Offer RECV fail - for (%d)msec", DHCP_RETRY_DELAY);
SET_STATE(DHCP_STATE_INIT);
dhcp_run_tick = wizpf_get_systick();
}
break;
case DHCP_STATE_SELECTING:
if(dhcp_run_cnt < DHCP_SEND_RETRY_COUNT) {
dhcp_run_cnt++;
if(send_request() == RET_OK) { // Request ok
if(dhcp_async) {
DBG("DHCP Request Send Async");
sockwatch_set(di.sock, WATCH_SOCK_UDP_SEND);
return; // alarm set is not needed
} else {
DBG("DHCP Request Sent");
SET_STATE(DHCP_STATE_REQUESTING);
dhcp_run_tick = wizpf_get_systick();
}
} else {
ERRA("DHCP Request SEND fail - (%d)times", dhcp_run_cnt);
dhcp_run_tick = wizpf_get_systick();
}
} else {
ERRA("DHCP Request SEND fail - (%d)times", dhcp_run_cnt);
dhcp_run_cnt = 0;
UDPClose(di.sock);
if(dhcp_async) sockwatch_close(di.sock);
dhcp_fail();
return; // alarm set is not needed
}
break;
case DHCP_STATE_REQUESTING:
if(!IS_TIME_PASSED(dhcp_run_tick, DHCP_RETRY_DELAY)) {
int8 ret = recv_handler();
if(ret == DHCP_MSG_ACK) { // Recv ACK
LOG("DHCP Success");
SET_STATE(DHCP_STATE_IP_CHECK);
dhcp_run_tick = wizpf_get_systick();
//.........这里部分代码省略.........
示例14: etna_screen_get_shader_param
static int etna_screen_get_shader_param( struct pipe_screen *screen, unsigned shader, enum pipe_shader_cap param )
{
struct etna_screen *priv = etna_screen(screen);
switch(shader)
{
case PIPE_SHADER_FRAGMENT:
case PIPE_SHADER_VERTEX:
break;
case PIPE_SHADER_COMPUTE:
case PIPE_SHADER_GEOMETRY:
/* maybe we could emulate.. */
return 0;
default:
DBG("unknown shader type %d", shader);
return 0;
}
switch (param) {
case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
return ETNA_MAX_TOKENS;
case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
return ETNA_MAX_DEPTH; /* XXX */
case PIPE_SHADER_CAP_MAX_INPUTS:
return 16; /* XXX this amount is reserved */
case PIPE_SHADER_CAP_MAX_TEMPS:
return 64; /* Max native temporaries. */
case PIPE_SHADER_CAP_MAX_ADDRS:
return 1; /* Max native address registers */
case PIPE_SHADER_CAP_MAX_CONSTS:
/* Absolute maximum on ideal hardware is 256 (as that's how much register space is reserved);
* immediates are included in here, so actual space available for constants will always be less.
* Also the amount of registers really available depends on the hw.
* XXX see also: viv_specs.num_constants, if this is 0 we need to come up with some default value.
*/
return 256;
case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
return 1;
case PIPE_SHADER_CAP_MAX_PREDS:
return 0; /* nothing uses this */
case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
return 1;
case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
return 1;
case PIPE_SHADER_CAP_SUBROUTINES:
return 0;
case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
return VIV_FEATURE(priv->dev, chipMinorFeatures0, HAS_SQRT_TRIG);
case PIPE_SHADER_CAP_TGSI_POW_SUPPORTED:
return false;
case PIPE_SHADER_CAP_TGSI_LRP_SUPPORTED:
return false;
case PIPE_SHADER_CAP_INTEGERS: /* XXX supported on gc2000 but not yet implemented */
return 0;
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
return shader==PIPE_SHADER_FRAGMENT ? priv->specs.fragment_sampler_count :
priv->specs.vertex_sampler_count;
case PIPE_SHADER_CAP_PREFERRED_IR:
return PIPE_SHADER_IR_TGSI;
case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
return 4096;
default:
DBG("unknown shader param %d", param);
return 0;
}
return 0;
}
示例15: tun_set_iff
static int tun_set_iff(struct file *file, struct ifreq *ifr)
{
struct tun_struct *tun;
struct net_device *dev;
int err;
dev = __dev_get_by_name(ifr->ifr_name);
if (dev) {
/* Device exist */
tun = dev->priv;
if (dev->init != tun_net_init || tun->attached)
return -EBUSY;
/* Check permissions */
if (tun->owner != -1)
if (current->euid != tun->owner && !capable(CAP_NET_ADMIN))
return -EPERM;
} else {
char *name;
/* Allocate new device */
if (!(tun = kmalloc(sizeof(struct tun_struct), GFP_KERNEL)) )
return -ENOMEM;
memset(tun, 0, sizeof(struct tun_struct));
skb_queue_head_init(&tun->readq);
init_waitqueue_head(&tun->read_wait);
tun->owner = -1;
tun->dev.init = tun_net_init;
tun->dev.priv = tun;
err = -EINVAL;
/* Set dev type */
if (ifr->ifr_flags & IFF_TUN) {
/* TUN device */
tun->flags |= TUN_TUN_DEV;
name = "tun%d";
} else if (ifr->ifr_flags & IFF_TAP) {
/* TAP device */
tun->flags |= TUN_TAP_DEV;
name = "tap%d";
} else
goto failed;
if (*ifr->ifr_name)
name = ifr->ifr_name;
if ((err = dev_alloc_name(&tun->dev, name)) < 0)
goto failed;
if ((err = register_netdevice(&tun->dev)))
goto failed;
MOD_INC_USE_COUNT;
tun->name = tun->dev.name;
}
DBG(KERN_INFO "%s: tun_set_iff\n", tun->name);
if (ifr->ifr_flags & IFF_NO_PI)
tun->flags |= TUN_NO_PI;
if (ifr->ifr_flags & IFF_ONE_QUEUE)
tun->flags |= TUN_ONE_QUEUE;
file->private_data = tun;
tun->attached = 1;
strcpy(ifr->ifr_name, tun->name);
return 0;
failed:
kfree(tun);
return err;
}