devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
To: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: "Linus Walleij"
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	"Shubhrajyoti Datta"
	<omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Carlos Chinea"
	<cch.devel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Tony Lindgren" <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
	"grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	"rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org"
	<rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	"Pawel Moll" <Pawel.Moll-5wv7dgnIgG8@public.gmane.org>,
	"Stephen Warren"
	<swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	"Ian Campbell"
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	"Rob Landley" <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"Pali Rohár" <pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Ивайло Димитров" <freemangordon-uiMcrn6V0Vs@public.gmane.org>,
	"Joni Lapilainen"
	<joni.lapilainen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Aaro Koskinen" <aaro.koskinen-X3B1VOXEql0@public.gmane.org>
Subject: Re: [PATCHv1 5/6] HSI: Introduce OMAP SSI driver
Date: Wed, 26 Feb 2014 23:49:25 +0100	[thread overview]
Message-ID: <20140226224924.GA12143@earth.universe> (raw)
In-Reply-To: <20140224155132.GK28555-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4841 bytes --]

Hi Mark,

On Mon, Feb 24, 2014 at 03:51:32PM +0000, Mark Rutland wrote:
> > +       irq = platform_get_resource_byname(pd, IORESOURCE_IRQ, "gdd_mpu");
> > +       if (!irq) {
> > +               dev_err(&pd->dev, "GDD IRQ resource missing\n");
> > +               err = -ENXIO;
> > +               goto out_err;
> > +       }
> > +       omap_ssi->gdd_irq = irq->start;
> 
> You can use platform_get_irq_byname here.

Right. Will be changed in PATCHv2.

> > +static inline int ssi_of_get_available_child_count(const struct device_node *np)
> > +{
> > +       struct device_node *child;
> > +       int num = 0;
> > +
> > +       for_each_child_of_node(np, child)
> > +               if (of_device_is_available(child))
> > +                       num++;
> > +
> > +       return num;
> > +}
> 
> You can find of_get_available_child_count in <linux/of.h>.

That did not exist when I started with the DT conversion of the
driver.

> That said, this seems to be trying to count the number of ports,
> which should all be compatible with "ti,omap3-ssi-port", no?
> 
> So maybe you should count all available child nodes compatible with
> that.

I updated the function to check the compatible string
and use for_each_available_child_of_node(), which has
also been added after I wrote this function.

