lkml.org 
[lkml]   [2023]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v8 03/10] dpll: core: Add DPLL framework base functions
On Fri,  9 Jun 2023 14:18:46 +0200 Arkadiusz Kubalewski wrote:
> + xa_for_each(xa_pins, i, ref) {
> + if (ref->pin != pin)
> + continue;
> + reg = dpll_pin_registration_find(ref, ops, priv);
> + if (reg) {
> + refcount_inc(&ref->refcount);
> + return 0;
> + }
> + ref_exists = true;
> + break;
> + }
> +
> + if (!ref_exists) {
> + ref = kzalloc(sizeof(*ref), GFP_KERNEL);
> + if (!ref)
> + return -ENOMEM;
> + ref->pin = pin;
> + INIT_LIST_HEAD(&ref->registration_list);
> + ret = xa_insert(xa_pins, pin->pin_idx, ref, GFP_KERNEL);
> + if (ret) {
> + kfree(ref);
> + return ret;
> + }
> + refcount_set(&ref->refcount, 1);
> + }
> +
> + reg = kzalloc(sizeof(*reg), GFP_KERNEL);

Why do we have two structures - ref and reg?

> + if (!reg) {
> + if (!ref_exists)
> + kfree(ref);

ref has already been inserted into xa_pins

> + return -ENOMEM;

\
 
 \ /
  Last update: 2023-06-13 01:45    [W:0.618 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site