linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: [RFC PATCH 1/5] drivers core: Prepare support for multiple platform notifications
Date: Fri, 12 Oct 2018 14:39:30 +0300	[thread overview]
Message-ID: <20181012113934.29942-2-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <20181012113934.29942-1-heikki.krogerus@linux.intel.com>

Since it should be possible to support several hardware
description models at the same time (at least in theory),
for example ACPI and devicetree on a running system, the
platform notifications need to be handled differently.

For now a single "platform_notify" callback function was
used to notify the underlying base system which is in charge
of the hardware description when a new device entry was
added to the system, but that callback is available to only
a single base system at the time. This will add a function
device_platform_notify() and replace all direct
platform_notify() calls with it.

device_platform_notify() will first simply call the
platform_notify() callback, so this commit has no functional
affect, however, the idea is that individual base systems
will put their direct notification calls there instead of
using the platform_notify function pointer.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/base/core.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 04bbcd779e11..e42d6e7dd368 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -728,6 +728,16 @@ static inline int device_is_not_partition(struct device *dev)
 }
 #endif
 
+static int
+device_platform_notify(struct device *dev, enum kobject_action action)
+{
+	if (platform_notify && action == KOBJ_ADD)
+		platform_notify(dev);
+	else if (platform_notify_remove && action == KOBJ_REMOVE)
+		platform_notify_remove(dev);
+	return 0;
+}
+
 /**
  * dev_driver_string - Return a device's driver name, if at all possible
  * @dev: struct device to get the name of
@@ -1883,8 +1893,9 @@ int device_add(struct device *dev)
 	}
 
 	/* notify platform of device entry */
-	if (platform_notify)
-		platform_notify(dev);
+	error = device_platform_notify(dev, KOBJ_ADD);
+	if (error)
+		goto platform_error;
 
 	error = device_create_file(dev, &dev_attr_uevent);
 	if (error)
@@ -1960,6 +1971,8 @@ int device_add(struct device *dev)
  SymlinkError:
 	device_remove_file(dev, &dev_attr_uevent);
  attrError:
+	device_platform_notify(dev, KOBJ_REMOVE);
+platform_error:
 	kobject_uevent(&dev->kobj, KOBJ_REMOVE);
 	glue_dir = get_glue_dir(dev);
 	kobject_del(&dev->kobj);
@@ -2083,8 +2096,8 @@ void device_del(struct device *dev)
 	/* Notify the platform of the removal, in case they
 	 * need to do anything...
 	 */
-	if (platform_notify_remove)
-		platform_notify_remove(dev);
+	device_platform_notify(dev, KOBJ_REMOVE);
+
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 					     BUS_NOTIFY_REMOVED_DEVICE, dev);
-- 
2.19.1


  reply	other threads:[~2018-10-12 11:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 11:39 [RFC PATCH 0/5] device property: Introducing software nodes Heikki Krogerus
2018-10-12 11:39 ` Heikki Krogerus [this message]
2018-10-12 11:39 ` [RFC PATCH 2/5] ACPI / glue: Add acpi_platform_notify() function Heikki Krogerus
2018-10-12 11:39 ` [RFC PATCH 3/5] drivers: base: Introducing software nodes to the firmware node framework Heikki Krogerus
2018-10-16 12:57   ` Andy Shevchenko
2018-10-16 14:53     ` Heikki Krogerus
2018-10-12 11:39 ` [RFC PATCH 4/5] device property: Move device_add_properties() to swnode.c Heikki Krogerus
2018-10-12 11:39 ` [RFC PATCH 5/5] device property: Remove struct property_set Heikki Krogerus
2018-10-16  7:35 ` [RFC PATCH 0/5] device property: Introducing software nodes Linus Walleij
2018-10-16  7:36   ` Rafael J. Wysocki
2018-10-16  8:40     ` Heikki Krogerus
2018-10-16  8:44       ` Rafael J. Wysocki
2018-10-16 14:35 ` Andy Shevchenko
2018-10-16 14:46   ` Heikki Krogerus
2018-10-17 14:53   ` Heikki Krogerus
2018-10-16 17:32 ` Dmitry Torokhov
2018-10-17 13:36   ` Heikki Krogerus
2018-10-18  1:06     ` Dmitry Torokhov

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=20181012113934.29942-2-heikki.krogerus@linux.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    /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).