Re: [PATCH 3/7] soc: qcom: add QCOM PBS driver

From: Krzysztof Kozlowski
Date: Sat Jun 24 2023 - 06:01:51 EST


On 24/06/2023 11:55, Krzysztof Kozlowski wrote:
>> +/**
>> + * get_pbs_client_device() - Get the PBS device used by client
>> + * @dev: Client device
>> + *
>> + * This function is used to get the PBS device that is being
>> + * used by the client.
>> + *
>> + * Returns: pbs_dev on success, ERR_PTR on failure
>> + */
>> +struct pbs_dev *get_pbs_client_device(struct device *dev)
>> +{
>> + struct device_node *pbs_dev_node;
>> + struct pbs_dev *pbs;
>> +
>> + pbs_dev_node = of_parse_phandle(dev->of_node, "qcom,pbs-client", 0);
>> + if (!pbs_dev_node) {
>> + pr_err("Missing qcom,pbs-client property\n");
>> + return ERR_PTR(-ENODEV);
>> + }
>> +
>> + mutex_lock(&pbs_list_lock);
>> + list_for_each_entry(pbs, &pbs_dev_list, link) {
>
> It does not make sense. You have the reference to the device, so you
> have the pbs (via container_of). Don't add some
> global-list-lookup-functions.
>
> Look for example at Abel Vesa's ICE patchset.

To be specific:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/soc/qcom/ice.c?h=v6.4-rc7#n293

(+CC Abel)

Best regards,
Krzysztof