mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Peter Rosin <peda@axentia.se>
Cc: Aswath Govindraju <a-govindraju@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/6] mux: add missing mux_state_get
Date: Mon, 3 Jan 2022 13:42:02 +0100	[thread overview]
Message-ID: <YdLvGge5SbuhAi3N@kroah.com> (raw)
In-Reply-To: <90c40462-9672-949a-14cd-e13e440fe177@axentia.se>

On Sun, Jan 02, 2022 at 11:38:36PM +0100, Peter Rosin wrote:
> From: Peter Rosin <peda@axentia.se>
> 
> And implement devm_mux_state_get in terms of the new function.
> 
> Tested-by: Aswath Govindraju <a-govindraju@ti.com>
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/mux/core.c           | 41 ++++++++++++++++++++++++++----------
>  include/linux/mux/consumer.h |  1 +
>  2 files changed, 31 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
> index 7d38e7c0c02e..90073ce01539 100644
> --- a/drivers/mux/core.c
> +++ b/drivers/mux/core.c
> @@ -673,6 +673,33 @@ struct mux_control *devm_mux_control_get(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_mux_control_get);
>  
> +/**
> + * mux_state_get() - Get the mux-state for a device.
> + * @dev: The device that needs a mux-state.
> + * @mux_name: The name identifying the mux-state.
> + *
> + * Return: A pointer to the mux-state, or an ERR_PTR with a negative errno.
> + */
> +struct mux_state *mux_state_get(struct device *dev, const char *mux_name)
> +{
> +	struct mux_state *mstate;
> +
> +	mstate = kzalloc(sizeof(*mstate), GFP_KERNEL);
> +	if (!mstate)
> +		return ERR_PTR(-ENOMEM);
> +
> +	mstate->mux = mux_get(dev, mux_name, &mstate->state);

will this build?  I haven't applied it but mux_get() in my tree right
now is defined as:
	static inline void mux_get(struct gsm_mux *gsm)



> +	if (IS_ERR(mstate->mux)) {
> +		int err = PTR_ERR(mstate->mux);
> +
> +		kfree(mstate);
> +		return ERR_PTR(err);
> +	}
> +
> +	return mstate;
> +}
> +EXPORT_SYMBOL_GPL(mux_state_get);

No need to export it or make it global if no one is using it, right?

Also, who frees this new memory you just allocated?

> +
>  /**
>   * mux_state_put() - Put away the mux-state for good.
>   * @mstate: The mux-state to put away.
> @@ -705,25 +732,17 @@ struct mux_state *devm_mux_state_get(struct device *dev,
>  				     const char *mux_name)
>  {
>  	struct mux_state **ptr, *mstate;
> -	struct mux_control *mux_ctrl;
> -	int state;
> -
> -	mstate = devm_kzalloc(dev, sizeof(struct mux_state), GFP_KERNEL);
> -	if (!mstate)
> -		return ERR_PTR(-ENOMEM);

Before this state memory was here, assigned to the device, so it was
freed when the device was unbound.  I'm missing where this now
happens...

thanks,

greg k-h

  reply	other threads:[~2022-01-03 12:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02 22:34 mux for 5.17-rc1 Peter Rosin
2022-01-02 22:38 ` [PATCH 1/6] dt-bindings: ti-serdes-mux: Add defines for J721S2 SoC Peter Rosin
2022-01-02 22:38 ` [PATCH 2/6] dt-bindings: mux: Document mux-states property Peter Rosin
2022-01-02 22:38 ` [PATCH 3/6] mux: Add support for reading mux state from consumer DT node Peter Rosin
2022-01-03 12:43   ` Greg Kroah-Hartman
2022-01-03 13:05     ` Aswath Govindraju
2022-01-03 13:23       ` Greg Kroah-Hartman
2022-01-02 22:38 ` [PATCH 4/6] mux: add missing mux_state_get Peter Rosin
2022-01-03 12:42   ` Greg Kroah-Hartman [this message]
2022-01-03 17:26     ` Peter Rosin
2022-01-06 14:41       ` Greg Kroah-Hartman
2022-01-07  7:10         ` Peter Rosin
2022-01-02 22:38 ` [PATCH 5/6] mux: fix grammar, missing "is" Peter Rosin
2022-01-03 12:37   ` Greg Kroah-Hartman
2022-01-02 22:38 ` [PATCH 6/6] mux: Fix struct mux_state kernel-doc comment Peter Rosin
2022-01-03 12:46 ` mux for 5.17-rc1 Greg Kroah-Hartman

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=YdLvGge5SbuhAi3N@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=a-govindraju@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome