Re: [PATCH v3 2/8] w1: Add w1_find_master_device

Krzysztof Kozlowski
2024-03-15T20:14:35Z

On 15/03/2024 19:49, Ayush Singh wrote:
> Add helper to find w1_master from w1_bus_master, which is present in
> drvdata of platform device.

Who needs this?

>
> Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
> Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
> ---
> drivers/w1/w1.c | 6 +++---
> drivers/w1/w1_int.c | 27 +++++++++++++++++++++++++++
> include/linux/w1.h | 1 +
> 3 files changed, 31 insertions(+), 3 deletions(-)

Why is this in the patchset? What are the dependencies? Please clearly
express dependencies between patches or merging needs in cover letter.
Otherwise please do not combine unrelated patches from different
subsystems together. It's make review and merging only difficult.

>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index afb1cc4606c5..ce8a3f93f2ef 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -673,9 +673,9 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
> sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node,
> sl->family->of_match_table);
>
> - dev_set_name(&sl->dev, "%02x-%012llx",
> - (unsigned int) sl->reg_num.family,
> - (unsigned long long) sl->reg_num.id);
> + dev_set_name(&sl->dev, "%s-%02x-%012llx", sl->master->name,
> + (unsigned int)sl->reg_num.family,
> + (unsigned long long)sl->reg_num.id);
> snprintf(&sl->name[0], sizeof(sl->name),

Why? How is this related to the goal "add a helper"? Where is the helper
used? I don't see. Don't combine unrelated topics in one patch.

> "%02x-%012llx",
> (unsigned int) sl->reg_num.family,
> diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
> index 3a71c5eb2f83..2bfef8e67687 100644
> --- a/drivers/w1/w1_int.c
> +++ b/drivers/w1/w1_int.c
> @@ -242,3 +242,30 @@ void w1_remove_master_device(struct w1_bus_master *bm)
> __w1_remove_master_device(found);
> }
> EXPORT_SYMBOL(w1_remove_master_device);
> +
> +/**
> + * w1_find_master_device() - find a master device
> + * @bm: master bus device to search
> + */
> +struct w1_master *w1_find_master_device(struct w1_bus_master *bm)

Why are you duplicating w1_search_master_id()? Without locking? Sorry,
this looks like you did not look at all at existing code.

Best regards,
Krzysztof