linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	David Herrmann <dh.herrmann@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Luc Verhaegen <libv@skynet.be>
Subject: Re: [PATCH v4 3/5] drm: add SimpleDRM driver
Date: Thu, 25 Aug 2016 08:09:53 -0500	[thread overview]
Message-ID: <CAL_JsqL3xc9QwPsDh0GgcC2NjTFE1NLkwy1Ypyn34iNh7atJ+Q@mail.gmail.com> (raw)
In-Reply-To: <1471897525-31118-4-git-send-email-noralf@tronnes.org>

On Mon, Aug 22, 2016 at 3:25 PM, Noralf Trønnes <noralf@tronnes.org> wrote:
> The SimpleDRM driver binds to simple-framebuffer devices and provides a
> DRM/KMS API. It provides only a single CRTC+encoder+connector combination
> plus one initial mode.
>
> Userspace can create dumb-buffers which can be blit into the real
> framebuffer similar to UDL. No access to the real framebuffer is allowed
> (compared to earlier version of this driver) to avoid security issues.
> Furthermore, this way we can support arbitrary modes as long as we have a
> conversion-helper.
>
> The driver was originally written by David Herrmann in 2014.
> My main contribution is to make use of drm_simple_kms_helper and
> rework the probe path to avoid use of the deprecated drm_platform_init()
> and drm_driver.{load,unload}().
> Additions have also been made for later changes to the Device Tree binding
> document, like support for clocks, regulators and having the node under
> /chosen. This code was lifted verbatim from simplefb.c.
>
> Cc: dh.herrmann@gmail.com
> Cc: libv@skynet.be
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

[...]

> +       /* Count the number of regulator supplies */
> +       for_each_property_of_node(np, prop) {
> +               p = strstr(prop->name, SUPPLY_SUFFIX);
> +               if (p && p != prop->name)
> +                       count++;
> +       }

The regulator API should have functions for this rather than open coding it.

> +
> +       if (!count)
> +               return 0;
> +
> +       sdrm->regulators = devm_kcalloc(&pdev->dev, count,
> +                                       sizeof(struct regulator *),
> +                                       GFP_KERNEL);
> +       if (!sdrm->regulators)
> +               return -ENOMEM;
> +
> +       /* Get all the regulators */
> +       for_each_property_of_node(np, prop) {
> +               char name[32]; /* 32 is max size of property name */
> +
> +               p = strstr(prop->name, SUPPLY_SUFFIX);
> +               if (!p || p == prop->name)
> +                       continue;

This too.

> +
> +               strlcpy(name, prop->name,
> +                       strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1);
> +               regulator = devm_regulator_get_optional(&pdev->dev, name);

[...]

> +       if (IS_ENABLED(CONFIG_OF_ADDRESS) && of_chosen) {
> +               struct device_node *np;
> +
> +               for_each_child_of_node(of_chosen, np) {
> +                       if (of_device_is_compatible(np, "simple-framebuffer"))

Rather than exporting of_chosen, this whole chunk can be replaced with
a of_find_compatible_node call. Yes, that would match if
simple-framebuffer exists somewhere else in the DT, but it is not the
kernel's job to do DT validation.

> +                               of_platform_device_create(np, NULL, NULL);
> +               }
> +       }

Rob

  parent reply	other threads:[~2016-08-25 13:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 20:25 [PATCH v4 0/5] drm: add SimpleDRM driver Noralf Trønnes
2016-08-22 20:25 ` [PATCH v4 1/5] of: Add EXPORT_SYMBOL for of_chosen Noralf Trønnes
2016-08-22 20:25 ` [PATCH v4 2/5] drm/fb-helper: Add drm_fb_helper_set_suspend_lock() Noralf Trønnes
2016-08-23  6:07   ` Daniel Vetter
2016-08-22 20:25 ` [PATCH v4 3/5] drm: add SimpleDRM driver Noralf Trønnes
2016-08-23  6:17   ` Daniel Vetter
2016-08-25 22:11     ` Noralf Trønnes
2016-08-26 14:40       ` Daniel Vetter
2016-08-25 13:09   ` Rob Herring [this message]
2016-08-25 18:42     ` Noralf Trønnes
2016-09-01 23:48   ` David Herrmann
2016-09-02  6:11     ` Daniel Vetter
2016-08-22 20:25 ` [PATCH v4 4/5] drm: simpledrm: add fbdev fallback support Noralf Trønnes
2016-08-23  6:10   ` Daniel Vetter
2016-08-22 20:25 ` [PATCH v4 5/5] drm: simpledrm: honour remove_conflicting_framebuffers() Noralf Trønnes
2016-08-23 12:41   ` Daniel Vetter
2016-08-23 17:52     ` Noralf Trønnes
2016-08-23 18:01       ` Daniel Vetter
2016-08-23 19:22         ` Noralf Trønnes

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=CAL_JsqL3xc9QwPsDh0GgcC2NjTFE1NLkwy1Ypyn34iNh7atJ+Q@mail.gmail.com \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=libv@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noralf@tronnes.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).