> > +static int __init ssi_probe(struct platform_device *pd)
> > +{
> > +       struct device_node *np = pd->dev.of_node;
> > +       struct hsi_controller *ssi;
> > +       int err;
> > +       int num_ports;
> > +
> > +       if (!np) {
> > +               dev_err(&pd->dev, "missing device tree data\n");
> > +               return -EINVAL;
> > +       }
> > +
> > +       num_ports = ssi_of_get_available_child_count(np);
> > +
> > +       ssi = hsi_alloc_controller(num_ports, GFP_KERNEL);
> > +       if (!ssi) {
> > +               dev_err(&pd->dev, "No memory for controller\n");
> > +               return -ENOMEM;
> > +       }
> > +
> > +       platform_set_drvdata(pd, ssi);
> > +
> > +       err = ssi_add_controller(ssi, pd);
> > +       if (err < 0)
> > +               goto out1;
> > +
> > +       pm_runtime_irq_safe(&pd->dev);
> > +       pm_runtime_enable(&pd->dev);
> > +
> > +       err = ssi_hw_init(ssi);
> > +       if (err < 0)
> > +               goto out2;
> > +#ifdef CONFIG_DEBUG_FS
> > +       err = ssi_debug_add_ctrl(ssi);
> > +       if (err < 0)
> > +               goto out2;
> > +#endif
> > +
> > +       err = of_platform_populate(pd->dev.of_node, NULL, NULL, &pd->dev);
> 
> I'm not keen on doing this because it allows arbitrary devices which are
> not ssi ports to be placed in the ssi host controller node that will be
> probed, which is nonsensical and something I'd like to avoid by
> construction.
> 
> Is there any reason the ports have to be platform devices at all?

not strictly, but I get system resources via platform_get_resource_byname.

> If so, is there no way we can register them directly and skip any other
> devices?

I set the second parameter (matches) of the of_platform_populate()
call to a table containing the ssi-port compatible value.

> > +static int __exit ssi_remove(struct platform_device *pd)
> > +{
> > +       struct hsi_controller *ssi = platform_get_drvdata(pd);
> > +
> > +#ifdef CONFIG_DEBUG_FS
> > +       ssi_debug_remove_ctrl(ssi);
> > +#endif
> > +       ssi_remove_controller(ssi);
> > +       platform_set_drvdata(pd, NULL);
> > +
> > +       pm_runtime_disable(&pd->dev);
> > +
> > +       /* cleanup of of_platform_populate() call */
> > +       device_for_each_child(&pd->dev, NULL, ssi_remove_ports);
> 
> This would certainly be broken for a non ssi port device.

I never intended to support other subdevices, but this only
unregisters each subdevice, so its probably safe...

> > +static int omap_ssi_port_runtime_suspend(struct device *dev)
> > +{
> > +       struct hsi_port *port = dev_get_drvdata(dev);
> > +       struct omap_ssi_port *omap_port = hsi_port_drvdata(port);
> > +       struct hsi_controller *ssi = to_hsi_controller(port->device.parent);
> > +       struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi);
> > +
> > +       dev_dbg(dev, "port runtime suspend!\n");
> > +
> > +       ssi_set_port_mode(omap_port, SSI_MODE_SLEEP);
> > +       if (omap_ssi->get_loss)
> > +               omap_port->loss_count =
> > +                               (*omap_ssi->get_loss)(ssi->device.parent);
> 
> You don't need to do (*struct->func)(args) when invoking a function
> pointer. You can jsut have struct->func(args) as we do elsewhere. This
> can be:
> 
>   omap_ssi->get_loss(ssi->device.parent)
> 
> This should be fixed up in the other sites too.

Thanks, fixed everywhere.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2014-02-26 22:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-23 23:49 [PATCHv1 0/6] OMAP SSI driver Sebastian Reichel
2014-02-23 23:49 ` [PATCHv1 1/6] HSI: add Device Tree support for HSI clients Sebastian Reichel
2014-02-24 15:09   ` Mark Rutland
2014-02-25  0:47   ` Rob Herring
2014-02-23 23:49 ` [PATCHv1 2/6] HSI: method to unregister clients from an hsi port Sebastian Reichel
2014-02-23 23:49 ` [PATCHv1 3/6] HSI: hsi-char: add Device Tree support Sebastian Reichel
2014-02-24 15:13   ` Mark Rutland
     [not found]     ` <20140224151301.GJ28555-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2014-02-27  0:24       ` Sebastian Reichel
2014-02-23 23:49 ` [PATCHv1 4/6] HSI: hsi-char: fix driver for multiport scenarios Sebastian Reichel
2014-02-23 23:50 ` [PATCHv1 5/6] HSI: Introduce OMAP SSI driver Sebastian Reichel
     [not found]   ` <1393199401-27197-6-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2014-02-24 15:51     ` Mark Rutland
2014-02-24 15:56       ` Nishanth Menon
2014-02-24 19:42         ` Sebastian Reichel
     [not found]       ` <20140224155132.GK28555-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2014-02-26 22:49         ` Sebastian Reichel [this message]
2014-02-23 23:50 ` [PATCHv1 6/6] Documentation: DT: omap-ssi binding documentation Sebastian Reichel
2014-03-09 22:25 ` [PATCHv2 0/6] OMAP SSI driver Sebastian Reichel
2014-03-09 22:25   ` [PATCHv2 1/6] Documentation: HSI: Add some general description for the HSI subsystem Sebastian Reichel
2014-03-09 22:25   ` [PATCHv2 2/6] HSI: Add function to register HSI clients from DT Sebastian Reichel
     [not found]   ` <1394403956-17297-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2014-03-09 22:25     ` [PATCHv2 3/6] HSI: method to unregister clients from an hsi port Sebastian Reichel
2014-03-09 22:25   ` [PATCHv2 4/6] HSI: hsi-char: fix driver for multiport scenarios Sebastian Reichel
2014-03-09 22:25   ` [PATCHv2 5/6] HSI: Introduce OMAP SSI driver Sebastian Reichel
2014-03-09 22:25   ` [PATCHv2 6/6] Documentation: DT: omap-ssi binding documentation Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140226224924.GA12143@earth.universe \
    --to=sre-8fiuurrzop0dnm+yrofe0a@public.gmane.org \
    --cc=Pawel.Moll-5wv7dgnIgG8@public.gmane.org \
    --cc=aaro.koskinen-X3B1VOXEql0@public.gmane.org \
    --cc=cch.devel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=freemangordon-uiMcrn6V0Vs@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=joni.lapilainen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).