[PATCH 1/2] ARM: socfpga: Add driver for the L3 interconnect

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Wed Oct 29 14:12:28 PDT 2014


Hello Steffen,

On Wed, Oct 29, 2014 at 09:51:03PM +0100, Steffen Trumtrar wrote:
> > > +
> > > +int socfpga_l3nic_regmap_by_phandle(struct device_node *np,
> > > +				    struct regmap **regmap,
> > > +				    const char *name)
> > > +{
> > 
> > This could return the regmap or ERR_PTR(-ENODEV) and just
> > have the np and name parameter, similar to 
> > syscon_regmap_lookup_by_phandle.
> >
> 
> I wanted to do that, but I also want to propagate the return
> value of socfpga_gpv_device_by_phandle and this doesn't
> seem to work than. Open for suggestions, though.
Doesn't the following work:

	struct regmap *socfpga_l3nic_regmap_by_phandle(struct device_node *np,
						       const char *name)
	{
		struct socfpga_l3nic *l3nic;
		struct platform_device *pdev;

		pdev = socfpga_gpv_device_by_phandle(np, name);
		if (!pdev)
			/* it's wrong to apply ERR_PTR to NULL */
			return ERR_PTR(-ENODEV);

		l3nic = dev_get_drvdata(&pdev->dev);
		if (!l3nic)
			return ERR_PTR(-EINVAL);

		/* do you need to check l3nic->regmap for being != NULL? */
		return l3nic->regmap;
	}

?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list