static int s5k6aafx13_set_brightness(int brightness) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s brightness=%d\n", __func__, brightness); switch (brightness) { case 0: pid = SI2C_BRIGHTNESS_M4; break; case 1: pid = SI2C_BRIGHTNESS_M3; break; case 2: pid = SI2C_BRIGHTNESS_M2; break; case 3: pid = SI2C_BRIGHTNESS_M1; break; case 4: pid = SI2C_BRIGHTNESS_0; break; case 5: pid = SI2C_BRIGHTNESS_P1; break; case 6: pid = SI2C_BRIGHTNESS_P2; break; case 7: pid = SI2C_BRIGHTNESS_P3; break; case 8: pid = SI2C_BRIGHTNESS_P4; break; default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
int sgpio_init(sgpio_ctrl_t *gpios, uint32_t sz) { uint32_t i = 0; int rc = 0; CINFO("%s E\n", __func__); for (i = 0; i < sz; i++) { rc = gpio_request(gpios[i].nr, gpios[i].label); CINFO("%s gpios[i].nr=%d, gpios[i].label=%s\n", __func__, gpios[i].nr, gpios[i].label); if (rc < 0) { CERR("%s req err(%d, %s)\n", __func__, rc, gpios[i].label); gpio_free(gpios[i].nr); CINFO("%s gpio_free(%d) and retry request~ \n", __func__, gpios[i].nr); rc = gpio_request(gpios[i].nr, gpios[i].label); if (rc < 0) { CERR("%s after retry req err(%d, %s)\n", __func__, rc, gpios[i].label); return rc; } } rc = gpio_direction_output(gpios[i].nr, 0); //gpio_set_value_cansleep(gpios[i].nr, 0); if (rc < 0) { CERR("%s dir_out err(%d, %s)\n", __func__, rc, gpios[i].label); return rc; } } CINFO("%s X\n", __func__); return 0; }
bool ChildProcess::receiveAnswer(std::deque<std::string> &answerStack) { Plazza::Packet::Header head; char *raw = nullptr; std::memset(&head, '\0', sizeof(head)); if (!_pipe2->readFrom(&head, sizeof(head))) { CERR("Couldn't read answer header"); return (false); } if (head.magic != Plazza::Packet::MAGIC) { CERR("bad answer header magic"); return (false); } raw = new char[head.size]; if (!_pipe2->readFrom(raw, head.size)) { CERR("Couldn't read raw answer data"); return (false); } answerStack.push_back(std::string(raw)); delete []raw; --this->_nbCurrentActions; return (true); }
int si2c_init( struct i2c_adapter *adap, si2c_const_param_t *src, si2c_param_t *dst) { si2c_pid_t i = SI2C_PID_MAX; si2c_pid_t j = SI2C_PID_MAX; CINFO("%s E\n", __func__); if (!adap || !src || !dst) { CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } if (si2c_adap != NULL) { CERR("%s err(-EBUSY)\n", __func__); return -EBUSY; } si2c_adap = adap; for (i = 0; i < SI2C_PID_MAX; i++) for (j = 0; j < SI2C_PID_MAX; j++) if ((src[j].id == i) && (src[j].cmds != NULL)) { dst[i].id = src[j].id; dst[i].cmds = (si2c_cmd_t *)src[j].cmds; break; } CINFO("%s X\n", __func__); return 0; }
static int32_t s5k6aafx13_set_wb(int wb) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s wb=%d\n", __func__, wb); switch (wb) { case 1: pid = SI2C_WB_AUTO; break; case 3: pid = SI2C_WB_INCANDESCENT; break; case 4: pid = SI2C_WB_FLUORESCENT; break; case 5: pid = SI2C_WB_DAYLIGHT; break; case 6: pid = SI2C_WB_CLOUDY; break; default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
/** * Returns address of 'start of next line'. If next line is comment, blank or * malformed command, just return null. */ static char *ptune_get_nl(char *str) { CDBG("%s E\n", __func__); if (!str) { /* PANTECH_CAMERA_TODO, assert? */ CERR("%s str=null\n", __func__); return NULL; } for (;;) { str = strchr(str, '\n'); if (!str) { /* PANTECH_CAMERA_TODO, assert? */ CERR("%s end of string\n", __func__); return NULL; } str++; if ((*str == '/') && (*(str + 1) == '/')) { CDBG("%s comment\n", __func__); continue; } else if (ptune_isblank(*str)) { CDBG("%s blank\n", __func__); continue; } else break; } CDBG("%s X\n", __func__); return str; }
static int s5k6aafx13_set_reflect(int reflect) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s reflect=%d\n", __func__, reflect); switch (reflect) { case 0: pid = SI2C_REFLECT_OFF; break; case 1: pid = SI2C_REFLECT_MIRROR; break; case 2: pid = SI2C_REFLECT_WATER; break; case 3: pid = SI2C_REFLECT_MIRROR_WATER; break; default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
int svreg_ctrl(svreg_ctrl_t *vregs, int id, int val) { int rc = 0; /* PANTECH_CAMERA_TODO, How to verify id? */ if (!vregs[id].vreg) { CERR("%s (-ENOENT, %d)\n", __func__, id); return -ENOENT; } if (val) { rc = regulator_enable(vregs[id].vreg); if (rc) { CERR("%s on err(%d, %s)\n", __func__, rc, vregs[id].vname); return rc; } } else { rc = regulator_disable(vregs[id].vreg); if (rc) { CERR("%s off err(%d, %s)\n", __func__, rc, vregs[id].vname); return rc; } } CINFO("%s set %s to %d\n", __func__, vregs[id].vname, val); return 0; }
static int s5k6aafx13_set_exposure(int exposure) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s exposure=%d\n", __func__, exposure); switch (exposure) { case 1: pid = SI2C_EXPOSURE_AVERAGE; break; case 2: case 3: pid = SI2C_EXPOSURE_CENTER; break; default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
static int s5k6aafx13_set_effect(int effect) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s effect=%d\n", __func__, effect); switch (effect) { case CAMERA_EFFECT_OFF: pid = SI2C_EFFECT_OFF; break; case CAMERA_EFFECT_MONO: pid = SI2C_EFFECT_MONO; break; //case CAMERA_EFFECT_NEGATIVE: pid = SI2C_EFFECT_NEGATIVE; break;//pangya _120510 EF39S don't use negative of effect. case CAMERA_EFFECT_SEPIA: pid = SI2C_EFFECT_SEPIA; break; case CAMERA_EFFECT_AQUA: pid = SI2C_EFFECT_AQUA; break; //pangya _120510 Effect added aqua. default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
int Producer(struct thInfoPersist* t, void (*action)(void*), void* arg) { CERR(pthread_mutex_lock(&t->buffer) != 0, "mutex lock failed"); while(t->itemCount > t->maxItems - 1) { // /* if(cCount * RATIO < pCount) { fprintf(stderr,"[+]"); fflush(stderr); CERR(pthread_mutex_unlock(&t->buffer) != 0, "mutex unlock failed"); return -1; } // */ fprintf(stderr, "\n P%u : itemCount: %d maxItems: %d, C%d P%d)\n", (unsigned int)pthread_self(), t->itemCount, t->maxItems, cCount, pCount); CERR(pthread_cond_broadcast(&t->notEmpty), "broadcast failed"); struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); ts.tv_sec+=5; pthread_cond_timedwait(&t->notFull, &t->buffer, &ts); } (*action)(arg); CERR(pthread_cond_broadcast(&t->notEmpty), "broadcast failed"); CERR(pthread_mutex_unlock(&t->buffer) != 0, "mutex unlock failed"); return 0; }
static int s5k6aafx13_config_csi(void) { struct msm_camera_csi_params *csi = NULL; int rc = 0; CDBG("%s E\n", __func__); csi = kmalloc(sizeof(struct msm_camera_csi_params), GFP_KERNEL); if (!csi) { CERR("%s err(-ENOMEM)", __func__); return -ENOMEM; } csi->data_format = CSI_8BIT; csi->lane_cnt = 1; csi->lane_assign = 0xe4; csi->settle_cnt = 0x14; csi->dpcm_scheme = 0; rc = msm_camio_csi_config(csi); if (rc < 0) { kfree(csi); CERR("%s err(%d)\n", __func__, rc); return rc; } msleep(10); config_csi_done = true; kfree(csi); CDBG("%s X\n", __func__); return 0; }
bool Parser::statement() { bool isReturn = false; switch (lexer->token) { case '{': isReturn = block(); break; case TK_if: ifStat(); break; case TK_while: whileStat(); break; case TK_for: forStat(); break; case TK_return: { advance(); int top = syms->localsTop(); emit(top, RET, 0, expr(top), UNUSED); isReturn = true; break; } case TK_NAME: { int lookahead = lexer->lookahead(); if (lookahead == '=' || lookahead == ':'+TK_EQUAL) { Value name = lexer->info.name; consume(TK_NAME); if (lookahead == '=') { int slot = lookupSlot(name); consume('='); int top = syms->localsTop(); patchOrEmitMove(top + 1, slot, expr(top)); proto->patchPos = -1; } else { consume(':'+TK_EQUAL); if (syms->definedInThisBlock(name)) { CERR(true, E_VAR_REDEFINITION, name); // aSlot = slot; // reuse existing local with same name } else { const Value a = expr(syms->localsTop()); const int slot = syms->set(name); patchOrEmitMove(slot+1, slot, a); proto->patchPos = -1; } } break; } } default: { int top = syms->localsTop(); Value lhs = expr(top); if (TOKEN == '=') { consume('='); CERR(!IS_REG(lhs), E_ASSIGN_TO_CONST, lhs); CERR(proto->patchPos < 0, E_ASSIGN_RHS, lhs); unsigned code = proto->code.pop(); int op = OP(code); CERR(op != GETI && op != GETF, E_ASSIGN_RHS, lhs); assert((int)lhs == OC(code)); emit(top + 3, op + 1, OA(code), VAL_REG(OB(code)), expr(top + 2)); } } } return isReturn; }
void end_eating(restaurant_t* place) { CERR(pthread_mutex_lock(&place->accessVars), "lck"); place->eating = place->eating - 1; if(place->eating == 0 && place->waiting > 0) { printf("Posting..\n"); for(int i = 0; i < MIN(CUST, place->waiting); i++) { CERR(sem_post(&place->entrance), "post"); } } CERR(pthread_mutex_unlock(&place->accessVars), "ulck"); }
bool Parser::_invalidActionsNumberErrorHandler(int nbActions, std::string const & line) { _tokList.clear() ; if (nbActions < 1){ CERR("Plazza::Parser: No action detected in line \"" << line << "\""); } else if (nbActions > 1) { CERR("Plazza::Parser: More than one action in line \"" << line << "\""); } return (false); }
int main(int argc, char *const argv[]) { int ret = 0, t=1000,A=0; while((ret = getopt(argc, argv, "t:A")) != -1 ) { switch(ret) { case 't': t = atoi(optarg); break; default: fprintf(stderr, "unknown option: %c\n", ret); break; case 'A': A = 1; printf("Unlinking memory\n"); } } if(A == 1) { shm_unlink(NAME); return EXIT_SUCCESS; } int fd; char existed; CERR(openSharedMem(NAME, &fd, &existed), "oSM"); if(fd == -1) { return EXIT_FAILURE; } if(!existed) { ftruncate(fd, sizeof(restaurant_t)); } restaurant_t* r = (restaurant_t*)mmap(NULL, sizeof(restaurant_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); CERR((long long)r, "mmap"); if(r == (restaurant_t*)-1) { shm_unlink(NAME); return EXIT_FAILURE; } if(!existed) { printf("initializing shm..\n"); restaurant_init(r); } start_eating(r); printf(" p%d started eating..\n", (int)getpid()); char buf[256]; sprintf(buf,"sleep %d", t); system(buf); end_eating(r); printf(" p%d ended eating..\n", (int)getpid()); return 0; }
static int s5k6aafx13_set_preview_fps(int preview_fps) { si2c_pid_t pid = SI2C_PID_MAX; int rc = 0; CDBG("%s preview_fps=%d\n", __func__, preview_fps); switch (preview_fps) { case 0: pid = SI2C_FPS_VARIABLE; break; case 7: pid = SI2C_FPS_FIXED7; break; case 8: pid = SI2C_FPS_FIXED8; break; case 10: pid = SI2C_FPS_FIXED10; break; case 15: pid = SI2C_FPS_FIXED15; break; case 20: pid = SI2C_FPS_FIXED20; break; case 24: pid = SI2C_FPS_FIXED24; break; default: //PANTECH_CAMERA_TODO return 0; //CERR("%s err(-EINVAL)\n", __func__); //return -EINVAL; } rc = si2c_write_param(SI2C_SA, pid, s5k6aafx13_params); if (rc < 0) { CERR("%s err(%d)\n", __func__, rc); return rc; } CDBG("%s X\n", __func__); return 0; }
// millisecs std::error_code PollPoller::poll(int timeout, std::unordered_map<int, Dispatcher *> &active_dispatchers) { if (fds_.size() == 0) { ::Sleep(timeout); return LS_OK_ERROR(); } int num_events = ::WSAPoll(&*fds_.begin(), fds_.size(), timeout); if (num_events < 0) { if (SOCK_ERRNO() == CERR(EINTR)) { return LS_OK_ERROR(); } } else if (num_events == 0) { return LS_OK_ERROR(); } else { for (auto it = fds_.begin(); it != fds_.end() && num_events > 0; ++it) { if (it->revents > 0) { --num_events; Dispatcher *dispatcher = dispatchers_[it->fd]; dispatcher->set_poll_event_data( it->revents & (POLLIN | POLLPRI), it->revents & POLLOUT, it->revents & POLLERR, (it->revents & POLLHUP) && !(it->revents & POLLIN)); active_dispatchers[dispatcher->get_fd()] = dispatcher; } } } return LS_OK_ERROR(); }
void Parser::consume(int t) { if (t == lexer->token) { lexer->advance(); } else { CERR(true, E_EXPECTED + t, VNIL); } }
void start_eating(restaurant_t* place) { CERR(pthread_mutex_lock(&place->accessVars), "lck"); printf("%d customers at table..\n", place->eating); if(place->eating >= CUST) { place->waiting++; CERR(pthread_mutex_unlock(&place->accessVars), "ulck"); //race cond between unlocking and waiting on sem printf("waiting for turn..\n"); CERR(sem_wait(&place->entrance), "wait"); CERR(pthread_mutex_lock(&place->accessVars), "lck"); place->waiting = place->waiting - 1; } place->eating++; CERR(pthread_mutex_unlock(&place->accessVars), "ulck"); }
int s5k6aafx13_sensor_config(void __user *argp) { struct sensor_cfg_data sc; int rc = 0; rc = copy_from_user(&sc, argp, sizeof(struct sensor_cfg_data)); if (rc) { CERR("%s err(%d)\n", __func__, rc); return rc; } /*CDBG("%s type=%d, mode=%d\n", __func__, sc.cfgtype, sc.mode);*/ mutex_lock(&s5k6aafx13_mutex); switch (sc.cfgtype) { case CFG_SET_BRIGHTNESS: rc = s5k6aafx13_set_brightness(sc.cfg.brightness); break; case CFG_SET_EFFECT: rc = s5k6aafx13_set_effect(sc.cfg.effect); break; //PANTECH_CAMERA_TODO, EXPOSURE_MODE -> EXPOSURE case CFG_SET_EXPOSURE_MODE: rc = s5k6aafx13_set_exposure(sc.cfg.exposure); break; case CFG_SET_MODE: rc = s5k6aafx13_set_mode(sc.mode); break; case CFG_SET_PREVIEW_FPS: rc = s5k6aafx13_set_preview_fps(sc.cfg.preview_fps); break; case CFG_SET_REFLECT: rc = s5k6aafx13_set_reflect(sc.cfg.reflect); break; #ifdef CONFIG_PANTECH_CAMERA_TUNER case CFG_SET_TUNER: rc = s5k6aafx13_set_tuner(sc.cfg.tuner); break; #endif case CFG_SET_WB: //PANTECH_CAMERA_TODO, whitebalance -> wb rc = s5k6aafx13_set_wb(sc.cfg.whitebalance); break; default: CDBG("%s err(-EINVAL)\n", __func__); rc = -EINVAL; break; } mutex_unlock(&s5k6aafx13_mutex); /*CDBG("%s X (%d)\n", __func__, rc);*/ return rc; }
bool resolveAddress(struct sockaddr_in *address, const char *host, unsigned short port) { assert(address); assert(host); // FIXME -- Need to ignore leading/trailing spaces in hostname. struct hostent *hp; int h_errno_local; #ifdef HAVE_GETHOSTBYNAME2_R struct hostent hostData; char tmpBuffer[2048]; // There are different flavors of gethostbyname_r(), but // latest Linux use the following form: if (gethostbyname2_r(host, AF_INET, &hostData, tmpBuffer, sizeof(tmpBuffer), &hp, &h_errno_local)!=0) { CERR("WARNING -- gethostbyname2_r() failed for " << host << ", " << hstrerror(h_errno_local)); return false; } #else static Mutex sGethostbynameMutex; // gethostbyname() is NOT thread-safe, so we should use a mutex here. // Ideally it should be a global mutex for all non thread-safe socket // operations and it should protect access to variables such as // global h_errno. sGethostbynameMutex.lock(); hp = gethostbyname(host); h_errno_local = h_errno; sGethostbynameMutex.unlock(); #endif if (hp==NULL) { CERR("WARNING -- gethostbyname() failed for " << host << ", " << hstrerror(h_errno_local)); return false; } if (hp->h_addrtype != AF_INET) { CERR("WARNING -- gethostbyname() resolved " << host << " to something other then AF_INET"); return false; } address->sin_family = hp->h_addrtype; assert(sizeof(address->sin_addr) == hp->h_length); memcpy(&(address->sin_addr), hp->h_addr_list[0], hp->h_length); address->sin_port = htons(port); return true; }
int svreg_init(svreg_ctrl_t *vregs, uint32_t sz) { struct regulator *vreg = NULL; int uvolt = 0; uint32_t i = 0; int rc = 0; CINFO("%s E\n", __func__); for (i = 0; i < sz; i++) { vreg = regulator_get(NULL, vregs[i].vname); if (IS_ERR(vreg)) { CERR("%s err(-EBUSY, %s)\n", __func__, vregs[i].vname); return -EBUSY; } vregs[i].vreg = vreg; /* Some voltage sources don't have interface to set voltage * levels. You can check these limitations in appropriate * regulator platform drivers. * (e.g. pmic8901-regulator.c, pmic8058-regulator.c,...) * So we don't call 'regulator_set_voltage' for this kind * of voltage sources. IOW you should set voltage level * correctly in board initialization code. * (e.g. static struct rpm_vreg_pdata rpm_vreg_init_pdata[]) */ if (vregs[i].arg == 0) continue; uvolt = vregs[i].arg * 1000; rc = regulator_set_voltage(vreg, uvolt, uvolt); if (rc < 0) { CERR("%s err(%d, %s)\n", __func__, rc, vregs[i].vname); return rc; } } CINFO("%s X\n", __func__); return 0; }
int si2c_write_param(uint16_t sa, si2c_pid_t pid, si2c_param_t *params) { int rc = 0; CINFO("%s E pid=%d\n", __func__, pid); if ((pid < 0) || (pid >= SI2C_PID_MAX) || !params) { CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } if (params[pid].cmds == NULL) { CERR("%s err(-ENOENT)\n", __func__); return -ENOENT; } rc = si2c_write_cmds(sa, params[pid].cmds); CINFO("%s X (%d)\n", __func__, rc); return rc; }
static int s5k6aafx13_set_mode(int mode) { int rc = 0; CDBG("%s mode=%d\n", __func__, mode); if (!config_csi_done) { #ifdef CONFIG_PANTECH_CAMERA_TUNER rc = si2c_write_param(SI2C_SA, SI2C_INIT, s5k6aafx13_params); if (rc < 0) { CERR("%s init err(%d)\n", __func__, rc); return rc; } #endif rc = s5k6aafx13_config_csi(); if (rc < 0) { CERR("%s err(-EIO)\n", __func__); return -EIO; } } switch (mode) { case SENSOR_PREVIEW_MODE: if (sensor_mode != SENSOR_PREVIEW_MODE) rc = s5k6aafx13_video_config(); break; case SENSOR_SNAPSHOT_MODE: if (sensor_mode != SENSOR_SNAPSHOT_MODE) rc = s5k6aafx13_snapshot_config(); break; default: rc = -EINVAL; break; } CDBG("%s X (%d)\n", __func__, rc); return rc; }
int si2c_read(si2c_cw_t w, uint16_t sa, uint16_t ra, uint16_t *rd) { uint8_t a[2] = {0, 0}, d[2] = {0, 0}; int rc = 0; if (!rd) { CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } switch (w) { case SI2C_A1D1: a[0] = SI2C_W2BL(ra); rc = si2c_rx(sa, a, 1, d, 1); *rd = SI2C_B2W(0, d[0]); break; case SI2C_A1D2: a[0] = SI2C_W2BL(ra); rc = si2c_rx(sa, a, 1, d, 2); *rd = SI2C_B2W(d[0], d[1]); break; case SI2C_A2D1: a[0] = SI2C_W2BM(ra); a[1] = SI2C_W2BL(ra); rc = si2c_rx(sa, a, 2, d, 1); *rd = SI2C_B2W(0, d[0]); break; case SI2C_A2D2: a[0] = SI2C_W2BM(ra); a[1] = SI2C_W2BL(ra); rc = si2c_rx(sa, a, 2, d, 2); *rd = SI2C_B2W(d[0], d[1]); break; default: CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } return rc; }
static int s5k6aafx13_set_tuner(struct tuner_cfg tuner) { si2c_cmd_t *cmds = NULL; char *fbuf = NULL; CDBG("%s fbuf=%p, fsize=%d\n", __func__, tuner.fbuf, tuner.fsize); if (!tuner.fbuf || (tuner.fsize == 0)) { CERR("%s err(-EINVAL)\n", __func__); return -EINVAL; } fbuf = (char *)kmalloc(tuner.fsize, GFP_KERNEL); if (!fbuf) { CERR("%s err(-ENOMEM)\n", __func__); return -ENOMEM; } if (copy_from_user(fbuf, tuner.fbuf, tuner.fsize)) { CERR("%s err(-EFAULT)\n", __func__); kfree(fbuf); return -EFAULT; } cmds = ptune_parse("@init", fbuf); if (!cmds) { CERR("%s no @init\n", __func__); kfree(fbuf); return -EFAULT; } s5k6aafx13_tuner_params[SI2C_INIT].cmds = cmds; s5k6aafx13_params[SI2C_INIT].cmds = cmds; kfree(fbuf); CDBG("%s X\n", __func__); return 0; }
int Parser::lookupSlot(Value name) { int slot, protoLevel; bool found = syms->get(name, &slot, &protoLevel, 0); CERR(!found, E_NAME_NOT_FOUND, name); const int curProtoLevel = syms->protoLevel(); assert(protoLevel <= curProtoLevel); if (protoLevel < curProtoLevel) { slot = createUpval(proto, curProtoLevel, name, protoLevel, slot); } assert(slot < syms->localsTop()); return slot; }
int sgpio_init(sgpio_ctrl_t *gpios, uint32_t sz) { uint32_t i = 0; int rc = 0; CINFO("%s E\n", __func__); for (i = 0; i < sz; i++) { rc = gpio_request(gpios[i].nr, gpios[i].label); if (rc < 0) { CERR("%s req err(%d, %s)\n", __func__, rc, gpios[i].label); return rc; } rc = gpio_direction_output(gpios[i].nr, 0); if (rc < 0) { CERR("%s dir_out err(%d, %s)\n", __func__, rc, gpios[i].label); return rc; } } CINFO("%s X\n", __func__); return 0; }
static int s5k6aafx13_i2c_probe( struct i2c_client *client, const struct i2c_device_id *id) { CDBG("%s E\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { CERR("%s (-ENOTSUPP)\n", __func__); return -ENOTSUPP; } s5k6aafx13_work = kzalloc(sizeof(s5k6aafx13_work_t), GFP_KERNEL); if (!s5k6aafx13_work) { CERR("%s (-ENOMEM)\n", __func__); return -ENOMEM; } i2c_set_clientdata(client, s5k6aafx13_work); s5k6aafx13_client = client; CDBG("%s X\n", __func__); return 0; }