linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] serdev: bus-code clean ups
@ 2018-01-08 12:42 Johan Hovold
  2018-01-08 12:42 ` [PATCH 1/2] serdev: do not generate modaliases for controllers Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johan Hovold @ 2018-01-08 12:42 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Frédéric Danis,
	Johan Hovold

As noted by Hans, we currently fail to generate uevents for ACPI serdev
controller as they do not have any ACPI companions from which ACPI
modaliases are constructed.

In fact, we should not have been generating modaliases for controllers
in the first place as controllers are not bound to drivers.

This series applies on top of Hans's minimal fix which suppresses the
uevent errors for ACPI controllers (even though it could replace it
entirely if preferred).

Johan


Johan Hovold (2):
  serdev: do not generate modaliases for controllers
  serdev: only match serdev devices

 drivers/tty/serdev/core.c | 80 +++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 38 deletions(-)

-- 
2.15.1

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

* [PATCH 1/2] serdev: do not generate modaliases for controllers
  2018-01-08 12:42 [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
@ 2018-01-08 12:42 ` Johan Hovold
  2018-01-09 15:48   ` Greg Kroah-Hartman
  2018-01-08 12:42 ` [PATCH 2/2] serdev: only match serdev devices Johan Hovold
  2018-01-08 13:50 ` [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2018-01-08 12:42 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Frédéric Danis,
	Johan Hovold

Serdev controllers are not bound to any drivers and it therefore makes
no sense to generate modaliases for them.

This has already been fixed separately for ACPI controllers for which
uevent errors were also being logged during probe due to the missing
ACPI companions (from which ACPI modaliases are generated).

This patch moves the modalias handling from the bus type to the client
device type. Specifically, this means that only serdev devices (a.k.a.
clients or slaves) will have have MODALIAS fields in their uevent
environments and corresponding modalias sysfs attributes.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serdev/core.c | 72 ++++++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 5dc88f61f506..61c85e49e178 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -19,6 +19,38 @@
 static bool is_registered;
 static DEFINE_IDA(ctrl_ida);
 
+static ssize_t modalias_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	int len;
+
+	len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
+	if (len != -ENODEV)
+		return len;
+
+	return of_device_modalias(dev, buf, PAGE_SIZE);
+}
+DEVICE_ATTR_RO(modalias);
+
+static struct attribute *serdev_device_attrs[] = {
+	&dev_attr_modalias.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(serdev_device);
+
+static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	int rc;
+
+	/* TODO: platform modalias */
+
+	rc = acpi_device_uevent_modalias(dev, env);
+	if (rc != -ENODEV)
+		return rc;
+
+	return of_device_uevent_modalias(dev, env);
+}
+
 static void serdev_device_release(struct device *dev)
 {
 	struct serdev_device *serdev = to_serdev_device(dev);
@@ -26,6 +58,8 @@ static void serdev_device_release(struct device *dev)
 }
 
 static const struct device_type serdev_device_type = {
+	.groups		= serdev_device_groups,
+	.uevent		= serdev_device_uevent,
 	.release	= serdev_device_release,
 };
 
@@ -49,23 +83,6 @@ static int serdev_device_match(struct device *dev, struct device_driver *drv)
 	return of_driver_match_device(dev, drv);
 }
 
-static int serdev_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
-	int rc;
-
-	/* TODO: platform modalias */
-
-	/* ACPI enumerated controllers do not have a modalias */
-	if (!dev->of_node && dev->type == &serdev_ctrl_type)
-		return 0;
-
-	rc = acpi_device_uevent_modalias(dev, env);
-	if (rc != -ENODEV)
-		return rc;
-
-	return of_device_uevent_modalias(dev, env);
-}
-
 /**
  * serdev_device_add() - add a device previously constructed via serdev_device_alloc()
  * @serdev:	serdev_device to be added
@@ -305,32 +322,11 @@ static int serdev_drv_remove(struct device *dev)
 	return 0;
 }
 
-static ssize_t modalias_show(struct device *dev,
-			     struct device_attribute *attr, char *buf)
-{
-	int len;
-
-	len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
-	if (len != -ENODEV)
-		return len;
-
-	return of_device_modalias(dev, buf, PAGE_SIZE);
-}
-DEVICE_ATTR_RO(modalias);
-
-static struct attribute *serdev_device_attrs[] = {
-	&dev_attr_modalias.attr,
-	NULL,
-};
-ATTRIBUTE_GROUPS(serdev_device);
-
 static struct bus_type serdev_bus_type = {
 	.name		= "serial",
 	.match		= serdev_device_match,
 	.probe		= serdev_drv_probe,
 	.remove		= serdev_drv_remove,
-	.uevent		= serdev_uevent,
-	.dev_groups	= serdev_device_groups,
 };
 
 /**
-- 
2.15.1

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

* [PATCH 2/2] serdev: only match serdev devices
  2018-01-08 12:42 [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
  2018-01-08 12:42 ` [PATCH 1/2] serdev: do not generate modaliases for controllers Johan Hovold
