Lines Matching refs:bin
23 static void *bin_alloc(struct bin_container *bin, size_t len) in bin_alloc() argument
29 if (bin->end - bin->now < len) in bin_alloc()
32 ptr = bin->now; in bin_alloc()
33 bin->now += len; in bin_alloc()
38 static void bin_reserve(struct bin_container *bin, size_t len) in bin_reserve() argument
40 bin->size += ALIGN(len, 8); in bin_reserve()
43 static int bin_backing_alloc(struct bin_container *bin) in bin_backing_alloc() argument
45 bin->base = bin->now = kvzalloc(bin->size, GFP_KERNEL); in bin_backing_alloc()
46 if (!bin->base) in bin_backing_alloc()
49 bin->end = bin->base + bin->size; in bin_backing_alloc()
131 static int ccs_data_parse_version(struct bin_container *bin, in ccs_data_parse_version() argument
141 if (!bin->base) { in ccs_data_parse_version()
142 bin_reserve(bin, sizeof(*ccsdata->version)); in ccs_data_parse_version()
146 ccsdata->version = bin_alloc(bin, sizeof(*ccsdata->version)); in ccs_data_parse_version()
212 static int ccs_data_parse_regs(struct bin_container *bin, in ccs_data_parse_regs() argument
221 if (bin->base && __regs) { in ccs_data_parse_regs()
222 regs = regs_base = bin_alloc(bin, sizeof(*regs) * *__num_regs); in ccs_data_parse_regs()
285 if (!bin->base) { in ccs_data_parse_regs()
286 bin_reserve(bin, len); in ccs_data_parse_regs()
293 regs->value = bin_alloc(bin, len); in ccs_data_parse_regs()
305 if (!bin->base) in ccs_data_parse_regs()
306 bin_reserve(bin, sizeof(*regs) * num_regs); in ccs_data_parse_regs()
311 if (bin->base && __regs) { in ccs_data_parse_regs()
321 static int ccs_data_parse_reg_rules(struct bin_container *bin, in ccs_data_parse_reg_rules() argument
329 if (!bin->base) in ccs_data_parse_reg_rules()
330 return ccs_data_parse_regs(bin, NULL, NULL, payload, endp, dev); in ccs_data_parse_reg_rules()
332 rval = ccs_data_parse_regs(bin, NULL, __num_regs, payload, endp, dev); in ccs_data_parse_reg_rules()
336 return ccs_data_parse_regs(bin, __regs, __num_regs, payload, endp, in ccs_data_parse_reg_rules()
347 static int ccs_data_parse_ffd(struct bin_container *bin, in ccs_data_parse_ffd() argument
365 if (!bin->base) { in ccs_data_parse_ffd()
366 bin_reserve(bin, sizeof(**ffd)); in ccs_data_parse_ffd()
367 bin_reserve(bin, __ffd->num_column_descs * in ccs_data_parse_ffd()
369 bin_reserve(bin, __ffd->num_row_descs * in ccs_data_parse_ffd()
375 *ffd = bin_alloc(bin, sizeof(**ffd)); in ccs_data_parse_ffd()
383 (*ffd)->column_descs = bin_alloc(bin, __ffd->num_column_descs * in ccs_data_parse_ffd()
391 (*ffd)->row_descs = bin_alloc(bin, __ffd->num_row_descs * in ccs_data_parse_ffd()
405 static int ccs_data_parse_pdaf_readout(struct bin_container *bin, in ccs_data_parse_pdaf_readout() argument
415 if (!bin->base) { in ccs_data_parse_pdaf_readout()
416 bin_reserve(bin, sizeof(**pdaf_readout)); in ccs_data_parse_pdaf_readout()
418 *pdaf_readout = bin_alloc(bin, sizeof(**pdaf_readout)); in ccs_data_parse_pdaf_readout()
426 return ccs_data_parse_ffd(bin, !bin->base ? NULL : &(*pdaf_readout)->ffd, in ccs_data_parse_pdaf_readout()
430 static int ccs_data_parse_rules(struct bin_container *bin, in ccs_data_parse_rules() argument
440 if (bin->base) { in ccs_data_parse_rules()
442 bin_alloc(bin, sizeof(*rules) * *__num_rules); in ccs_data_parse_rules()
485 if (!bin->base) { in ccs_data_parse_rules()
486 bin_reserve(bin, in ccs_data_parse_rules()
499 if_rule = bin_alloc(bin, in ccs_data_parse_rules()
520 rval = ccs_data_parse_reg_rules(bin, &rules->read_only_regs, in ccs_data_parse_rules()
529 rval = ccs_data_parse_ffd(bin, &rules->frame_format, in ccs_data_parse_rules()
537 rval = ccs_data_parse_reg_rules(bin, in ccs_data_parse_rules()
547 rval = ccs_data_parse_pdaf_readout(bin, in ccs_data_parse_rules()
564 if (!bin->base) { in ccs_data_parse_rules()
565 bin_reserve(bin, sizeof(*rules) * num_rules); in ccs_data_parse_rules()
577 static int ccs_data_parse_pdaf(struct bin_container *bin, struct ccs_pdaf_pix_loc **pdaf, in ccs_data_parse_pdaf() argument
592 if (bin->base) { in ccs_data_parse_pdaf()
593 *pdaf = bin_alloc(bin, sizeof(**pdaf)); in ccs_data_parse_pdaf()
597 bin_reserve(bin, sizeof(**pdaf)); in ccs_data_parse_pdaf()
604 if (bin->base) { in ccs_data_parse_pdaf()
619 if (bin->base) { in ccs_data_parse_pdaf()
621 bin_alloc(bin, in ccs_data_parse_pdaf()
627 bin_reserve(bin, sizeof(struct ccs_pdaf_pix_loc_block_desc_group) * in ccs_data_parse_pdaf()
643 if (bin->base) { in ccs_data_parse_pdaf()
652 if (bin->base) { in ccs_data_parse_pdaf()
654 bin_alloc(bin, in ccs_data_parse_pdaf()
660 bin_reserve(bin, sizeof(struct ccs_pdaf_pix_loc_block_desc) * in ccs_data_parse_pdaf()
673 if (!bin->base) in ccs_data_parse_pdaf()
692 if (bin->base) { in ccs_data_parse_pdaf()
694 bin_alloc(bin, in ccs_data_parse_pdaf()
701 bin_reserve(bin, sizeof(struct ccs_pdaf_pix_loc_pixel_desc_group) * in ccs_data_parse_pdaf()
712 if (bin->base) { in ccs_data_parse_pdaf()
715 bin_alloc(bin, in ccs_data_parse_pdaf()
722 bin_reserve(bin, sizeof(struct ccs_pdaf_pix_loc_pixel_desc) * in ccs_data_parse_pdaf()
734 if (!bin->base) in ccs_data_parse_pdaf()
752 static int ccs_data_parse_license(struct bin_container *bin, in ccs_data_parse_license() argument
760 if (!bin->base) { in ccs_data_parse_license()
761 bin_reserve(bin, size); in ccs_data_parse_license()
765 license = bin_alloc(bin, size); in ccs_data_parse_license()
793 static int __ccs_data_parse(struct bin_container *bin, in __ccs_data_parse() argument
813 if (!bin->base) in __ccs_data_parse()
824 bin->base ? false : verbose); in __ccs_data_parse()
833 rval = ccs_data_parse_version(bin, ccsdata, payload, in __ccs_data_parse()
840 bin, &ccsdata->sensor_read_only_regs, in __ccs_data_parse()
848 bin, &ccsdata->sensor_manufacturer_regs, in __ccs_data_parse()
856 bin, &ccsdata->module_read_only_regs, in __ccs_data_parse()
864 bin, &ccsdata->module_manufacturer_regs, in __ccs_data_parse()
871 rval = ccs_data_parse_pdaf(bin, &ccsdata->sensor_pdaf, in __ccs_data_parse()
877 rval = ccs_data_parse_pdaf(bin, &ccsdata->module_pdaf, in __ccs_data_parse()
884 bin, &ccsdata->sensor_rules, in __ccs_data_parse()
892 bin, &ccsdata->module_rules, in __ccs_data_parse()
899 rval = ccs_data_parse_license(bin, &ccsdata->license, in __ccs_data_parse()
935 struct bin_container bin = { 0 }; in ccs_data_parse() local
938 rval = __ccs_data_parse(&bin, ccsdata, data, len, dev, verbose); in ccs_data_parse()
942 rval = bin_backing_alloc(&bin); in ccs_data_parse()
946 rval = __ccs_data_parse(&bin, ccsdata, data, len, dev, false); in ccs_data_parse()
953 if (bin.now != bin.end) { in ccs_data_parse()
956 bin.base, bin.now, bin.end); in ccs_data_parse()
960 ccsdata->backing = bin.base; in ccs_data_parse()
965 kvfree(bin.base); in ccs_data_parse()