Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1714889

Re: [PATCH 4/4] phy: tegra: use of_device_get_match_data()

From Thierry Reding <thierry.reding@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] phy: tegra: use of_device_get_match_data()
Date 2017-08-18 14:50 +0200
Message-ID <ufOSR-3M9-1@gated-at.bofh.it> (permalink)
References <ucvjI-59r-11@gated-at.bofh.it> <ucvjJ-59r-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Aug 09, 2017 at 05:18:00PM +0800, Chunfeng Yun wrote:
> reduce the boilerplate code to get the specific data
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/tegra/xusb.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

You're not reducing by much here. =)

> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index 3cbcb25..25cdfb1 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  	struct device_node *np = of_node_get(pdev->dev.of_node);
>  	const struct tegra_xusb_padctl_soc *soc;
>  	struct tegra_xusb_padctl *padctl;
> -	const struct of_device_id *match;
>  	struct resource *res;
>  	int err;
>  
> @@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  
>  	of_node_put(np);
>  
> -	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
> -	soc = match->data;
> +	soc = of_device_get_match_data(&pdev->dev);
> +	if (!soc)
> +		return -EINVAL;

This is never going to happen. There will always be a match, otherwise
this function would never be called.

Also, if you omit these last two lines, then you actually do reduce the
boilerplate.

Thierry

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH 4/4] phy: tegra: use of_device_get_match_data() Thierry Reding <thierry.reding@gmail.com> - 2017-08-18 14:50 +0200

csiph-web