@ 2018-01-08 12:42 ` Johan Hovold
  2018-01-08 13:50 ` [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
  2 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2018-01-08 12:42 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-kernel, Frédéric Danis,
	Johan Hovold

Only serdev devices (a.k.a. clients or slaves) are bound to drivers so
bail out early from match() in case the device is not a serdev device
(i.e. if it's a serdev controller).

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serdev/core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 61c85e49e178..a30e237eb98c 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -63,6 +63,11 @@ static const struct device_type serdev_device_type = {
 	.release	= serdev_device_release,
 };
 
+static bool is_serdev_device(const struct device *dev)
+{
+	return dev->type == &serdev_device_type;
+}
+
 static void serdev_ctrl_release(struct device *dev)
 {
 	struct serdev_controller *ctrl = to_serdev_controller(dev);
@@ -76,6 +81,9 @@ static const struct device_type serdev_ctrl_type = {
 
 static int serdev_device_match(struct device *dev, struct device_driver *drv)
 {
+	if (!is_serdev_device(dev))
+		return 0;
+
 	/* TODO: platform matching */
 	if (acpi_driver_match_device(dev, drv))
 		return 1;
-- 
2.15.1

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

* Re: [PATCH 0/2] serdev: bus-code clean ups
  2018-01-08 12:42 [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
  2018-01-08 12:42 ` [PATCH 1/2] serdev: do not generate modaliases for controllers Johan Hovold
  2018-01-08 12:42 ` [PATCH 2/2] serdev: only match serdev devices Johan Hovold
@ 2018-01-08 13:50 ` Johan Hovold
  2018-01-09 15:48   ` Greg Kroah-Hartman
  2 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2018-01-08 13:50 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman, Hans de Goede
  Cc: Jiri Slaby, linux-serial, linux-kernel, Frédéric Danis,
	Johan Hovold

On Mon, Jan 08, 2018 at 01:42:31PM +0100, Johan Hovold wrote:
> As noted by Hans, we currently fail to generate uevents for ACPI serdev
> controller as they do not have any ACPI companions from which ACPI
> modaliases are constructed.
> 
> In fact, we should not have been generating modaliases for controllers
> in the first place as controllers are not bound to drivers.
> 
> This series applies on top of Hans's minimal fix which suppresses the
> uevent errors for ACPI controllers (even though it could replace it
> entirely if preferred).

I somehow forgot to CC Hans. Sorry about that. This series can be found
here:

	https://lkml.kernel.org/r/20180108124233.26729-1-johan@kernel.org

> Johan Hovold (2):
>   serdev: do not generate modaliases for controllers
>   serdev: only match serdev devices
> 
>  drivers/tty/serdev/core.c | 80 +++++++++++++++++++++++++----------------------
>  1 file changed, 42 insertions(+), 38 deletions(-)

Johan

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

* Re: [PATCH 1/2] serdev: do not generate modaliases for controllers
  2018-01-08 12:42 ` [PATCH 1/2] serdev: do not generate modaliases for controllers Johan Hovold
@ 2018-01-09 15:48   ` Greg Kroah-Hartman
  2018-01-09 15:56     ` Johan Hovold
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-01-09 15:48 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Rob Herring, Jiri Slaby, linux-serial, linux-kernel,
	Frédéric Danis

On Mon, Jan 08, 2018 at 01:42:32PM +0100, Johan Hovold wrote:
> Serdev controllers are not bound to any drivers and it therefore makes
> no sense to generate modaliases for them.
> 
> This has already been fixed separately for ACPI controllers for which
> uevent errors were also being logged during probe due to the missing
> ACPI companions (from which ACPI modaliases are generated).
> 
> This patch moves the modalias handling from the bus type to the client
> device type. Specifically, this means that only serdev devices (a.k.a.
> clients or slaves) will have have MODALIAS fields in their uevent
> environments and corresponding modalias sysfs attributes.
> 
> Reported-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/tty/serdev/core.c | 72 ++++++++++++++++++++++-------------------------
>  1 file changed, 34 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 5dc88f61f506..61c85e49e178 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -19,6 +19,38 @@
>  static bool is_registered;
>  static DEFINE_IDA(ctrl_ida);
>  
> +static ssize_t modalias_show(struct device *dev,
> +			     struct device_attribute *attr, char *buf)
> +{
> +	int len;
> +
> +	len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
> +	if (len != -ENODEV)
> +		return len;
> +
> +	return of_device_modalias(dev, buf, PAGE_SIZE);
> +}
> +DEVICE_ATTR_RO(modalias);

static?

Sorry, minor nit :(

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

* Re: [PATCH 0/2] serdev: bus-code clean ups
  2018-01-08 13:50 ` [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
@ 2018-01-09 15:48   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-01-09 15:48 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Rob Herring, Hans de Goede, Jiri Slaby, linux-serial,
	linux-kernel, Frédéric Danis

On Mon, Jan 08, 2018 at 02:50:14PM +0100, Johan Hovold wrote:
> On Mon, Jan 08, 2018 at 01:42:31PM +0100, Johan Hovold wrote:
> > As noted by Hans, we currently fail to generate uevents for ACPI serdev
> > controller as they do not have any ACPI companions from which ACPI
> > modaliases are constructed.
> > 
> > In fact, we should not have been generating modaliases for controllers
> > in the first place as controllers are not bound to drivers.
> > 
> > This series applies on top of Hans's minimal fix which suppresses the
> > uevent errors for ACPI controllers (even though it could replace it
> > entirely if preferred).
> 
> I somehow forgot to CC Hans. Sorry about that. This series can be found
> here:
> 
> 	https://lkml.kernel.org/r/20180108124233.26729-1-johan@kernel.org

Minor issue found with patch 1, can you fix that up and resend and cc:
him this time?  :)

thanks,

greg k-h

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

* Re: [PATCH 1/2] serdev: do not generate modaliases for controllers
  2018-01-09 15:48   ` Greg Kroah-Hartman
@ 2018-01-09 15:56     ` Johan Hovold
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2018-01-09 15:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Johan Hovold, Rob Herring, Jiri Slaby, linux-serial, linux-kernel,
	Frédéric Danis

On Tue, Jan 09, 2018 at 04:48:03PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Jan 08, 2018 at 01:42:32PM +0100, Johan Hovold wrote:
> > Serdev controllers are not bound to any drivers and it therefore makes
> > no sense to generate modaliases for them.
> > 
> > This has already been fixed separately for ACPI controllers for which
> > uevent errors were also being logged during probe due to the missing
> > ACPI companions (from which ACPI modaliases are generated).
> > 
> > This patch moves the modalias handling from the bus type to the client
> > device type. Specifically, this means that only serdev devices (a.k.a.
> > clients or slaves) will have have MODALIAS fields in their uevent
> > environments and corresponding modalias sysfs attributes.
> > 
> > Reported-by: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/tty/serdev/core.c | 72 ++++++++++++++++++++++-------------------------
> >  1 file changed, 34 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> > index 5dc88f61f506..61c85e49e178 100644
> > --- a/drivers/tty/serdev/core.c
> > +++ b/drivers/tty/serdev/core.c
> > @@ -19,6 +19,38 @@
> >  static bool is_registered;
> >  static DEFINE_IDA(ctrl_ida);
> >  
> > +static ssize_t modalias_show(struct device *dev,
> > +			     struct device_attribute *attr, char *buf)
> > +{
> > +	int len;
> > +
> > +	len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
> > +	if (len != -ENODEV)
> > +		return len;
> > +
> > +	return of_device_modalias(dev, buf, PAGE_SIZE);
> > +}
> > +DEVICE_ATTR_RO(modalias);
> 
> static?
> 
> Sorry, minor nit :(

Heh, no worries. I didn't notice that as I was just moving code around
here, but I'll make sure to add that missing static in a v2.

Thanks,
Johan

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

end of thread, other threads:[~2018-01-09 15:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-08 12:42 [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
2018-01-08 12:42 ` [PATCH 1/2] serdev: do not generate modaliases for controllers Johan Hovold
2018-01-09 15:48   ` Greg Kroah-Hartman
2018-01-09 15:56     ` Johan Hovold
2018-01-08 12:42 ` [PATCH 2/2] serdev: only match serdev devices Johan Hovold
2018-01-08 13:50 ` [PATCH 0/2] serdev: bus-code clean ups Johan Hovold
2018-01-09 15:48   ` Greg Kroah-Hartman

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