lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Jul 2021 16:52:07 +0200
From:   Arnd Bergmann <arnd@...nel.org>
To:     Viresh Kumar <viresh.kumar@...aro.org>
Cc:     Jason Wang <jasowang@...hat.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Rob Herring <robh+dt@...nel.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.org>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Bill Mills <bill.mills@...aro.org>,
        Alex Bennée <alex.bennee@...aro.org>,
        "Enrico Weigelt, metux IT consult" <info@...ux.net>,
        Jie Deng <jie.deng@...el.com>,
        DTML <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE" 
        <virtualization@...ts.linux-foundation.org>
Subject: Re: [PATCH V2 5/5] virtio: Bind virtio device to device-tree node

On Thu, Jul 22, 2021 at 11:56 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
>
> +/* Virtio device compatibles and IDs */
> +static const struct of_device_id of_virtio_devices[] = {
> +       { .compatible = "virtio,22", .data = (void *)VIRTIO_ID_I2C_ADAPTER },
> +       { .compatible = "virtio,29", .data = (void *)VIRTIO_ID_GPIO },
> +       { }
> +};
> +
> +static int virtio_device_of_init(struct virtio_device *dev)
> +{
> +       struct device_node *np, *pnode = dev->dev.parent->of_node;
> +       const struct of_device_id *match;
> +       int ret, count;
> +
> +       if (!pnode)
> +               return 0;
> +
> +       count = of_get_available_child_count(pnode);
> +       if (!count)
> +               return 0;
> +
> +       /* There can be only 1 child node */
> +       if (WARN_ON(count > 1))
> +               return -EINVAL;
> +
> +       np = of_get_next_available_child(pnode, NULL);
> +       if (WARN_ON(!np))
> +               return -ENODEV;
> +
> +       match = of_match_node(of_virtio_devices, np);
> +       if (!match) {
> +               ret = -ENODEV;
> +               goto out;
> +       }

I think it would be better not to have to enumerate the of_virtio_devices[]
strings, but instead use of_device_is_compatible() to match against
"virtio,%d". Otherwise we end up modifying this function for every
virtio driver that needs a binding.

       Arnd

Powered by blists - more mailing lists