diff mbox series

[v2] ASoC: ti: omap-mcbsp: duplicate sysfs error

Message ID 20220615150955.4140789-1-dowens@precisionplanting.com
State New
Headers show
Series [v2] ASoC: ti: omap-mcbsp: duplicate sysfs error | expand

Commit Message

David Owens June 15, 2022, 3:09 p.m. UTC
Convert to managed versions of sysfs and clk allocation to simplify
unbinding and error handling in probe.  Managed sysfs node
creation specifically addresses the following error seen the second time
probe is attempted after sdma_pcm_platform_register() previously requsted
probe deferral:

sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'

Signed-off-by: David Owens <dowens@precisionplanting.com>
---
 sound/soc/ti/omap-mcbsp-priv.h |  2 --
 sound/soc/ti/omap-mcbsp-st.c   | 21 ++++-----------------
 sound/soc/ti/omap-mcbsp.c      | 26 ++++----------------------
 3 files changed, 8 insertions(+), 41 deletions(-)

--
2.34.1

This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of Precision Planting. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses, and it is your responsibility to scan, and virus check the e-mail and its attachment(s) (if any).

Comments

Péter Ujfalusi June 16, 2022, 2:25 p.m. UTC | #1
Hi David,

On 6/15/22 18:09, David Owens wrote:
> Convert to managed versions of sysfs and clk allocation to simplify
> unbinding and error handling in probe.  Managed sysfs node
> creation specifically addresses the following error seen the second time
> probe is attempted after sdma_pcm_platform_register() previously requsted
> probe deferral:
> 
> sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'

I have tried to looked up devm_sysfs_remove_group(), which did not
existed, but you found the correct devm ;)

Looks good, thank you!

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>


