From: Vinod Koul <vinod.koul@intel.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: ALSA <alsa-devel@alsa-project.org>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Takashi <tiwai@suse.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
plai@codeaurora.org, LKML <linux-kernel@vger.kernel.org>,
Pierre <pierre-louis.bossart@linux.intel.com>,
patches.audio@intel.com, Mark <broonie@kernel.org>,
Sudheer Papothi <spapothi@codeaurora.org>,
Shreyas NC <shreyas.nc@intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
Sagar Dharia <sdharia@codeaurora.org>,
alan@linux.intel.com
Subject: Re: [PATCH v2 03/14] soundwire: Add Master registration
Date: Thu, 16 Nov 2017 22:19:44 +0530 [thread overview]
Message-ID: <20171116164944.GC3187@localhost> (raw)
In-Reply-To: <2ba56597-2178-6389-bc4d-153a17505981@linaro.org>
On Thu, Nov 16, 2017 at 04:05:22PM +0000, Srinivas Kandagatla wrote:
>
>
> On 10/11/17 11:49, Vinod Koul wrote:
> >A Master registers with SoundWire bus and scans the firmware provided
> >for device description. In this patch we scan the ACPI namespaces and
> >create the SoundWire Slave devices based on the ACPI description
> >
> >Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
> >Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> >---
> > drivers/soundwire/Makefile | 2 +-
> > drivers/soundwire/bus.c | 163 +++++++++++++++++++++++++++++++++++++++
> > drivers/soundwire/bus.h | 20 +++++
> > drivers/soundwire/slave.c | 172 ++++++++++++++++++++++++++++++++++++++++++
> > include/linux/soundwire/sdw.h | 11 +++
> > 5 files changed, 367 insertions(+), 1 deletion(-)
> > create mode 100644 drivers/soundwire/bus.c
> > create mode 100644 drivers/soundwire/slave.c
> >
> >diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
> >index d1281def7662..c875e434f8b3 100644
> >--- a/drivers/soundwire/Makefile
> >+++ b/drivers/soundwire/Makefile
> >@@ -3,5 +3,5 @@
> > #
> > #Bus Objs
> >-soundwire-bus-objs := bus_type.o
> >+soundwire-bus-objs := bus_type.o bus.o slave.o
>
> >+
> >+#include <linux/delay.h>
> >+#include <linux/device.h>
> >+#include <linux/pm_runtime.h>
> Does this belong to this patch.
Not really, tahnks for spotting
>
> >+#include <linux/soundwire/sdw.h>
> >+#include "bus.h"
> >+
> >+/**
> >+ * sdw_add_bus_master: add a bus Master instance
> >+ *
> >+ * @bus: bus instance
> >+ *
> >+ * Initializes the bus instance, read properties and create child
> >+ * devices.
> >+ */
> >+int sdw_add_bus_master(struct sdw_bus *bus)
> >+{
> >+ int ret;
> >+
> >+ if (!bus->dev) {
> >+ pr_err("SoundWire bus has no device");
> >+ return -ENODEV;
> >+ }
> >+
> >+ mutex_init(&bus->bus_lock);
> >+ INIT_LIST_HEAD(&bus->slaves);
> >+
> >+ /*
> >+ * Enumeration device number and broadcast device number are
> >+ * not used for assignment so mask these and other higher bits
> >+ */
> >+
> >+ /* Set higher order bits */
> >+ *bus->assigned = ~GENMASK(SDW_BROADCAST_DEV_NUM, SDW_ENUM_DEV_NUM);
> Can't we use ida for this.
> This would also cut down code added for allocating dev_num.
Device numbers in SoundWire are 0 thru 15 with 0 and 15 having special
meaning so can'r be allocated. Bitmaps give me a nice way to ensure we dont
use those by masking these and above 15... IDR uses bitmap with stuff on top
which maynot be helpful here as I need a number 1 to 14. For a generic, give
me a number IDRs are very useful.
>
> >+
> >+ /* Set device number and broadcast device number */
> >+ set_bit(SDW_ENUM_DEV_NUM, bus->assigned);
> >+ set_bit(SDW_BROADCAST_DEV_NUM, bus->assigned);
>
> >+ return 0;
> >+}
> >+EXPORT_SYMBOL(sdw_add_bus_master);
> >+
> >+static int sdw_delete_slave(struct device *dev, void *data)
> >+{
> >+ struct sdw_slave *slave = dev_to_sdw_dev(dev);
> >+ struct sdw_bus *bus = slave->bus;
> >+
> >+ mutex_lock(&bus->bus_lock);
> >+
> >+ if (slave->dev_num) /* clear dev_num if assigned */
> >+ clear_bit(slave->dev_num, bus->assigned);
> >+
> >+ list_del_init(&slave->node);
> >+ mutex_unlock(&bus->bus_lock);
> >+
> >+ device_unregister(dev);
> >+ return 0;
> >+}
> >+
> >+void sdw_delete_bus_master(struct sdw_bus *bus)
> >+{
> >+ device_for_each_child(bus->dev, NULL, sdw_delete_slave);
> >+}
> >+EXPORT_SYMBOL(sdw_delete_bus_master);
> No kerneldoc..??
will add.
>
> >+
> diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
> >new file mode 100644
> >index 000000000000..4bf2a6cf732c
> >--- /dev/null
> >+++ b/drivers/soundwire/slave.c
>
> >+
> >+#include <linux/acpi.h>
> >+#include <linux/init.h>
> >+#include <linux/soundwire/sdw.h>
> >+#include "bus.h"
> >+
> >+}
> >+
> >+static int sdw_slave_add(struct sdw_bus *bus,
> >+ struct sdw_slave_id *id, struct fwnode_handle *fwnode)
> >+{
> >+ struct sdw_slave *slave;
> >+ int ret;
> >+
> >+ slave = kzalloc(sizeof(*slave), GFP_KERNEL);
> >+ if (!slave)
> >+ return -ENOMEM;
> >+
> >+ /* Initialize data structure */
> >+ memcpy(&slave->id, id, sizeof(*id));
> >+ slave->dev.parent = bus->dev;
> >+ slave->dev.fwnode = fwnode;
> >+
> >+ /* name shall be sdw:link:mfg:part:class:unique */
> >+ dev_set_name(&slave->dev, "sdw:%x:%x:%x:%x:%x",
> >+ bus->link_id, id->mfg_id, id->part_id,
> >+ id->class_id, id->unique_id);
> >+
> >+ slave->dev.release = sdw_slave_release;
> >+ slave->dev.bus = &sdw_bus_type;
> >+ slave->bus = bus;
> >+ slave->status = SDW_SLAVE_UNATTACHED;
> >+ slave->dev_num = 0;
> >+
> >+ mutex_lock(&bus->bus_lock);
> >+ list_add_tail(&slave->node, &bus->slaves);
> >+ mutex_unlock(&bus->bus_lock);
> >+
> >+ ret = device_register(&slave->dev);
> >+ if (ret) {
> >+ dev_err(bus->dev, "Failed to add slave: ret %d\n", ret);
> >+
> >+ /*
> >+ * On err, don't free but drop ref as this will be freed
> >+ * when release method is invoked.
> >+ */
> >+ mutex_lock(&bus->bus_lock);
> >+ list_del(&slave->node);
> >+ mutex_unlock(&bus->bus_lock);
> >+ put_device(&slave->dev);
> >+ return ret;
>
> remove this line and ..
> >+ }
> >+
> >+ return 0;
>
> return ret;
better :)
> >+#if IS_ENABLED(CONFIG_OF)
> >+int sdw_of_find_slaves(struct sdw_bus *bus)
> >+{
> >+ /* placeholder now, fill on OF support */
> >+ return -ENOTSUPP;
> >+}
> >+#endif
>
> We should probably remove this dummy function, and add this functionality
> later.
this was kept for people to know how they may add DT support, but yes its
better to remove.
--
~Vinod
WARNING: multiple messages have this Message-ID (diff)
From: Vinod Koul <vinod.koul@intel.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
ALSA <alsa-devel@alsa-project.org>, Mark <broonie@kernel.org>,
Takashi <tiwai@suse.de>,
Pierre <pierre-louis.bossart@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
Shreyas NC <shreyas.nc@intel.com>,
patches.audio@intel.com, alan@linux.intel.com,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Sagar Dharia <sdharia@codeaurora.org>,
plai@codeaurora.org, Sudheer Papothi <spapothi@codeaurora.org>
Subject: Re: [PATCH v2 03/14] soundwire: Add Master registration
Date: Thu, 16 Nov 2017 22:19:44 +0530 [thread overview]
Message-ID: <20171116164944.GC3187@localhost> (raw)
In-Reply-To: <2ba56597-2178-6389-bc4d-153a17505981@linaro.org>
On Thu, Nov 16, 2017 at 04:05:22PM +0000, Srinivas Kandagatla wrote:
>
>
> On 10/11/17 11:49, Vinod Koul wrote:
> >A Master registers with SoundWire bus and scans the firmware provided
> >for device description. In this patch we scan the ACPI namespaces and
> >create the SoundWire Slave devices based on the ACPI description
> >
> >Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
> >Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> >---
> > drivers/soundwire/Makefile | 2 +-
> > drivers/soundwire/bus.c | 163 +++++++++++++++++++++++++++++++++++++++
> > drivers/soundwire/bus.h | 20 +++++
> > drivers/soundwire/slave.c | 172 ++++++++++++++++++++++++++++++++++++++++++
> > include/linux/soundwire/sdw.h | 11 +++
> > 5 files changed, 367 insertions(+), 1 deletion(-)
> > create mode 100644 drivers/soundwire/bus.c
> > create mode 100644 drivers/soundwire/slave.c
> >
> >diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
> >index d1281def7662..c875e434f8b3 100644
> >--- a/drivers/soundwire/Makefile
> >+++ b/drivers/soundwire/Makefile
> >@@ -3,5 +3,5 @@
> > #
> > #Bus Objs
> >-soundwire-bus-objs := bus_type.o
> >+soundwire-bus-objs := bus_type.o bus.o slave.o
>
> >+
> >+#include <linux/delay.h>
> >+#include <linux/device.h>
> >+#include <linux/pm_runtime.h>
> Does this belong to this patch.
Not really, tahnks for spotting
>
> >+#include <linux/soundwire/sdw.h>
> >+#include "bus.h"
> >+
> >+/**
> >+ * sdw_add_bus_master: add a bus Master instance
> >+ *
> >+ * @bus: bus instance
> >+ *
> >+ * Initializes the bus instance, read properties and create child
> >+ * devices.
> >+ */
> >+int sdw_add_bus_master(struct sdw_bus *bus)
> >+{
> >+ int ret;
> >+
> >+ if (!bus->dev) {
> >+ pr_err("SoundWire bus has no device");
> >+ return -ENODEV;
> >+ }
> >+
> >+ mutex_init(&bus->bus_lock);
> >+ INIT_LIST_HEAD(&bus->slaves);
> >+
> >+ /*
> >+ * Enumeration device number and broadcast device number are
> >+ * not used for assignment so mask these and other higher bits
> >+ */
> >+
> >+ /* Set higher order bits */
> >+ *bus->assigned = ~GENMASK(SDW_BROADCAST_DEV_NUM, SDW_ENUM_DEV_NUM);
> Can't we use ida for this.
> This would also cut down code added for allocating dev_num.
Device numbers in SoundWire are 0 thru 15 with 0 and 15 having special
meaning so can'r be allocated. Bitmaps give me a nice way to ensure we dont
use those by masking these and above 15... IDR uses bitmap with stuff on top
which maynot be helpful here as I need a number 1 to 14. For a generic, give
me a number IDRs are very useful.
>
> >+
> >+ /* Set device number and broadcast device number */
> >+ set_bit(SDW_ENUM_DEV_NUM, bus->assigned);
> >+ set_bit(SDW_BROADCAST_DEV_NUM, bus->assigned);
>
> >+ return 0;
> >+}
> >+EXPORT_SYMBOL(sdw_add_bus_master);
> >+
> >+static int sdw_delete_slave(struct device *dev, void *data)
> >+{
> >+ struct sdw_slave *slave = dev_to_sdw_dev(dev);
> >+ struct sdw_bus *bus = slave->bus;
> >+
> >+ mutex_lock(&bus->bus_lock);
> >+
> >+ if (slave->dev_num) /* clear dev_num if assigned */
> >+ clear_bit(slave->dev_num, bus->assigned);
> >+
> >+ list_del_init(&slave->node);
> >+ mutex_unlock(&bus->bus_lock);
> >+
> >+ device_unregister(dev);
> >+ return 0;
> >+}
> >+
> >+void sdw_delete_bus_master(struct sdw_bus *bus)
> >+{
> >+ device_for_each_child(bus->dev, NULL, sdw_delete_slave);
> >+}
> >+EXPORT_SYMBOL(sdw_delete_bus_master);
> No kerneldoc..??
will add.
>
> >+
> diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
> >new file mode 100644
> >index 000000000000..4bf2a6cf732c
> >--- /dev/null
> >+++ b/drivers/soundwire/slave.c
>
> >+
> >+#include <linux/acpi.h>
> >+#include <linux/init.h>
> >+#include <linux/soundwire/sdw.h>
> >+#include "bus.h"
> >+
> >+}
> >+
> >+static int sdw_slave_add(struct sdw_bus *bus,
> >+ struct sdw_slave_id *id, struct fwnode_handle *fwnode)
> >+{
> >+ struct sdw_slave *slave;
> >+ int ret;
> >+
> >+ slave = kzalloc(sizeof(*slave), GFP_KERNEL);
> >+ if (!slave)
> >+ return -ENOMEM;
> >+
> >+ /* Initialize data structure */
> >+ memcpy(&slave->id, id, sizeof(*id));
> >+ slave->dev.parent = bus->dev;
> >+ slave->dev.fwnode = fwnode;
> >+
> >+ /* name shall be sdw:link:mfg:part:class:unique */
> >+ dev_set_name(&slave->dev, "sdw:%x:%x:%x:%x:%x",
> >+ bus->link_id, id->mfg_id, id->part_id,
> >+ id->class_id, id->unique_id);
> >+
> >+ slave->dev.release = sdw_slave_release;
> >+ slave->dev.bus = &sdw_bus_type;
> >+ slave->bus = bus;
> >+ slave->status = SDW_SLAVE_UNATTACHED;
> >+ slave->dev_num = 0;
> >+
> >+ mutex_lock(&bus->bus_lock);
> >+ list_add_tail(&slave->node, &bus->slaves);
> >+ mutex_unlock(&bus->bus_lock);
> >+
> >+ ret = device_register(&slave->dev);
> >+ if (ret) {
> >+ dev_err(bus->dev, "Failed to add slave: ret %d\n", ret);
> >+
> >+ /*
> >+ * On err, don't free but drop ref as this will be freed
> >+ * when release method is invoked.
> >+ */
> >+ mutex_lock(&bus->bus_lock);
> >+ list_del(&slave->node);
> >+ mutex_unlock(&bus->bus_lock);
> >+ put_device(&slave->dev);
> >+ return ret;
>
> remove this line and ..
> >+ }
> >+
> >+ return 0;
>
> return ret;
better :)
> >+#if IS_ENABLED(CONFIG_OF)
> >+int sdw_of_find_slaves(struct sdw_bus *bus)
> >+{
> >+ /* placeholder now, fill on OF support */
> >+ return -ENOTSUPP;
> >+}
> >+#endif
>
> We should probably remove this dummy function, and add this functionality
> later.
this was kept for people to know how they may add DT support, but yes its
better to remove.
--
~Vinod
next prev parent reply other threads:[~2017-11-16 16:46 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 11:49 [PATCH v2 00/14] soundwire: Add a new SoundWire subsystem Vinod Koul
2017-11-10 11:49 ` Vinod Koul
2017-11-10 11:49 ` [PATCH v2 01/14] Documentation: Add SoundWire summary Vinod Koul
2017-11-10 11:49 ` Vinod Koul
2017-11-10 11:49 ` [PATCH v2 02/14] soundwire: Add SoundWire bus type Vinod Koul
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 17:02 ` Vinod Koul
2017-11-16 17:02 ` Vinod Koul
2017-11-16 17:24 ` Mark Brown
2017-11-16 17:24 ` Mark Brown
2017-11-17 3:52 ` Vinod Koul
2017-11-10 11:49 ` [PATCH v2 03/14] soundwire: Add Master registration Vinod Koul
2017-11-10 11:49 ` Vinod Koul
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 16:49 ` Vinod Koul [this message]
2017-11-16 16:49 ` Vinod Koul
2017-11-16 17:30 ` Mark Brown
2017-11-16 17:30 ` Mark Brown
2017-11-17 2:06 ` Vinod Koul
2017-11-17 2:06 ` [alsa-devel] " Vinod Koul
2017-11-10 11:49 ` [PATCH v2 04/14] soundwire: Add MIPI DisCo property helpers Vinod Koul
2017-11-10 11:49 ` Vinod Koul
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 17:04 ` Vinod Koul
2017-11-16 17:04 ` Vinod Koul
2017-11-23 14:38 ` Charles Keepax
2017-11-23 14:38 ` Charles Keepax
2017-11-24 16:04 ` Sanyog Kale
2017-11-27 7:59 ` Charles Keepax
2017-11-27 7:59 ` Charles Keepax
2017-11-27 9:18 ` Vinod Koul
2017-11-27 9:56 ` Charles Keepax
2017-11-27 9:56 ` Charles Keepax
2017-11-27 10:55 ` Vinod Koul
2017-11-27 10:55 ` [alsa-devel] " Vinod Koul
2017-11-10 11:49 ` [PATCH v2 05/14] soundwire: Add SoundWire MIPI defined registers Vinod Koul
2017-11-10 11:49 ` [PATCH v2 06/14] soundwire: Add IO transfer Vinod Koul
2017-11-10 11:49 ` Vinod Koul
2017-11-10 11:49 ` [PATCH v2 07/14] regmap: Add SoundWire bus support Vinod Koul
2017-11-16 12:04 ` Mark Brown
2017-11-16 12:04 ` Mark Brown
2017-11-16 13:02 ` Vinod Koul
2017-11-16 14:48 ` Mark Brown
2017-11-16 14:48 ` Mark Brown
2017-11-10 11:49 ` [PATCH v2 08/14] soundwire: Add Slave status handling helpers Vinod Koul
2017-11-16 16:05 ` Srinivas Kandagatla
2017-11-16 17:08 ` Vinod Koul
2017-11-16 17:08 ` Vinod Koul
2017-11-10 11:49 ` [PATCH v2 09/14] soundwire: Add slave status handling Vinod Koul
2017-11-10 11:49 ` [PATCH v2 10/14] soundwire: Add sysfs for SoundWire DisCo properties Vinod Koul
2017-11-10 11:49 ` [PATCH v2 11/14] soundwire: cdns: Add cadence library Vinod Koul
2017-11-10 11:49 ` [PATCH v2 12/14] soundwire: cdns: Add sdw_master_ops and IO transfer support Vinod Koul
2017-11-10 11:49 ` [PATCH v2 13/14] soundwire: intel: Add Intel Master driver Vinod Koul
2017-11-10 11:49 ` [PATCH v2 14/14] soundwire: intel: Add Intel init module Vinod Koul
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=20171116164944.GC3187@localhost \
--to=vinod.koul@intel.com \
--cc=alan@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches.audio@intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=plai@codeaurora.org \
--cc=sanyog.r.kale@intel.com \
--cc=sdharia@codeaurora.org \
--cc=shreyas.nc@intel.com \
--cc=spapothi@codeaurora.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.