Re: [RFC PATCH v8 03/10] dpll: core: Add DPLL framework base functions
From: Jiri Pirko <jiri@resnulli.us>
Date: 2023-06-11 10:01:27
Also in:
intel-wired-lan, linux-clk, linux-doc, linux-rdma, lkml
Fri, Jun 09, 2023 at 02:18:46PM CEST, arkadiusz.kubalewski@intel.com wrote:
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
[...]
+ * dpll_xa_ref_dpll_first - find first record of given xarray + * @xa_refs: xarray + * + * Context: shall be called under a lock (dpll_lock) + * Return: first element on given xaaray
typo: xarray
+ */ +struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs)
[...]
+/** + * dpll_device_get - find existing or create new dpll device + * @clock_id: clock_id of creator + * @device_idx: idx given by device driver + * @module: reference to registering module + * + * Get existing object of a dpll device, unique for given arguments. + * Create new if doesn't exist yet. + * + * Context: Acquires a lock (dpll_lock) + * Return: + * * valid dpll_device struct pointer if succeeded + * * ERR_PTR(-ENOMEM) - failed memory allocation
Yeah, that is kind of obvious, isn't? Really, drop this pointless coments.
+ * * ERR_PTR(X) - failed allocation on dpll's xa + */ +struct dpll_device * +dpll_device_get(u64 clock_id, u32 device_idx, struct module *module)
[...]
+/** + * dpll_pin_register - register the dpll pin in the subsystem + * @dpll: pointer to a dpll + * @pin: pointer to a dpll pin + * @ops: ops for a dpll pin ops + * @priv: pointer to private information of owner + * + * Context: Acquires a lock (dpll_lock) + * Return: + * * 0 on success + * * -EINVAL - missing pin ops + * * -ENOMEM - failed to allocate memory
Does not make sense to assign one errno to one specific error. Avoid tables like this.
+ */
+int
+dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
+ const struct dpll_pin_ops *ops, void *priv)
+{
+ int ret;
+
+ mutex_lock(&dpll_lock);
+ if (WARN_ON(!(dpll->module == pin->module &&
+ dpll->clock_id == pin->clock_id)))
+ ret = -EFAULT;-EINVAL;
+ else + ret = __dpll_pin_register(dpll, pin, ops, priv); + mutex_unlock(&dpll_lock); + + return ret; +}
[...]