linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors
@ 2022-09-26 21:41 Won Chung
  2022-09-27  9:07 ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Won Chung @ 2022-09-26 21:41 UTC (permalink / raw)
  To: wonchung, bleung, pmalani, heikki.krogerus, imre.deak,
	maarten.lankhorst, mripard, tzimmermann, airlied, daniel,
	linux-kernel

Create a symlink pointing to USB Type-C connector for DRM connectors
when they are created. The link will be created only if the firmware is
able to describe the connection beween the two connectors.

Signed-off-by: Won Chung <wonchung@google.com>
---
Changes from v1:
- Fix multiple lines to single line


 drivers/gpu/drm/drm_sysfs.c | 40 +++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 430e00b16eec..6a9904fa9186 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -11,12 +11,14 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/component.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/gfp.h>
 #include <linux/i2c.h>
 #include <linux/kdev_t.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #include <drm/drm_connector.h>
@@ -95,6 +97,34 @@ static char *drm_devnode(struct device *dev, umode_t *mode)
 	return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
 }
 
+static int typec_connector_bind(struct device *dev,
+	struct device *typec_connector, void *data)
+{
+	int ret;
+
+	ret = sysfs_create_link(&dev->kobj, &typec_connector->kobj, "typec_connector");
+	if (ret)
+		return ret;
+
+	ret = sysfs_create_link(&typec_connector->kobj, &dev->kobj, "drm_connector");
+	if (ret)
+		sysfs_remove_link(&dev->kobj, "typec_connector");
+
+	return ret;
+}
+
+static void typec_connector_unbind(struct device *dev,
+	struct device *typec_connector, void *data)
+{
+	sysfs_remove_link(&typec_connector->kobj, "drm_connector");
+	sysfs_remove_link(&dev->kobj, "typec_connector");
+}
+
+static const struct component_ops typec_connector_ops = {
+	.bind = typec_connector_bind,
+	.unbind = typec_connector_unbind,
+};
+
 static CLASS_ATTR_STRING(version, S_IRUGO, "drm 1.1.0 20060810");
 
 /**
@@ -355,6 +385,13 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
 	if (connector->ddc)
 		return sysfs_create_link(&connector->kdev->kobj,
 				 &connector->ddc->dev.kobj, "ddc");
+
+	if (dev_fwnode(kdev)) {
+		r = component_add(kdev, &typec_connector_ops);
+		if (r)
+			drm_err(dev, "failed to add component\n");
+	}
+
 	return 0;
 
 err_free:
@@ -367,6 +404,9 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
 	if (!connector->kdev)
 		return;
 
+	if (dev_fwnode(connector->kdev))
+		component_del(connector->kdev, &typec_connector_ops);
+
 	if (connector->ddc)
 		sysfs_remove_link(&connector->kdev->kobj, "ddc");
 
-- 
2.37.3.998.g577e59143f-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors
  2022-09-26 21:41 [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors Won Chung
@ 2022-09-27  9:07 ` Heikki Krogerus
  2022-10-03 17:02   ` Won Chung
  2022-10-11 19:27   ` Won Chung
  0 siblings, 2 replies; 4+ messages in thread
From: Heikki Krogerus @ 2022-09-27  9:07 UTC (permalink / raw)
  To: Won Chung
  Cc: bleung, pmalani, imre.deak, maarten.lankhorst, mripard,
	tzimmermann, airlied, daniel, linux-kernel

On Mon, Sep 26, 2022 at 09:41:57PM +0000, Won Chung wrote:
> Create a symlink pointing to USB Type-C connector for DRM connectors
> when they are created. The link will be created only if the firmware is
> able to describe the connection beween the two connectors.
> 
> Signed-off-by: Won Chung <wonchung@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> Changes from v1:
> - Fix multiple lines to single line
> 
> 
>  drivers/gpu/drm/drm_sysfs.c | 40 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 430e00b16eec..6a9904fa9186 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -11,12 +11,14 @@
>   */
>  
>  #include <linux/acpi.h>
> +#include <linux/component.h>
>  #include <linux/device.h>
>  #include <linux/err.h>
>  #include <linux/export.h>
>  #include <linux/gfp.h>
>  #include <linux/i2c.h>
>  #include <linux/kdev_t.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  
>  #include <drm/drm_connector.h>
> @@ -95,6 +97,34 @@ static char *drm_devnode(struct device *dev, umode_t *mode)
>  	return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
>  }
>  
> +static int typec_connector_bind(struct device *dev,
> +	struct device *typec_connector, void *data)
> +{
> +	int ret;
> +
> +	ret = sysfs_create_link(&dev->kobj, &typec_connector->kobj, "typec_connector");
> +	if (ret)
> +		return ret;
> +
> +	ret = sysfs_create_link(&typec_connector->kobj, &dev->kobj, "drm_connector");
> +	if (ret)
> +		sysfs_remove_link(&dev->kobj, "typec_connector");
> +
> +	return ret;
> +}
> +
> +static void typec_connector_unbind(struct device *dev,
> +	struct device *typec_connector, void *data)
> +{
> +	sysfs_remove_link(&typec_connector->kobj, "drm_connector");
> +	sysfs_remove_link(&dev->kobj, "typec_connector");
> +}
> +
> +static const struct component_ops typec_connector_ops = {
> +	.bind = typec_connector_bind,
> +	.unbind = typec_connector_unbind,
> +};
> +
>  static CLASS_ATTR_STRING(version, S_IRUGO, "drm 1.1.0 20060810");
>  
>  /**
> @@ -355,6 +385,13 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
>  	if (connector->ddc)
>  		return sysfs_create_link(&connector->kdev->kobj,
>  				 &connector->ddc->dev.kobj, "ddc");
> +
> +	if (dev_fwnode(kdev)) {
> +		r = component_add(kdev, &typec_connector_ops);
> +		if (r)
> +			drm_err(dev, "failed to add component\n");
> +	}
> +
>  	return 0;
>  
>  err_free:
> @@ -367,6 +404,9 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
>  	if (!connector->kdev)
>  		return;
>  
> +	if (dev_fwnode(connector->kdev))
> +		component_del(connector->kdev, &typec_connector_ops);
> +
>  	if (connector->ddc)
>  		sysfs_remove_link(&connector->kdev->kobj, "ddc");
>  

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors
  2022-09-27  9:07 ` Heikki Krogerus
@ 2022-10-03 17:02   ` Won Chung
  2022-10-11 19:27   ` Won Chung
  1 sibling, 0 replies; 4+ messages in thread
From: Won Chung @ 2022-10-03 17:02 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: bleung, pmalani, imre.deak, maarten.lankhorst, mripard,
	tzimmermann, airlied, daniel, linux-kernel

On Tue, Sep 27, 2022 at 2:07 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> On Mon, Sep 26, 2022 at 09:41:57PM +0000, Won Chung wrote:
> > Create a symlink pointing to USB Type-C connector for DRM connectors
> > when they are created. The link will be created only if the firmware is
> > able to describe the connection beween the two connectors.
> >
> > Signed-off-by: Won Chung <wonchung@google.com>
>
> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>
> > ---
> > Changes from v1:
> > - Fix multiple lines to single line
> >
> >
> >  drivers/gpu/drm/drm_sysfs.c | 40 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index 430e00b16eec..6a9904fa9186 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -11,12 +11,14 @@
> >   */
> >
> >  #include <linux/acpi.h>
> > +#include <linux/component.h>
> >  #include <linux/device.h>
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> >  #include <linux/gfp.h>
> >  #include <linux/i2c.h>
> >  #include <linux/kdev_t.h>
> > +#include <linux/property.h>
> >  #include <linux/slab.h>
> >
> >  #include <drm/drm_connector.h>
> > @@ -95,6 +97,34 @@ static char *drm_devnode(struct device *dev, umode_t *mode)
> >       return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
> >  }
> >
> > +static int typec_connector_bind(struct device *dev,
> > +     struct device *typec_connector, void *data)
> > +{
> > +     int ret;
> > +
> > +     ret = sysfs_create_link(&dev->kobj, &typec_connector->kobj, "typec_connector");
> > +     if (ret)
> > +             return ret;
> > +
> > +     ret = sysfs_create_link(&typec_connector->kobj, &dev->kobj, "drm_connector");
> > +     if (ret)
> > +             sysfs_remove_link(&dev->kobj, "typec_connector");
> > +
> > +     return ret;
> > +}
> > +
> > +static void typec_connector_unbind(struct device *dev,
> > +     struct device *typec_connector, void *data)
> > +{
> > +     sysfs_remove_link(&typec_connector->kobj, "drm_connector");
> > +     sysfs_remove_link(&dev->kobj, "typec_connector");
> > +}
> > +
> > +static const struct component_ops typec_connector_ops = {
> > +     .bind = typec_connector_bind,
> > +     .unbind = typec_connector_unbind,
> > +};
> > +
> >  static CLASS_ATTR_STRING(version, S_IRUGO, "drm 1.1.0 20060810");
> >
> >  /**
> > @@ -355,6 +385,13 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
> >       if (connector->ddc)
> >               return sysfs_create_link(&connector->kdev->kobj,
> >                                &connector->ddc->dev.kobj, "ddc");
> > +
> > +     if (dev_fwnode(kdev)) {
> > +             r = component_add(kdev, &typec_connector_ops);
> > +             if (r)
> > +                     drm_err(dev, "failed to add component\n");
> > +     }
> > +
> >       return 0;
> >
> >  err_free:
> > @@ -367,6 +404,9 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
> >       if (!connector->kdev)
> >               return;
> >
> > +     if (dev_fwnode(connector->kdev))
> > +             component_del(connector->kdev, &typec_connector_ops);
> > +
> >       if (connector->ddc)
> >               sysfs_remove_link(&connector->kdev->kobj, "ddc");
> >
>
> thanks,
>
> --
> heikki

Hi upstream DRM maintainers,

Can one of you take a look at this patch for a review when you have
time? Thank you!

Won

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors
  2022-09-27  9:07 ` Heikki Krogerus
  2022-10-03 17:02   ` Won Chung
@ 2022-10-11 19:27   ` Won Chung
  1 sibling, 0 replies; 4+ messages in thread
From: Won Chung @ 2022-10-11 19:27 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: bleung, pmalani, imre.deak, maarten.lankhorst, mripard,
	tzimmermann, airlied, airlied, daniel, linux-kernel

On Tue, Sep 27, 2022 at 2:07 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> On Mon, Sep 26, 2022 at 09:41:57PM +0000, Won Chung wrote:
> > Create a symlink pointing to USB Type-C connector for DRM connectors
> > when they are created. The link will be created only if the firmware is
> > able to describe the connection beween the two connectors.
> >
> > Signed-off-by: Won Chung <wonchung@google.com>
>
> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>
> > ---
> > Changes from v1:
> > - Fix multiple lines to single line
> >
> >
> >  drivers/gpu/drm/drm_sysfs.c | 40 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index 430e00b16eec..6a9904fa9186 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -11,12 +11,14 @@
> >   */
> >
> >  #include <linux/acpi.h>
> > +#include <linux/component.h>
> >  #include <linux/device.h>
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> >  #include <linux/gfp.h>
> >  #include <linux/i2c.h>
> >  #include <linux/kdev_t.h>
> > +#include <linux/property.h>
> >  #include <linux/slab.h>
> >
> >  #include <drm/drm_connector.h>
> > @@ -95,6 +97,34 @@ static char *drm_devnode(struct device *dev, umode_t *mode)
> >       return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
> >  }
> >
> > +static int typec_connector_bind(struct device *dev,
> > +     struct device *typec_connector, void *data)
> > +{
> > +     int ret;
> > +
> > +     ret = sysfs_create_link(&dev->kobj, &typec_connector->kobj, "typec_connector");
> > +     if (ret)
> > +             return ret;
> > +
> > +     ret = sysfs_create_link(&typec_connector->kobj, &dev->kobj, "drm_connector");
> > +     if (ret)
> > +             sysfs_remove_link(&dev->kobj, "typec_connector");
> > +
> > +     return ret;
> > +}
> > +
> > +static void typec_connector_unbind(struct device *dev,
> > +     struct device *typec_connector, void *data)
> > +{
> > +     sysfs_remove_link(&typec_connector->kobj, "drm_connector");
> > +     sysfs_remove_link(&dev->kobj, "typec_connector");
> > +}
> > +
> > +static const struct component_ops typec_connector_ops = {
> > +     .bind = typec_connector_bind,
> > +     .unbind = typec_connector_unbind,
> > +};
> > +
> >  static CLASS_ATTR_STRING(version, S_IRUGO, "drm 1.1.0 20060810");
> >
> >  /**
> > @@ -355,6 +385,13 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
> >       if (connector->ddc)
> >               return sysfs_create_link(&connector->kdev->kobj,
> >                                &connector->ddc->dev.kobj, "ddc");
> > +
> > +     if (dev_fwnode(kdev)) {
> > +             r = component_add(kdev, &typec_connector_ops);
> > +             if (r)
> > +                     drm_err(dev, "failed to add component\n");
> > +     }
> > +
> >       return 0;
> >
> >  err_free:
> > @@ -367,6 +404,9 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
> >       if (!connector->kdev)
> >               return;
> >
> > +     if (dev_fwnode(connector->kdev))
> > +             component_del(connector->kdev, &typec_connector_ops);
> > +
> >       if (connector->ddc)
> >               sysfs_remove_link(&connector->kdev->kobj, "ddc");
> >
>
> thanks,
>
> --
> heikki

Hi upstream DRM maintainers,

Can you please take a look at this patch for a review when you have time?

Thank you,
Won

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-11 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26 21:41 [PATCH v2] drm/sysfs: Link DRM connectors to corresponding Type-C connectors Won Chung
2022-09-27  9:07 ` Heikki Krogerus
2022-10-03 17:02   ` Won Chung
2022-10-11 19:27   ` Won Chung

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).