static int vt1603_bat_uboot_env_check(struct vt1603_bat_drvdata *bat_drv) { int ret = 0; int len = 96; char buf[96] = { 0 }; ret = wmt_getsyspara("wmt.io.bat", buf, &len); if(ret ||strncmp(buf,"3",1)){ dbg_err(" VT1603A/VT1609 Battery Disabled.\n"); return -EIO; } len = sizeof(buf); memset(buf, 0, sizeof(buf)); ret = wmt_getsyspara("wmt.audio.i2s", buf, &len); if(ret ||strncmp(buf,"vt1603",6)){ dbg_err("Vt1603 battery invalid, for VT1603 codec disabled.\n"); return -EINVAL; } bat_drv->tch_enabled = 0; len = sizeof(buf); memset(buf, 0, sizeof(buf)); ret = wmt_getsyspara("wmt.io.touch", buf, &len); if(!strncmp(buf,"1:vt1603",8) ||!strncmp(buf,"1:vt1609",8) ) bat_drv->tch_enabled = 1; return 0; }
static int __init vt1603_bat_init(void) { int ret = 0; struct vt1603_bat_drvdata *bat_drv = NULL; bat_drv = kzalloc(sizeof(*bat_drv), GFP_KERNEL); if (!bat_drv) { dbg_err("vt160x: alloc driver data failed\n"); ret = -ENOMEM; goto out; } ret = vt1603_bat_uboot_env_check(bat_drv); if (ret) { dbg_err("vt1603x uboot env check failed\n"); goto out; } vt1603_bat = bat_drv; ret = platform_driver_register(&vt1603_bat_driver); if(ret){ dbg_err("vt160x battery driver register failed!.\n"); goto out; } return 0; out: kfree(bat_drv); return ret; }
/* * vt1603_bat_work - vt1603 battery workqueue routine, switch * vt1603 working mode to battery detecting * @work: battery work struct */ static void vt1603_bat_work(struct work_struct *work) { int tmp = 0; int timeout, i = 0; int bat_arrary[DFLT_BAT_VAL_AVG]={0}; struct vt1603_bat_drvdata *bat_drv; dbg("Enter\n"); bat_drv = container_of(work, struct vt1603_bat_drvdata, work); if (unlikely(vt1603_get_pen_state(bat_drv) == TS_PENDOWN_STATE)) { dbg("vt1603 pendown when battery detect\n"); goto out; } /* enable sar-adc power and clock */ vt1603_bat_power_up(bat_drv); /* enable pen down/up to avoid miss irq */ vt1603_bat_pen_manual(bat_drv); /* switch vt1603 to battery detect mode */ vt1603_switch_to_bat_mode(bat_drv); /* do conversion use battery manual mode */ vt1603_setbits(bat_drv, VT1603_INTS_REG, BIT0); vt1603_set_reg8(bat_drv, VT1603_CR_REG, BIT4); for(i=0; i<DFLT_BAT_VAL_AVG; i++){ timeout = 2000; while(--timeout && (vt1603_get_reg8(bat_drv, VT1603_INTS_REG) & BIT0)==0) ; if(timeout){ if(vt1603_get_bat_data(bat_drv,&bat_arrary[i]) < 0) dbg_err("vt1603 get bat adc data Failed!\n"); }else { dbg_err("wait adc end timeout ?!\n"); goto out; } vt1603_setbits(bat_drv, VT1603_INTS_REG, BIT0); vt1603_set_reg8(bat_drv, VT1603_CR_REG, BIT4);//start manual ADC mode } tmp = vt1603_bat_avg(bat_arrary,DFLT_BAT_VAL_AVG); bat_drv->bat_new = tmp; vt1603_fifo_push(&Bat_buf, tmp); vt1603_fifo_avg(Bat_buf, &tmp); bat_drv->bat_val = tmp; //printk(KERN_ERR"reported battery val:%d, new val:%d\n",tmp, bat_drv->bat_new); out: vt1603_clrbits(bat_drv, VT1603_INTCR_REG, BIT7); vt1603_setbits(bat_drv, VT1603_INTS_REG, BIT0 | BIT3); vt1603_set_reg8(bat_drv, VT1603_CR_REG, BIT1); mod_timer(&bat_drv->bat_tmr, jiffies + msecs_to_jiffies(DFLT_POLLING_BAT_INTERVAL* 1000)); dbg("Exit\n\n\n"); return ; }
/** * validate_vid_hdr - check volume identifier header. * @vid_hdr: the volume identifier header to check * @sv: information about the volume this logical eraseblock belongs to * @pnum: physical eraseblock number the VID header came from * * This function checks that data stored in @vid_hdr is consistent. Returns * non-zero if an inconsistency was found and zero if not. * * Note, UBI does sanity check of everything it reads from the flash media. * Most of the checks are done in the I/O sub-system. Here we check that the * information in the VID header is consistent to the information in other VID * headers of the same volume. */ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, const struct ubi_scan_volume *sv, int pnum) { int vol_type = vid_hdr->vol_type; int vol_id = be32_to_cpu(vid_hdr->vol_id); int used_ebs = be32_to_cpu(vid_hdr->used_ebs); int data_pad = be32_to_cpu(vid_hdr->data_pad); if (sv->leb_count != 0) { int sv_vol_type; /* * This is not the first logical eraseblock belonging to this * volume. Ensure that the data in its VID header is consistent * to the data in previous logical eraseblock headers. */ if (vol_id != sv->vol_id) { dbg_err("inconsistent vol_id"); goto bad; } if (sv->vol_type == UBI_STATIC_VOLUME) sv_vol_type = UBI_VID_STATIC; else sv_vol_type = UBI_VID_DYNAMIC; if (vol_type != sv_vol_type) { dbg_err("inconsistent vol_type"); goto bad; } if (used_ebs != sv->used_ebs) { dbg_err("inconsistent used_ebs"); goto bad; } if (data_pad != sv->data_pad) { dbg_err("inconsistent data_pad"); goto bad; } } return 0; bad: ubi_err("inconsistent VID header at PEB %d", pnum); ubi_dbg_dump_vid_hdr(vid_hdr); ubi_dbg_dump_sv(sv); return -EINVAL; }
static int sitronix_get_chip_id(struct sitronix_data *sitronix) { int ret = 0; uint8_t buffer[3]={CHIP_ID}; ret = sitronix_read(sitronix, buffer, 3); if (ret < 0){ dbg_err("read Chip ID error (%d)\n", ret); return ret; } if(buffer[0] == 0){ if(buffer[1] + buffer[2] > 32) sitronix->chip_id = 2; else sitronix->chip_id = 0; }else sitronix->chip_id = buffer[0]; sitronix->Num_X = buffer[1]; sitronix->Num_Y = buffer[2]; printk("Chip ID = %d, Num_X = %d, Num_Y = %d\n", sitronix->chip_id, sitronix->Num_X, sitronix->Num_Y); return 0; }
int vhost_load_allowed_methods(const char *m, ec_method_mask_t *pmm) { size_t nelems, i; char **tv = NULL; dbg_return_if(m == NULL, -1); dbg_return_if(pmm == NULL, -1); *pmm = EC_METHOD_MASK_UNSET; dbg_err_if(u_strtok(m, " \t", &tv, &nelems)); for (i = 0; i < nelems; ++i) { if (!strcasecmp(tv[i], "GET")) *pmm |= EC_GET_MASK; else if (!strcasecmp(tv[i], "POST")) *pmm |= EC_POST_MASK; else if (!strcasecmp(tv[i], "PUT")) *pmm |= EC_PUT_MASK; else if (!strcasecmp(tv[i], "DELETE")) *pmm |= EC_DELETE_MASK; else dbg_err("unknown method %s", tv[i]); } u_strtok_cleanup(tv, nelems); return 0; err: if (tv) u_strtok_cleanup(tv, nelems); return -1; }
/* * Course of action when leaving the CS. */ int process_ev_exited_cr(void * cookie) { generic_message_t msg = {}; char msctext[MAX_MSC_TEXT] = {}; int err = 0; dbg_msg("Entered DME_EV_EXITED_CRITICAL_REG"); if (fsm_state != PS_EXECUTING) { dbg_err("Fatal error: DME_EV_EXITED_CRITICAL_REG occurred while not in EXECUTING state."); return (err = ERR_FATAL); } /* inform the supervisor */ supervisor_send_inform_message(DME_EV_EXITED_CRITICAL_REG); /* Switch state to IDLE */ fsm_state = PS_IDLE; /* Do whatever IPC deems necessary */ generic_msg_set(&msg, MTYPE_RELEASE, msctext, sizeof(msctext)); err = dme_broadcast_msg((uint8*)&msg, GENERIC_MSG_LEN, msctext); return err; }
/** * do_sync_erase - synchronously erase a physical eraseblock. * @ubi: UBI device description object * @pnum: the physical eraseblock number to erase * * This function synchronously erases physical eraseblock @pnum and returns * zero in case of success and a negative error code in case of failure. If * %-EIO is returned, the physical eraseblock most probably went bad. */ static int do_sync_erase(struct ubi_device *ubi, int pnum) { int err, retries = 0; struct erase_info ei; wait_queue_head_t wq; dbg_io("erase PEB %d", pnum); retry: init_waitqueue_head(&wq); memset(&ei, 0, sizeof(struct erase_info)); ei.mtd = ubi->mtd; ei.addr = (loff_t)pnum * ubi->peb_size; ei.len = ubi->peb_size; ei.callback = erase_callback; ei.priv = (unsigned long)&wq; err = ubi->mtd->erase(ubi->mtd, &ei); if (err) { if (retries++ < UBI_IO_RETRIES) { dbg_io("error %d while erasing PEB %d, retry", err, pnum); yield(); goto retry; } ubi_err("cannot erase PEB %d, error %d", pnum, err); ubi_dbg_dump_stack(); return err; } err = wait_event_interruptible(wq, ei.state == MTD_ERASE_DONE || ei.state == MTD_ERASE_FAILED); if (err) { ubi_err("interrupted PEB %d erasure", pnum); return -EINTR; } if (ei.state == MTD_ERASE_FAILED) { if (retries++ < UBI_IO_RETRIES) { dbg_io("error while erasing PEB %d, retry", pnum); yield(); goto retry; } ubi_err("cannot erase PEB %d", pnum); ubi_dbg_dump_stack(); return -EIO; } err = ubi_dbg_check_all_ff(ubi, pnum, 0, ubi->peb_size); if (err) return err; if (ubi_dbg_is_erase_failure() && !err) { dbg_err("cannot erase PEB %d (emulated)", pnum); return -EIO; } return 0; }
/** * ubifs_scan_a_node - scan for a node or padding. * @c: UBIFS file-system description object * @buf: buffer to scan * @len: length of buffer * @lnum: logical eraseblock number * @offs: offset within the logical eraseblock * @quiet: print no messages * * This function returns a scanning code to indicate what was scanned. */ int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, int offs, int quiet) { struct ubifs_ch *ch = buf; uint32_t magic; magic = le32_to_cpu(ch->magic); if (magic == 0xFFFFFFFF) { dbg_scan("hit empty space"); return SCANNED_EMPTY_SPACE; } if (magic != UBIFS_NODE_MAGIC) return scan_padding_bytes(buf, len); if (len < UBIFS_CH_SZ) return SCANNED_GARBAGE; dbg_scan("scanning %s", dbg_ntype(ch->node_type)); if (ubifs_check_node(c, buf, lnum, offs, quiet, 1)) return SCANNED_A_CORRUPT_NODE; if (ch->node_type == UBIFS_PAD_NODE) { struct ubifs_pad_node *pad = buf; int pad_len = le32_to_cpu(pad->pad_len); int node_len = le32_to_cpu(ch->len); /* Validate the padding node */ if (pad_len < 0 || offs + node_len + pad_len > c->leb_size) { if (!quiet) { ubifs_err("bad pad node at LEB %d:%d", lnum, offs); dbg_dump_node(c, pad); } return SCANNED_A_BAD_PAD_NODE; } /* Make the node pads to 8-byte boundary */ if ((node_len + pad_len) & 7) { if (!quiet) { dbg_err("bad padding length %d - %d", offs, offs + node_len + pad_len); } return SCANNED_A_BAD_PAD_NODE; } dbg_scan("%d bytes padded, offset now %d", pad_len, ALIGN(offs + node_len + pad_len, 8)); return node_len + pad_len; } return SCANNED_A_NODE; }
static int handle_supervisor_msg(void * cookie) { const buff_t * buff = (buff_t *)cookie; sup_message_t srcmsg = {}; int ret = 0; if (!buff) { dbg_err("Message is empty!"); return ERR_RECV_MSG; } /* record the time */ clock_gettime(CLOCK_REALTIME, &sup_tstamp); ret = sup_msg_parse(*buff, &srcmsg); if (srcmsg.msg_type == DME_SEV_ENDSIMULATION) { exit_request = TRUE; return ret; } switch(fsm_state) { case PS_IDLE: if (srcmsg.msg_type == DME_SEV_SYNCRO) { sup_syncro.tv_sec = srcmsg.sec_tdelta; sup_syncro.tv_nsec = srcmsg.nsec_tdelta; } else if (srcmsg.msg_type == DME_EV_WANT_CRITICAL_REG) { critical_region_simulated_duration = srcmsg.sec_tdelta; ret = handle_event(DME_EV_WANT_CRITICAL_REG, NULL); } break; /* The supervisor should not send a message in these states */ case PS_PENDING: case PS_EXECUTING: dbg_msg("Ignoring message from supervisor (not in IDLE state)."); break; default: dbg_err("Fatal error: FSM state corrupted"); ret = ERR_FATAL; break; } return ret; }
static int pixcir_auto_clb(struct pixcir_data *pixcir) { int ret; u8 cmd[2]={0x3a,0x03}; ret = pixcir_write(pixcir, cmd, sizeof(cmd)); if(ret <= 0) dbg_err("Pixcir initialize failed.\n"); mdelay(500); return ret; }
static int pixcir_sysfs_create_group(struct pixcir_data *pixcir, const struct attribute_group *group) { int err; pixcir->kobj = kobject_create_and_add("wmtts", NULL) ; if(!pixcir->kobj){ dbg_err("kobj create failed.\n"); return -ENOMEM; } /* Register sysfs hooks */ err = sysfs_create_group(pixcir->kobj, group); if (err < 0){ kobject_del(pixcir->kobj); dbg_err("Create sysfs group failed!\n"); return -ENOMEM; } return 0; }
static int pixcir_active(struct pixcir_data *pixcir) { int ret; u8 cmd[3]={0x33,0,0x0a}; ret = pixcir_write(pixcir, cmd, sizeof(cmd)); if(ret <= 0) dbg_err("Pixcir initialize failed.\n"); return ret; }
static int __init pixcir_init(void) { int ret = -ENOMEM; struct pixcir_data *pixcir=NULL; pixcir = kzalloc(sizeof(struct pixcir_data), GFP_KERNEL); if(!pixcir){ dbg_err("mem alloc failed.\n"); return -ENOMEM; } pContext = pixcir; ret = check_touch_env(pixcir); if(ret < 0) goto exit_free_mem; ret = platform_device_register(&pixcir_device); if(ret){ dbg_err("register platform drivver failed!\n"); goto exit_free_mem; } platform_set_drvdata(&pixcir_device, pixcir); ret = platform_driver_register(&pixcir_driver); if(ret){ dbg_err("register platform device failed!\n"); goto exit_unregister_pdev; } return ret; exit_unregister_pdev: platform_device_unregister(&pixcir_device); exit_free_mem: kfree(pixcir); pContext = NULL; return ret; }
/** * ubifs_scanned_corruption - print information after UBIFS scanned corruption. * @c: UBIFS file-system description object * @lnum: LEB number of corruption * @offs: offset of corruption * @buf: buffer containing corruption */ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, void *buf) { int len; ubifs_err("corruption at LEB %d:%d", lnum, offs); if (dbg_failure_mode) return; len = c->leb_size - offs; if (len > 8192) len = 8192; dbg_err("first %d bytes from LEB %d:%d", len, lnum, offs); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1); }
/* * vt1603_set_reg8 - set register value of vt1603 * @bat_drv: vt1603 driver data * @reg: vt1603 register address * @val: value register will be set */ static int vt1603_set_reg8(struct vt1603_bat_drvdata *bat_drv, u8 reg, u8 val) { int ret =0; if (bat_drv->tdev) ret = bat_drv->tdev->reg_write(bat_drv->tdev, reg, val); if(ret){ dbg_err("vt1603 battery write error, errno%d\n", ret); return ret; } return 0; }
static int vt1603_read8(struct vt1603_bat_drvdata *bat_drv, u8 reg,u8* data) { int ret = 0; if (bat_drv->tdev) ret = bat_drv->tdev->reg_read(bat_drv->tdev, reg, data); if (ret){ dbg_err("vt1603 battery read error, errno%d\n", ret); return ret; } return 0; }
static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) { struct ubi_volume_desc *desc = file->private_data; struct ubi_volume *vol = desc->vol; loff_t new_offset; if (vol->updating) { /* Update is in progress, seeking is prohibited */ dbg_err("updating"); return -EBUSY; } switch (origin) { case 0: /* SEEK_SET */ new_offset = offset; break; case 1: /* SEEK_CUR */ new_offset = file->f_pos + offset; break; case 2: /* SEEK_END */ new_offset = vol->used_bytes + offset; break; default: return -EINVAL; } if (new_offset < 0 || new_offset > vol->used_bytes) { dbg_err("bad seek %lld", new_offset); return -EINVAL; } dbg_msg("seek volume %d, offset %lld, origin %d, new offset %lld", vol->vol_id, offset, origin, new_offset); file->f_pos = new_offset; return new_offset; }
/* * This is the algortihm's implementation * Note: the FSM state transition should be done with handle_event(ev, cookie) * and would be the last operation in the logical flow of the function. * This in needed to assure that no other message processing is handled * between the state change decision and the actual state change. */ static int handle_peer_msg(void * cookie) { generic_message_t srcmsg = {}; generic_message_t dstmsg = {}; int ret = 0; const buff_t * buff = (buff_t *)cookie; int ix; if (!buff) { dbg_err("Message is empty!"); return ERR_RECV_MSG; } /* parse the received buffer in the srcmsg structure */ generic_msg_parse(*buff, &srcmsg); switch(fsm_state) { case PS_IDLE: /* process peer message*/ break; case PS_EXECUTING: /* process peer message*/ break; case PS_PENDING: /* process peer message*/ break; default: dbg_err("Fatal error: FSM state corrupted"); ret = ERR_FATAL; break; } return ret; }
static int sitronix_get_device_status(struct sitronix_data *sitronix) { int ret = 0; uint8_t buf[3]={FIRMWARE_VERSION,0}; ret = sitronix_read(sitronix, buf, 3); if (ret < 0){ dbg_err("read resolution error (%d)\n", ret); return ret; } printk("Firmware version:%02x, Status Reg:%02x,Ctrl Reg:%02x\n", buf[0], buf[1],buf[2]); return 0; }
/* * vt1603_get_reg8 - get register value of vt1603 * @bat_drv: vt1603 driver data * @reg: vt1603 register address */ static u8 vt1603_get_reg8(struct vt1603_bat_drvdata *bat_drv, u8 reg) { u8 val = 0; int ret = 0; if (bat_drv->tdev) ret = bat_drv->tdev->reg_read(bat_drv->tdev, reg, &val); if (ret < 0){ dbg_err("vt1603 battery read error, errno%d\n", ret); return 0; } return val; }
int dme_recv_msg(uint8 ** out_buff, size_t * out_len) { int len = 0; *out_len = 0; /* initialize to 0 just to avoid reading an empty buffer */ /* Determine the length of the packet first */ len = recv(nodes[proc_id].sock_fd, test_buff, MAX_PACK_LEN, MSG_PEEK); if (len <= 0 || !(*out_buff = malloc(len))) { dbg_err("Could not allocate buffer of length %d", len); return ERR_RECV_MSG; } /* Recieve the real data */ if (len != recv(nodes[proc_id].sock_fd, *out_buff, len, 0)) { dbg_err("The expected packet length has changed! How did this happen??"); safe_free(*out_buff); return ERR_RECV_MSG; } /* Now it's safe to report the retrieved buffer length */ *out_len = len; return 0; }
static int pixcir_write(struct pixcir_data *pixcir, u8 *txdata, int length) { int ret; struct i2c_msg msg[1]; msg[0].addr = pixcir->addr; msg[0].flags = 0; msg[0].len = length; msg[0].buf = txdata; ret = wmt_i2c_xfer_continue_if_4(msg, 1, I2C_BUS1); if (ret <= 0) dbg_err("msg i2c read error: %d\n", ret); return ret; }
static int sitronix_get_max_touches(struct sitronix_data *sitronix) { int ret = 0; uint8_t buffer[1]={MAX_NUM_TOUCHES}; ret = sitronix_read(sitronix, buffer, 1); if (ret < 0){ dbg_err("read max touches error (%d)\n", ret); return ret; } sitronix->max_touches = buffer[0]; printk("max touches = %d \n",sitronix->max_touches); return 0; }
static int sitronix_get_fw_revision(struct sitronix_data *sitronix) { int ret = 0; uint8_t buffer[4]={FIRMWARE_REVISION_3,0}; ret = sitronix_read(sitronix, buffer, 4); if (ret < 0){ dbg_err("read fw revision error (%d)\n", ret); return ret; } memcpy(sitronix->fw_revision, buffer, 4); printk("Fw Revision (hex): %x%x%x%x\n", buffer[0], buffer[1], buffer[2], buffer[3]); return 0; }
static int sitronix_get_protocol(struct sitronix_data *sitronix) { int ret = 0; uint8_t buffer[1]={I2C_PROTOCOL}; ret = sitronix_read(sitronix, buffer, 1); if (ret < 0){ dbg_err("read i2c protocol error (%d)\n", ret); return ret; } sitronix->touch_protocol_type = buffer[0] & I2C_PROTOCOL_BMSK; sitronix->sensing_mode = (buffer[0] & (ONE_D_SENSING_CONTROL_BMSK << ONE_D_SENSING_CONTROL_SHFT)) >> ONE_D_SENSING_CONTROL_SHFT; printk("i2c protocol = %d ,sensing mode = %d \n", sitronix->touch_protocol_type, sitronix->sensing_mode); return 0; }
static int sitronix_get_resolution(struct sitronix_data *sitronix) { int ret = 0; uint8_t buffer[3]={XY_RESOLUTION_HIGH}; ret = sitronix_read(sitronix, buffer, 3); if (ret < 0){ dbg_err("read resolution error (%d)\n", ret); return ret; } sitronix->resolution_x = ((buffer[0] & (X_RES_H_BMSK << X_RES_H_SHFT)) << 4) | buffer[1]; sitronix->resolution_y = ((buffer[0] & Y_RES_H_BMSK) << 8) | buffer[2]; printk("Resolution: %d x %d\n", sitronix->resolution_x, sitronix->resolution_y); return 0; }
static int sitronix_write(struct sitronix_data *sitronix, u8 *txdata, int length) { int ret; struct i2c_msg msg[1]; msg[0].addr = sitronix->addr; msg[0].flags = 0; msg[0].len = length; msg[0].buf = txdata; //ret = wmt_i2c_xfer_continue_if_4(msg, 1, I2C_BUS1); ret = i2c_transfer(l_client->adapter, msg, 1); if (ret <= 0) dbg_err("msg i2c read error: %d\n", ret); return ret; }
/* * Send the buffer to node with process_id dest. */ int dme_send_msg(proc_id_t dest, uint8 * buff, size_t len, char * const msctext) { dbg_msg("send_msg(dest=%llu, buff@%p, len=%u)", dest, buff, len); int maxcount = nodes_count; struct sockaddr * dest_addr = NULL; if (dest < 0 || dest > maxcount) { dbg_err("Destination process id is out of bounds: %llu not in [0..%d]", dest, maxcount); return ERR_SEND_MSG; } dest_addr = (struct sockaddr *)&nodes[dest].listen_addr; msc_msg(proc_id, dest, msctext); sendto(nodes[proc_id].sock_fd, buff, len, 0, dest_addr, sizeof(*dest_addr)); return 0; }
/** * verify_mkvol_req - verify volume creation request. * @ubi: UBI device description object * @req: the request to check * * This function zero if the request is correct, and %-EINVAL if not. */ static int verify_mkvol_req(const struct ubi_device *ubi, const struct ubi_mkvol_req *req) { int n, err = -EINVAL; if (req->bytes < 0 || req->alignment < 0 || req->vol_type < 0 || req->name_len < 0) goto bad; if ((req->vol_id < 0 || req->vol_id >= ubi->vtbl_slots) && req->vol_id != UBI_VOL_NUM_AUTO) goto bad; if (req->alignment == 0) goto bad; if (req->bytes == 0) goto bad; if (req->vol_type != UBI_DYNAMIC_VOLUME && req->vol_type != UBI_STATIC_VOLUME) goto bad; if (req->alignment > ubi->leb_size) goto bad; n = req->alignment % ubi->min_io_size; if (req->alignment != 1 && n) goto bad; if (req->name_len > UBI_VOL_NAME_MAX) { err = -ENAMETOOLONG; goto bad; } return 0; bad: dbg_err("bad volume creation request"); ubi_dbg_dump_mkvol_req(req); return err; }