Re: [PATCH v4 3/5] drm: add SimpleDRM driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, Aug 22, 2016 at 3:25 PM, Noralf Trønnes <noralf@xxxxxxxxxxx> 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@xxxxxxxxx
> Cc: libv@xxxxxxxxx
> Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx>

[...]

> +       /* 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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux