All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>,
	"lars@metafoo.de" <lars@metafoo.de>
Subject: Re: [PATCH v4 1/4] Input: adp5589: Add default platform data
Date: Wed, 1 Apr 2020 14:05:17 +0000	[thread overview]
Message-ID: <44fc70102430d4d13221907a3d5ccd2d8021b854.camel@analog.com> (raw)
In-Reply-To: <20200305131405.6598-1-alexandru.ardelean@analog.com>

On Thu, 2020-03-05 at 15:14 +0200, Alexandru Ardelean wrote:
> From: Lars-Peter Clausen <lars@metafoo.de>
> 
> If no platform data is supplied use a dummy platform data that configures
> the device in GPIO only mode. This change adds a adp5589_kpad_pdata_get()
> helper that returns the default platform-data. This can be later extended
> to load configuration from device-trees or ACPI.

ping

> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
> 
> Changelog v3 -> v4:
> * Fixed smatch warnings about potential leak being created; resulted in 2
>   more patches:
>   - Input: adp5589: unify ret & error variables
>   - Input: adp5589: fix possible memleak of 'kpad'
> 
> Changelog v2 -> v3:
> * fix `-Wpointer-to-int-cast` warnings for patch `input: adp5589: Add basic
>   devicetree support` ; warnings shows up on 64 bit ARCHs
> 
> Changelog v1 -> v2:
> * adjusted patch `input: adp5589: Add default platform data` by
>   introducting a `adp5589_kpad_pdata_get()` helper, which returns the
>   platform-data; the previos patch was based on an older version of the
>   kernel from the ADI kernel-tree; the driver was sync-ed with the upstream
>   version
> 
>  drivers/input/keyboard/adp5589-keys.c | 36 +++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/input/keyboard/adp5589-keys.c
> b/drivers/input/keyboard/adp5589-keys.c
> index e7d58e7f0257..c6a801bcdf90 100644
> --- a/drivers/input/keyboard/adp5589-keys.c
> +++ b/drivers/input/keyboard/adp5589-keys.c
> @@ -369,6 +369,25 @@ static const struct adp_constants const_adp5585 = {
>  	.reg			= adp5585_reg,
>  };
>  
> +static const struct adp5589_gpio_platform_data adp5589_default_gpio_pdata = {
> +	.gpio_start = -1,
> +};
> +
> +static const struct adp5589_kpad_platform_data adp5589_default_pdata = {
> +	.gpio_data = &adp5589_default_gpio_pdata,
> +};
> +
> +static const struct adp5589_kpad_platform_data *adp5589_kpad_pdata_get(
> +	struct device *dev)
> +{
> +	const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
> +
> +	if (!pdata)
> +		pdata = &adp5589_default_pdata;
> +
> +	return pdata;
> +}
> +
>  static int adp5589_read(struct i2c_client *client, u8 reg)
>  {
>  	int ret = i2c_smbus_read_byte_data(client, reg);
> @@ -498,7 +517,8 @@ static int adp5589_build_gpiomap(struct adp5589_kpad
> *kpad,
>  static int adp5589_gpio_add(struct adp5589_kpad *kpad)
>  {
>  	struct device *dev = &kpad->client->dev;
> -	const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
> +	const struct adp5589_kpad_platform_data *pdata =
> +		adp5589_kpad_pdata_get(dev);
>  	const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
>  	int i, error;
>  
> @@ -553,7 +573,8 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad)
>  static void adp5589_gpio_remove(struct adp5589_kpad *kpad)
>  {
>  	struct device *dev = &kpad->client->dev;
> -	const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev);
> +	const struct adp5589_kpad_platform_data *pdata =
> +		adp5589_kpad_pdata_get(dev);
>  	const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data;
>  	int error;
>  
> @@ -656,7 +677,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
>  {
>  	struct i2c_client *client = kpad->client;
>  	const struct adp5589_kpad_platform_data *pdata =
> -		dev_get_platdata(&client->dev);
> +		adp5589_kpad_pdata_get(&client->dev);
>  	u8 (*reg) (u8) = kpad->var->reg;
>  	unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0;
>  	unsigned char pull_mask = 0;
> @@ -861,7 +882,7 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad,
> unsigned int revid)
>  {
>  	struct i2c_client *client = kpad->client;
>  	const struct adp5589_kpad_platform_data *pdata =
> -		dev_get_platdata(&client->dev);
> +		adp5589_kpad_pdata_get(&client->dev);
>  	struct input_dev *input;
>  	unsigned int i;
>  	int error;
> @@ -992,7 +1013,7 @@ static int adp5589_probe(struct i2c_client *client,
>  {
>  	struct adp5589_kpad *kpad;
>  	const struct adp5589_kpad_platform_data *pdata =
> -		dev_get_platdata(&client->dev);
> +		adp5589_kpad_pdata_get(&client->dev);
>  	unsigned int revid;
>  	int error, ret;
>  
> @@ -1002,11 +1023,6 @@ static int adp5589_probe(struct i2c_client *client,
>  		return -EIO;
>  	}
>  
> -	if (!pdata) {
> -		dev_err(&client->dev, "no platform data?\n");
> -		return -EINVAL;
> -	}
> -
>  	kpad = kzalloc(sizeof(*kpad), GFP_KERNEL);
>  	if (!kpad)
>  		return -ENOMEM;

      parent reply	other threads:[~2020-04-01 14:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 13:14 [PATCH v4 1/4] Input: adp5589: Add default platform data Alexandru Ardelean
2020-03-05 13:14 ` [PATCH v4 2/4] Input: adp5589: Add basic devicetree support Alexandru Ardelean
2020-03-05 13:14 ` [PATCH v4 3/4] Input: adp5589: unify ret & error variables Alexandru Ardelean
2020-03-05 13:29   ` Dan Carpenter
2020-03-05 13:14 ` [PATCH v4 4/4] Input: adp5589: fix possible memleak of 'kpad' Alexandru Ardelean
2020-04-01 14:05 ` Ardelean, Alexandru [this message]

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=44fc70102430d4d13221907a3d5ccd2d8021b854.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.