[PATCH RFC 1/3] reset: replace boolean parameters with flags parameter
Uwe Kleine-König
u.kleine-koenig at baylibre.com
Sat Jun 22 00:47:18 PDT 2024
Hello Philipp,
I like the idea in general. Just a detail concern down below.
On Fri, Jun 21, 2024 at 04:45:02PM +0200, Philipp Zabel wrote:
> @@ -999,8 +1001,9 @@ static struct reset_controller_dev *__reset_find_rcdev(const struct of_phandle_a
>
> struct reset_control *
> __of_reset_control_get(struct device_node *node, const char *id, int index,
> - bool shared, bool optional, bool acquired)
> + enum reset_control_flags flags)
> {
> + bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
> bool gpio_fallback = false;
> struct reset_control *rstc;
> struct reset_controller_dev *rcdev;
> @@ -1065,7 +1068,7 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
> }
>
> /* reset_list_mutex also protects the rcdev's reset_control list */
> - rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired);
> + rstc = __reset_control_get_internal(rcdev, rstc_id, flags);
If RESET_CONTROL_FLAGS_BIT_OPTIONAL was passed to
__of_reset_control_get(), you're forwarding it to
__reset_control_get_internal(). But the latter doesn't do anything with
that flag. I wonder if the API would be still less prone to error if
you'd filter out RESET_CONTROL_FLAGS_BIT_OPTIONAL before passing to
__reset_control_get_internal() and in __reset_control_get_internal() add
a check for unsupported flags.
> out_unlock:
> mutex_unlock(&reset_list_mutex);
> @@ -1096,8 +1099,9 @@ __reset_controller_by_name(const char *name)
>
> static struct reset_control *
> __reset_control_get_from_lookup(struct device *dev, const char *con_id,
> - bool shared, bool optional, bool acquired)
> + enum reset_control_flags flags)
> {
> + bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
> const struct reset_control_lookup *lookup;
> struct reset_controller_dev *rcdev;
> const char *dev_id = dev_name(dev);
> [...]
> @@ -1422,7 +1423,7 @@ EXPORT_SYMBOL_GPL(of_reset_control_array_get);
> * Returns pointer to allocated reset_control on success or error on failure
> */
> struct reset_control *
> -devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
> +devm_reset_control_array_get(struct device *dev, enum reset_control_flags flags)
> {
> struct reset_control **ptr, *rstc;
>
> @@ -1431,7 +1432,7 @@ devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
> if (!ptr)
> return ERR_PTR(-ENOMEM);
>
> - rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
> + rstc = of_reset_control_array_get(dev->of_node, flags);
Is it an error if the new devm_reset_control_array_get() is called
without RESET_CONTROL_FLAGS_BIT_ACQUIRED in flags?
> if (IS_ERR_OR_NULL(rstc)) {
> devres_free(ptr);
> return rstc;
Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240622/6540407a/attachment.sig>
More information about the linux-arm-kernel
mailing list