> Signed-off-by: David Owens <dowens@precisionplanting.com>
> ---
>  sound/soc/ti/omap-mcbsp-priv.h |  2 --
>  sound/soc/ti/omap-mcbsp-st.c   | 21 ++++-----------------
>  sound/soc/ti/omap-mcbsp.c      | 26 ++++----------------------
>  3 files changed, 8 insertions(+), 41 deletions(-)
> 
> diff --git a/sound/soc/ti/omap-mcbsp-priv.h b/sound/soc/ti/omap-mcbsp-priv.h
> index 7865cda4bf0a..da519ea1f303 100644
> --- a/sound/soc/ti/omap-mcbsp-priv.h
> +++ b/sound/soc/ti/omap-mcbsp-priv.h
> @@ -316,8 +316,6 @@ static inline int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg,
> 
>  /* Sidetone specific API */
>  int omap_mcbsp_st_init(struct platform_device *pdev);
> -void omap_mcbsp_st_cleanup(struct platform_device *pdev);
> -
>  int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp);
>  int omap_mcbsp_st_stop(struct omap_mcbsp *mcbsp);
> 
> diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
> index 0bc7d26c660a..402a57a502e6 100644
> --- a/sound/soc/ti/omap-mcbsp-st.c
> +++ b/sound/soc/ti/omap-mcbsp-st.c
> @@ -292,14 +292,11 @@ static ssize_t st_taps_store(struct device *dev,
> 
>  static DEVICE_ATTR_RW(st_taps);
> 
> -static const struct attribute *sidetone_attrs[] = {
> +static struct attribute *sidetone_attrs[] = {
>         &dev_attr_st_taps.attr,
>         NULL,
>  };
> -
> -static const struct attribute_group sidetone_attr_group = {
> -       .attrs = (struct attribute **)sidetone_attrs,
> -};
> +ATTRIBUTE_GROUPS(sidetone);
> 
>  int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp)
>  {
> @@ -347,7 +344,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
>         if (!st_data)
>                 return -ENOMEM;
> 
> -       st_data->mcbsp_iclk = clk_get(mcbsp->dev, "ick");
> +       st_data->mcbsp_iclk = devm_clk_get(mcbsp->dev, "ick");
>         if (IS_ERR(st_data->mcbsp_iclk)) {
>                 dev_warn(mcbsp->dev,
>                          "Failed to get ick, sidetone might be broken\n");
> @@ -359,7 +356,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
>         if (!st_data->io_base_st)
>                 return -ENOMEM;
> 
> -       ret = sysfs_create_group(&mcbsp->dev->kobj, &sidetone_attr_group);
> +       ret = devm_device_add_group(mcbsp->dev, &sidetone_group);
>         if (ret)
>                 return ret;
> 
> @@ -368,16 +365,6 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
>         return 0;
>  }
> 
> -void omap_mcbsp_st_cleanup(struct platform_device *pdev)
> -{
> -       struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
> -
> -       if (mcbsp->st_data) {
> -               sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group);
> -               clk_put(mcbsp->st_data->mcbsp_iclk);
> -       }
> -}
> -
>  static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
>                                     struct snd_ctl_elem_info *uinfo)
>  {
> diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
> index 4479d74f0a45..395493a2d965 100644
> --- a/sound/soc/ti/omap-mcbsp.c
> +++ b/sound/soc/ti/omap-mcbsp.c
> @@ -595,16 +595,13 @@ static ssize_t dma_op_mode_store(struct device *dev,
> 
>  static DEVICE_ATTR_RW(dma_op_mode);
> 
> -static const struct attribute *additional_attrs[] = {
> +static struct attribute *additional_attrs[] = {
>         &dev_attr_max_tx_thres.attr,
>         &dev_attr_max_rx_thres.attr,
>         &dev_attr_dma_op_mode.attr,
>         NULL,
>  };
> -
> -static const struct attribute_group additional_attr_group = {
> -       .attrs = (struct attribute **)additional_attrs,
> -};
> +ATTRIBUTE_GROUPS(additional);
> 
>  /*
>   * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
> @@ -702,8 +699,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
>                 mcbsp->max_tx_thres = max_thres(mcbsp) - 0x10;
>                 mcbsp->max_rx_thres = max_thres(mcbsp) - 0x10;
> 
> -               ret = sysfs_create_group(&mcbsp->dev->kobj,
> -                                        &additional_attr_group);
> +               ret = devm_device_add_group(mcbsp->dev, &additional_group);
>                 if (ret) {
>                         dev_err(mcbsp->dev,
>                                 "Unable to create additional controls\n");
> @@ -711,16 +707,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
>                 }
>         }
> 
> -       ret = omap_mcbsp_st_init(pdev);
> -       if (ret)
> -               goto err_st;
> -
> -       return 0;
> -
> -err_st:
> -       if (mcbsp->pdata->buffer_size)
> -               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
> -       return ret;
> +       return omap_mcbsp_st_init(pdev);
>  }
> 
>  /*
> @@ -1431,11 +1418,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)
>         if (cpu_latency_qos_request_active(&mcbsp->pm_qos_req))
>                 cpu_latency_qos_remove_request(&mcbsp->pm_qos_req);
> 
> -       if (mcbsp->pdata->buffer_size)
> -               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
> -
> -       omap_mcbsp_st_cleanup(pdev);
> -
>         return 0;
>  }
> 
> --
> 2.34.1
> 
> This email is intended solely for the use of the individual to whom it is addressed and may contain confidential and/or privileged material. Any views or opinions presented are solely those of the author and do not necessarily represent those of Precision Planting. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. Neither AGCO nor the sender accepts any responsibility for viruses, and it is your responsibility to scan, and virus check the e-mail and its attachment(s) (if any).
Mark Brown June 16, 2022, 2:57 p.m. UTC | #2
On Wed, Jun 15, 2022 at 10:09:55AM -0500, David Owens wrote:
> Convert to managed versions of sysfs and clk allocation to simplify
> unbinding and error handling in probe.  Managed sysfs node
> creation specifically addresses the following error seen the second time
> probe is attempted after sdma_pcm_platform_register() previously requsted
> probe deferral:

This doesn't apply against current code (either for-5.19 or for-5.20),
please check and resend.
Mark Brown June 27, 2022, 8:19 p.m. UTC | #3
On Wed, 15 Jun 2022 10:09:55 -0500, David Owens wrote:
> Convert to managed versions of sysfs and clk allocation to simplify
> unbinding and error handling in probe.  Managed sysfs node
> creation specifically addresses the following error seen the second time
> probe is attempted after sdma_pcm_platform_register() previously requsted
> probe deferral:
> 
> sysfs: cannot create duplicate filename '/devices/platform/68000000.ocp/49022000.mcbsp/max_tx_thres'
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: ti: omap-mcbsp: duplicate sysfs error
      commit: 6d31e225742a1955db8a0c6f6f52beb748a2895e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/ti/omap-mcbsp-priv.h b/sound/soc/ti/omap-mcbsp-priv.h
index 7865cda4bf0a..da519ea1f303 100644
--- a/sound/soc/ti/omap-mcbsp-priv.h
+++ b/sound/soc/ti/omap-mcbsp-priv.h
@@ -316,8 +316,6 @@  static inline int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg,

 /* Sidetone specific API */
 int omap_mcbsp_st_init(struct platform_device *pdev);
-void omap_mcbsp_st_cleanup(struct platform_device *pdev);
-
 int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp);
 int omap_mcbsp_st_stop(struct omap_mcbsp *mcbsp);

diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
index 0bc7d26c660a..402a57a502e6 100644
--- a/sound/soc/ti/omap-mcbsp-st.c
+++ b/sound/soc/ti/omap-mcbsp-st.c
@@ -292,14 +292,11 @@  static ssize_t st_taps_store(struct device *dev,

 static DEVICE_ATTR_RW(st_taps);

-static const struct attribute *sidetone_attrs[] = {
+static struct attribute *sidetone_attrs[] = {
        &dev_attr_st_taps.attr,
        NULL,
 };
-
-static const struct attribute_group sidetone_attr_group = {
-       .attrs = (struct attribute **)sidetone_attrs,
-};
+ATTRIBUTE_GROUPS(sidetone);

 int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp)
 {
@@ -347,7 +344,7 @@  int omap_mcbsp_st_init(struct platform_device *pdev)
        if (!st_data)
                return -ENOMEM;

-       st_data->mcbsp_iclk = clk_get(mcbsp->dev, "ick");
+       st_data->mcbsp_iclk = devm_clk_get(mcbsp->dev, "ick");
        if (IS_ERR(st_data->mcbsp_iclk)) {
                dev_warn(mcbsp->dev,
                         "Failed to get ick, sidetone might be broken\n");
@@ -359,7 +356,7 @@  int omap_mcbsp_st_init(struct platform_device *pdev)
        if (!st_data->io_base_st)
                return -ENOMEM;

-       ret = sysfs_create_group(&mcbsp->dev->kobj, &sidetone_attr_group);
+       ret = devm_device_add_group(mcbsp->dev, &sidetone_group);
        if (ret)
                return ret;

@@ -368,16 +365,6 @@  int omap_mcbsp_st_init(struct platform_device *pdev)
        return 0;
 }

-void omap_mcbsp_st_cleanup(struct platform_device *pdev)
-{
-       struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
-
-       if (mcbsp->st_data) {
-               sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group);
-               clk_put(mcbsp->st_data->mcbsp_iclk);
-       }
-}
-
 static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_info *uinfo)
 {
diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index 4479d74f0a45..395493a2d965 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -595,16 +595,13 @@  static ssize_t dma_op_mode_store(struct device *dev,

 static DEVICE_ATTR_RW(dma_op_mode);

-static const struct attribute *additional_attrs[] = {
+static struct attribute *additional_attrs[] = {
        &dev_attr_max_tx_thres.attr,
        &dev_attr_max_rx_thres.attr,
        &dev_attr_dma_op_mode.attr,
        NULL,
 };
-
-static const struct attribute_group additional_attr_group = {
-       .attrs = (struct attribute **)additional_attrs,
-};
+ATTRIBUTE_GROUPS(additional);

 /*
  * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
@@ -702,8 +699,7 @@  static int omap_mcbsp_init(struct platform_device *pdev)
                mcbsp->max_tx_thres = max_thres(mcbsp) - 0x10;
                mcbsp->max_rx_thres = max_thres(mcbsp) - 0x10;

-               ret = sysfs_create_group(&mcbsp->dev->kobj,
-                                        &additional_attr_group);
+               ret = devm_device_add_group(mcbsp->dev, &additional_group);
                if (ret) {
                        dev_err(mcbsp->dev,
                                "Unable to create additional controls\n");
@@ -711,16 +707,7 @@  static int omap_mcbsp_init(struct platform_device *pdev)
                }
        }

-       ret = omap_mcbsp_st_init(pdev);
-       if (ret)
-               goto err_st;
-
-       return 0;
-
-err_st:
-       if (mcbsp->pdata->buffer_size)
-               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
-       return ret;
+       return omap_mcbsp_st_init(pdev);
 }

 /*
@@ -1431,11 +1418,6 @@  static int asoc_mcbsp_remove(struct platform_device *pdev)
        if (cpu_latency_qos_request_active(&mcbsp->pm_qos_req))
                cpu_latency_qos_remove_request(&mcbsp->pm_qos_req);

-       if (mcbsp->pdata->buffer_size)
-               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
-
-       omap_mcbsp_st_cleanup(pdev);
-
        return 0;
 }