APPLIED: [SRU] [jammy:linux-xilinx-zynqmp v2 1/1] UBUNTU: SAUCE: imx547 : Used devm_* resource management functions instead of gpiod_*

Portia Stephens portia.stephens at canonical.com
Wed Aug 7 13:50:39 UTC 2024


On Mon, Aug 5, 2024 at 12:02 PM Portia Stephens
<portia.stephens at canonical.com> wrote:
>
> BugLink: https://bugs.launchpad.net/bugs/2076108
>
> With current use of non-devm functions the user is responsible for freeing
> the resources and since this is not handled currently the driver does not probe
> the sensor on the second load, since resources are not freed.
> Here is a dmesg snippet:
> On first load
> ubuntu at kria:~$ sudo dmesg | grep imx547
> [   72.621037] imx547: module is from the staging directory, the quality is unknown, you have been warned.
> [   72.628992] imx547 7-001a: imx547 : imx547 probe success !
> On second load:
> ubuntu at kria:~$ sudo dmesg | grep imx547
> [  312.319586] imx547 7-001a: GT TRX Reset GPIO not setup in DT
> [  312.325487] imx547: probe of 7-001a failed with error -16
>
> Since freeing of the GPIO resource is not explicitly handled in current implementation
> the driver fails to probe the sensor and fails to add it to media subsystem. In this case,
> developer needs to add explicit cleanup code.
>
> New implementation of using device managed ie devm_* functions ensures that resource is
> automatically removed when driver is unloaded.
>
> Signed-off-by: Sagar Karmarkar <sagar.karmarkar at amd.com>
> (cherry-picked from git at github.com:Xilinx/mv-camera-sensor-module.git v0.3)
> Signed-off-by: Portia Stephens <portia.stephens at canonical.com>
> ---
>  ubuntu/staging/xilinx-mv-camera-sensor-module/imx547.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ubuntu/staging/xilinx-mv-camera-sensor-module/imx547.c b/ubuntu/staging/xilinx-mv-camera-sensor-module/imx547.c
> index fc4f4a44b5cd..094dfc6d7e86 100644
> --- a/ubuntu/staging/xilinx-mv-camera-sensor-module/imx547.c
> +++ b/ubuntu/staging/xilinx-mv-camera-sensor-module/imx547.c
> @@ -1037,7 +1037,7 @@ static int imx547_probe(struct i2c_client *client)
>      }
>
>      /* initialize gt trx reset gpio */
> -    imx547->gt_trx_reset_gpio = gpiod_get_index_optional(&client->dev, "reset",
> +    imx547->gt_trx_reset_gpio = devm_gpiod_get_index_optional(&client->dev, "reset",
>                                  0, GPIOD_OUT_HIGH);
>      if (IS_ERR(imx547->gt_trx_reset_gpio)) {
>          if (PTR_ERR(imx547->gt_trx_reset_gpio) != -EPROBE_DEFER)
> @@ -1047,7 +1047,7 @@ static int imx547_probe(struct i2c_client *client)
>      }
>
>      /* initialize pipe reset gpio */
> -    imx547->pipe_reset_gpio = gpiod_get_index_optional(&client->dev, "reset",
> +    imx547->pipe_reset_gpio = devm_gpiod_get_index_optional(&client->dev, "reset",
>                                1, GPIOD_OUT_HIGH);
>      if (IS_ERR(imx547->pipe_reset_gpio)) {
>          if (PTR_ERR(imx547->pipe_reset_gpio) != -EPROBE_DEFER)
> --
> 2.34.1
>



More information about the kernel-team mailing list