greybus: audio: Enable codec module detection on different slots
authorVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Wed, 13 Jan 2016 21:07:56 +0000 (14:07 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 14 Jan 2016 00:49:32 +0000 (16:49 -0800)
driver_name associated with dev_name was hard coded earlier.
This limits, audio codec module to be detected on Port#5 only.

Now, driver_name is generated dynamically based on dev_name.
This enables codec module detection on any 1x2 slot.

Also, Update dev_id based on slot number, instead of bundle->id.
bundle->id is not unique for multiple modules added, thus now
using slot number for unique identification.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/audio_codec.c

index 2b4fcbedd161f7277ee8d2b98d0f52c78f553ddd..79f2baf607f46138019b077ad643439c0c1cf525 100644 (file)
@@ -575,7 +575,6 @@ static void gbaudio_free_codec(struct device *dev,
  * GB codec module driver ops
  */
 struct device_driver gb_codec_driver = {
-       .name = "1-8",
        .owner = THIS_MODULE,
 };
 
@@ -626,11 +625,12 @@ static void gb_audio_cleanup(struct gbaudio_codec_info *gb)
 static int gbaudio_codec_probe(struct gb_connection *connection)
 {
        int ret, i;
+       char *driver_name;
        struct gbaudio_codec_info *gbcodec;
        struct gb_audio_topology *topology;
        struct gb_audio_manager_module_descriptor desc;
        struct device *dev = &connection->bundle->dev;
-       int dev_id = connection->bundle->id;
+       int dev_id = connection->intf->interface_id;
 
        dev_dbg(dev, "Add device:%d:%s\n", dev_id, dev_name(dev));
        /* get gbcodec data */
@@ -670,6 +670,10 @@ static int gbaudio_codec_probe(struct gb_connection *connection)
                gbcodec->dais[i].ops = &gbcodec_dai_ops;
 
        /* FIXME */
+       driver_name = devm_kzalloc(dev, NAME_SIZE, GFP_KERNEL);
+       strlcpy(driver_name, gbcodec->name, NAME_SIZE);
+       gb_codec_driver.name = strsep(&driver_name, ".");
+       dev_dbg(dev, "driver.name:%s\n", gb_codec_driver.name);
        dev->driver = &gb_codec_driver;
 
        /* register codec */
@@ -730,7 +734,7 @@ static void gbaudio_codec_remove(struct gb_connection *connection)
 {
        struct gbaudio_codec_info *gbcodec;
        struct device *dev = &connection->bundle->dev;
-       int dev_id = connection->bundle->id;
+       int dev_id = connection->intf->interface_id;
 
        dev_dbg(dev, "Remove device:%d:%s\n", dev_id, dev_name(dev));
 
@@ -795,7 +799,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection)
 {
        struct gbaudio_dai *dai;
        struct device *dev = &connection->bundle->dev;
-       int dev_id = connection->bundle->id;
+       int dev_id = connection->intf->interface_id;
        struct gbaudio_codec_info *gbcodec = dev_get_drvdata(dev);
        struct gb_audio_manager_module_descriptor desc;
 
@@ -839,7 +843,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection)
 static void gbaudio_dai_remove(struct gb_connection *connection)
 {
        struct device *dev = &connection->bundle->dev;
-       int dev_id = connection->bundle->id;
+       int dev_id = connection->intf->interface_id;
        struct gbaudio_codec_info *gbcodec;
 
        dev_dbg(dev, "Remove DAI device:%d:%s\n", dev_id, dev_name(dev));