intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Hans de Goede <hdegoede@redhat.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	 Thomas Zimmermann <tzimmermann@suse.de>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	 Imre Deak <imre.deak@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel@lists.freedesktop.org,  linux-usb@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH 1/8] drm/connector: Give connector sysfs devices there own device_type
Date: Wed, 18 Aug 2021 17:35:31 -0400	[thread overview]
Message-ID: <5fe94acc12b0f845cd55436056368c3bf9e48544.camel@redhat.com> (raw)
In-Reply-To: <20210817215201.795062-2-hdegoede@redhat.com>

On Tue, 2021-08-17 at 23:51 +0200, Hans de Goede wrote:
> Give connector sysfs devices there own device_type, this allows us to
> check if a device passed to functions dealing with generic devices is
> a drm_connector or not.
> 
> A check like this is necessary in the drm_connector_acpi_bus_match()
> function added in the next patch in this series.
> 
> Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/gpu/drm/drm_sysfs.c | 50 +++++++++++++++++++++++++++----------
>  1 file changed, 37 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 968a9560b4aa..f9d92bbb1f98 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -50,6 +50,10 @@ static struct device_type drm_sysfs_device_minor = {
>         .name = "drm_minor"
>  };
>  
> +static struct device_type drm_sysfs_device_connector = {
> +       .name = "drm_connector",
> +};
> +
>  struct class *drm_class;
>  
>  static char *drm_devnode(struct device *dev, umode_t *mode)
> @@ -102,6 +106,11 @@ void drm_sysfs_destroy(void)
>         drm_class = NULL;
>  }
>  
> +static void drm_sysfs_release(struct device *dev)
> +{
> +       kfree(dev);
> +}
> +
>  /*
>   * Connector properties
>   */
> @@ -273,27 +282,47 @@ static const struct attribute_group
> *connector_dev_groups[] = {
>  int drm_sysfs_connector_add(struct drm_connector *connector)
>  {
>         struct drm_device *dev = connector->dev;
> +       struct device *kdev;
> +       int r;
>  
>         if (connector->kdev)
>                 return 0;
>  
> -       connector->kdev =
> -               device_create_with_groups(drm_class, dev->primary->kdev, 0,
> -                                         connector, connector_dev_groups,
> -                                         "card%d-%s", dev->primary->index,
> -                                         connector->name);
> +       kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
> +       if (!kdev)
> +               return -ENOMEM;
> +
> +       device_initialize(kdev);
> +       kdev->class = drm_class;
> +       kdev->type = &drm_sysfs_device_connector;
> +       kdev->parent = dev->primary->kdev;
> +       kdev->groups = connector_dev_groups;
> +       kdev->release = drm_sysfs_release;
> +       dev_set_drvdata(kdev, connector);
> +
> +       r = dev_set_name(kdev, "card%d-%s", dev->primary->index, connector-
> >name);
> +       if (r)
> +               goto err_free;
> +
>         DRM_DEBUG("adding \"%s\" to sysfs\n",
>                   connector->name);
>  
> -       if (IS_ERR(connector->kdev)) {
> -               DRM_ERROR("failed to register connector device: %ld\n",
> PTR_ERR(connector->kdev));
> -               return PTR_ERR(connector->kdev);
> +       r = device_add(kdev);
> +       if (r) {
> +               DRM_ERROR("failed to register connector device: %d\n", r);
> +               goto err_free;

Should probably be using drm_err() here since we have access to struct
drm_device *

>         }
>  
> +       connector->kdev = kdev;
> +
>         if (connector->ddc)
>                 return sysfs_create_link(&connector->kdev->kobj,
>                                  &connector->ddc->dev.kobj, "ddc");
>         return 0;
> +
> +err_free:
> +       put_device(kdev);
> +       return r;
>  }
>  
>  void drm_sysfs_connector_remove(struct drm_connector *connector)
> @@ -374,11 +403,6 @@ void drm_sysfs_connector_status_event(struct
> drm_connector *connector,
>  }
>  EXPORT_SYMBOL(drm_sysfs_connector_status_event);
>  
> -static void drm_sysfs_release(struct device *dev)
> -{
> -       kfree(dev);
> -}
> -
>  struct device *drm_sysfs_minor_alloc(struct drm_minor *minor)
>  {
>         const char *minor_str;

-- 
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat


  reply	other threads:[~2021-08-18 21:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 21:51 [Intel-gfx] [PATCH 0/8] drm + usb-type-c: Add support for out-of-band hotplug notification (v4 resend) Hans de Goede
2021-08-17 21:51 ` [Intel-gfx] [PATCH 1/8] drm/connector: Give connector sysfs devices there own device_type Hans de Goede
2021-08-18 21:35   ` Lyude Paul [this message]
2021-08-17 21:51 ` [Intel-gfx] [PATCH 2/8] drm/connector: Add a fwnode pointer to drm_connector and register with ACPI (v2) Hans de Goede
2021-08-17 21:51 ` [Intel-gfx] [PATCH 3/8] drm/connector: Add drm_connector_find_by_fwnode() function (v3) Hans de Goede
2021-08-17 21:51 ` [Intel-gfx] [PATCH 4/8] drm/connector: Add support for out-of-band hotplug notification (v3) Hans de Goede
2021-08-17 21:51 ` [Intel-gfx] [PATCH 5/8] drm/i915: Associate ACPI connector nodes with connector entries (v2) Hans de Goede
2021-08-17 21:51 ` [Intel-gfx] [PATCH 6/8] drm/i915/dp: Add support for out-of-bound hotplug events Hans de Goede
2021-08-17 21:52 ` [Intel-gfx] [PATCH 7/8] usb: typec: altmodes/displayport: Make dp_altmode_notify() more generic Hans de Goede
2021-08-17 21:52 ` [Intel-gfx] [PATCH 8/8] usb: typec: altmodes/displayport: Notify drm subsys of hotplug events Hans de Goede
2021-09-16  3:20   ` Stephen Boyd
2021-09-16 13:17     ` Hans de Goede
2021-09-24 23:29       ` Stephen Boyd
2021-08-17 22:08 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm + usb-type-c: Add support for out-of-band hotplug notification (v4 resend) Patchwork
2021-08-17 22:35 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-08-18  0:08 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-08-18 19:54   ` Hans de Goede
2021-08-18 22:03 ` [Intel-gfx] [PATCH 0/8] " Lyude Paul
  -- strict thread matches above, loose matches on Subject: below --
2021-06-04 19:48 [Intel-gfx] [PATCH 0/8] drm + usb-type-c: Add support for out-of-band hotplug notification (v4) Hans de Goede
2021-06-04 19:48 ` [Intel-gfx] [PATCH 1/8] drm/connector: Give connector sysfs devices there own device_type Hans de Goede
2021-05-05 16:24 [Intel-gfx] [PATCH 0/8] drm + usb-type-c: Add support for out-of-band hotplug notification (v3) Hans de Goede
2021-05-05 16:24 ` [Intel-gfx] [PATCH 1/8] drm/connector: Give connector sysfs devices there own device_type Hans de Goede

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=5fe94acc12b0f845cd55436056368c3bf9e48544.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=tzimmermann@suse.de \
    /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).