diff mbox

[3/3] ASoC: Intel: atom: Add sysfs entry in order to store FW version

Message ID 20161104080411.12410-3-sebastien.guiriec@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastien Guiriec Nov. 4, 2016, 8:04 a.m. UTC
This patch is adding a sysfs entry in order to be able to get
access to SST FW version.

Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
---
 sound/soc/intel/atom/sst/sst.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Vinod Koul Nov. 7, 2016, 9:02 p.m. UTC | #1
On Fri, Nov 04, 2016 at 09:04:11AM +0100, Sebastien Guiriec wrote:
> This patch is adding a sysfs entry in order to be able to get
> access to SST FW version.
> 
> Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
> ---
>  sound/soc/intel/atom/sst/sst.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
> index a4b458e..dabbd06 100644
> --- a/sound/soc/intel/atom/sst/sst.c
> +++ b/sound/soc/intel/atom/sst/sst.c
> @@ -27,6 +27,7 @@
>  #include <linux/pm_qos.h>
>  #include <linux/async.h>
>  #include <linux/acpi.h>
> +#include <linux/sysfs.h>
>  #include <sound/core.h>
>  #include <sound/soc.h>
>  #include <asm/platform_sst_audio.h>
> @@ -241,6 +242,28 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
>  }
>  EXPORT_SYMBOL_GPL(sst_alloc_drv_context);
>  
> +static ssize_t firmware_version_show(struct device *dev,
> +			    struct device_attribute *attr, char *buf)
> +{
> +	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "v%02x.%02x.%02x.%02x\n",
> +			ctx->fw_version.type, ctx->fw_version.major,
> +			ctx->fw_version.minor, ctx->fw_version.build);

we should do this only after FW load, can you add that bit please. ALso
check we dont leak kernel memory when this is not set
Sebastien Guiriec Nov. 8, 2016, 8:29 a.m. UTC | #2
Hi Vinod,

On 07/11/2016 22:02, Vinod Koul wrote:
> On Fri, Nov 04, 2016 at 09:04:11AM +0100, Sebastien Guiriec wrote:
>> This patch is adding a sysfs entry in order to be able to get
>> access to SST FW version.
>>
>> Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
>> ---
>>  sound/soc/intel/atom/sst/sst.c | 35 +++++++++++++++++++++++++++++++++++
>>  1 file changed, 35 insertions(+)
>>
>> diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
>> index a4b458e..dabbd06 100644
>> --- a/sound/soc/intel/atom/sst/sst.c
>> +++ b/sound/soc/intel/atom/sst/sst.c
>> @@ -27,6 +27,7 @@
>>  #include <linux/pm_qos.h>
>>  #include <linux/async.h>
>>  #include <linux/acpi.h>
>> +#include <linux/sysfs.h>
>>  #include <sound/core.h>
>>  #include <sound/soc.h>
>>  #include <asm/platform_sst_audio.h>
>> @@ -241,6 +242,28 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
>>  }
>>  EXPORT_SYMBOL_GPL(sst_alloc_drv_context);
>>
>> +static ssize_t firmware_version_show(struct device *dev,
>> +			    struct device_attribute *attr, char *buf)
>>+{
>> +	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
>> +
>> +	return sprintf(buf, "v%02x.%02x.%02x.%02x\n",
>> +			ctx->fw_version.type, ctx->fw_version.major,
>> +			ctx->fw_version.minor, ctx->fw_version.build);
>
> we should do this only after FW load, can you add that bit please. ALso
> check we dont leak kernel memory when this is not set
>

Ok in case of v00.00.00.00 I will return "FW not yet Loaded".
Is it ok for you?

Seb
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Vinod Koul Nov. 9, 2016, 10:21 a.m. UTC | #3
On Tue, Nov 08, 2016 at 09:29:15AM +0100, Sebastien Guiriec wrote:
> >we should do this only after FW load, can you add that bit please. ALso
> >check we dont leak kernel memory when this is not set
> >
> 
> Ok in case of v00.00.00.00 I will return "FW not yet Loaded".
> Is it ok for you?

Yes sounds good to me :)
diff mbox

Patch

diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
index a4b458e..dabbd06 100644
--- a/sound/soc/intel/atom/sst/sst.c
+++ b/sound/soc/intel/atom/sst/sst.c
@@ -27,6 +27,7 @@ 
 #include <linux/pm_qos.h>
 #include <linux/async.h>
 #include <linux/acpi.h>
+#include <linux/sysfs.h>
 #include <sound/core.h>
 #include <sound/soc.h>
 #include <asm/platform_sst_audio.h>
@@ -241,6 +242,28 @@  int sst_alloc_drv_context(struct intel_sst_drv **ctx,
 }
 EXPORT_SYMBOL_GPL(sst_alloc_drv_context);
 
+static ssize_t firmware_version_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+
+	return sprintf(buf, "v%02x.%02x.%02x.%02x\n",
+			ctx->fw_version.type, ctx->fw_version.major,
+			ctx->fw_version.minor, ctx->fw_version.build);
+
+}
+
+DEVICE_ATTR_RO(firmware_version);
+
+static const struct attribute *sst_fw_version_attrs[] = {
+	&dev_attr_firmware_version.attr,
+	NULL,
+};
+
+static const struct attribute_group sst_fw_version_attr_group = {
+	.attrs = (struct attribute **)sst_fw_version_attrs,
+};
+
 int sst_context_init(struct intel_sst_drv *ctx)
 {
 	int ret = 0, i;
@@ -314,8 +337,19 @@  int sst_context_init(struct intel_sst_drv *ctx)
 		dev_err(ctx->dev, "Firmware download failed:%d\n", ret);
 		goto do_free_mem;
 	}
+
+	ret = sysfs_create_group(&ctx->dev->kobj,
+				 &sst_fw_version_attr_group);
+	if (ret) {
+		dev_err(ctx->dev,
+			"Unable to create sysfs\n");
+		goto err_sysfs;
+	}
+
 	sst_register(ctx->dev);
 	return 0;
+err_sysfs:
+	sysfs_remove_group(&ctx->dev->kobj, &sst_fw_version_attr_group);
 
 do_free_mem:
 	destroy_workqueue(ctx->post_msg_wq);
@@ -329,6 +363,7 @@  void sst_context_cleanup(struct intel_sst_drv *ctx)
 	pm_runtime_disable(ctx->dev);
 	sst_unregister(ctx->dev);
 	sst_set_fw_state_locked(ctx, SST_SHUTDOWN);
+	sysfs_remove_group(&ctx->dev->kobj, &sst_fw_version_attr_group);
 	flush_scheduled_work();
 	destroy_workqueue(ctx->post_msg_wq);
 	pm_qos_remove_request(ctx->qos);