mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] platform/x86: silead_dmi - do not treat all devices as i2c_clients
Date: Tue, 4 Apr 2017 11:54:24 +0200	[thread overview]
Message-ID: <410e176d-7609-b38c-cd95-2284d152a82c@redhat.com> (raw)
In-Reply-To: <20170404032514.31832-1-dmitry.torokhov@gmail.com>

Hi,

On 04-04-17 05:25, Dmitry Torokhov wrote:
> I2C bus has both i2c clients and adapter devices, so we must be careful in
> notifier code and verify that we are actually dealing with an i2c client
> before using it as such.
>
> Fixes: cef9dd85acd7 ("platform/x86: add support for devices with Silead...")
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thank you for fixing this, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/platform/x86/silead_dmi.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/silead_dmi.c b/drivers/platform/x86/silead_dmi.c
> index 02e11fdbf375..7f1049951d1c 100644
> --- a/drivers/platform/x86/silead_dmi.c
> +++ b/drivers/platform/x86/silead_dmi.c
> @@ -75,9 +75,8 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
>  	{ },
>  };
>
> -static void silead_ts_dmi_add_props(struct device *dev)
> +static void silead_ts_dmi_add_props(struct i2c_client *client)
>  {
> -	struct i2c_client *client = to_i2c_client(dev);
>  	const struct dmi_system_id *dmi_id;
>  	const struct silead_ts_dmi_data *ts_data;
>  	int error;
> @@ -87,11 +86,13 @@ static void silead_ts_dmi_add_props(struct device *dev)
>  		return;
>
>  	ts_data = dmi_id->driver_data;
> -	if (has_acpi_companion(dev) &&
> +	if (has_acpi_companion(&client->dev) &&
>  	    !strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
> -		error = device_add_properties(dev, ts_data->properties);
> +		error = device_add_properties(&client->dev,
> +					      ts_data->properties);
>  		if (error)
> -			dev_err(dev, "failed to add properties: %d\n", error);
> +			dev_err(&client->dev,
> +				"failed to add properties: %d\n", error);
>  	}
>  }
>
> @@ -99,10 +100,13 @@ static int silead_ts_dmi_notifier_call(struct notifier_block *nb,
>  				       unsigned long action, void *data)
>  {
>  	struct device *dev = data;
> +	struct i2c_client *client;
>
>  	switch (action) {
>  	case BUS_NOTIFY_ADD_DEVICE:
> -		silead_ts_dmi_add_props(dev);
> +		client = i2c_verify_client(dev);
> +		if (client)
> +			silead_ts_dmi_add_props(client);
>  		break;
>
>  	default:
>

  parent reply	other threads:[~2017-04-04  9:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04  3:25 Dmitry Torokhov
2017-04-04  3:25 ` [PATCH 2/2] platform/x86: silead_dmi - abort early if DMI does not match Dmitry Torokhov
2017-04-04  9:54   ` Hans de Goede
2017-04-06 21:47   ` Andy Shevchenko
2017-04-04  9:54 ` Hans de Goede [this message]
2017-04-04 13:45 ` [PATCH 1/2] platform/x86: silead_dmi - do not treat all devices as i2c_clients Andy Shevchenko
2017-04-04 16:05   ` Darren Hart
2017-04-04 16:08     ` Andy Shevchenko
2017-04-04 16:31       ` Darren Hart
2017-04-04 16:33         ` Andy Shevchenko
2017-04-04 17:12           ` Dmitry Torokhov

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=410e176d-7609-b38c-cd95-2284d152a82c@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@infradead.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®