linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Bastien Nocera <hadess@hadess.net>,
	Stephen Just <stephenjust@gmail.com>,
	Sebastian Reichel <sre@kernel.org>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Len Brown <lenb@kernel.org>,
	Robert Moore <robert.moore@intel.com>,
	Lv Zheng <lv.zheng@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	devel@acpica.org,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] ACPI: surface3_power: MSHW0011 rev-eng implementation
Date: Fri, 30 Jun 2017 17:43:47 +0200	[thread overview]
Message-ID: <f0feab26-a71f-522c-9a54-9e6ac03878a7@redhat.com> (raw)
In-Reply-To: <20170630152645.GK26073@mail.corp.redhat.com>

Hi,

On 30-06-17 17:26, Benjamin Tissoires wrote:
> On Jun 30 2017 or thereabouts, Hans de Goede wrote:

<snip>

>>>> +static int mshw0011_i2c_resource_lookup(struct mshw0011_data *cdata,
>>>> +                                       unsigned int index)
>>>> +{
>>>> +       struct i2c_client *client = cdata->adp1;
>>>> +       struct acpi_device *adev = ACPI_COMPANION(&client->dev);
>>>> +       struct mshw0011_lookup lookup = {
>>>> +               .cdata = cdata,
>>>> +               .index = index,
>>>> +       };
>>>> +       struct list_head res_list;
>>>> +       int ret;
>>>> +
>>>> +       INIT_LIST_HEAD(&res_list);
>>>> +
>>>> +       ret = acpi_dev_get_resources(adev, &res_list, acpi_find_i2c, &lookup);
>>>> +       if (ret < 0)
>>>> +               return ret;
>>>> +
>>>> +       acpi_dev_free_resource_list(&res_list);
>>>> +
>>>> +       if (!lookup.addr)
>>>> +               return -ENOENT;
>>>> +
>>>> +       return lookup.addr;
>>>> +}
>>>
>>> Strange you have above functions here. It's a copy paste from I2C > core. Please, think about way of deduplicating it.
>>
>> Right, this is something I can actually help with. When implementing the
>> INT33FE support (*) I also was dealing with an ACPI node with more then 1
>> I2cSerialBus type resource and I needed not just an i2c-client for the
>> first one (which the i2c-core gives us) but also for the others.
>>
>> In 4.12 there is an i2c_acpi_new_device function which you can use
>> to create an i2c-client for the second i2c address you want to communicate
>> with, here is an example usage:
>>
>> struct i2c_board_info board_info;
>>
>> memset(&board_info, 0, sizeof(board_info));
>> strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>> bat0 = i2c_acpi_new_device(dev, 1, &board_info);
>>
>> And then you can use bat0 to communicate to the other address,
>> as before, while dropping a whole bunch of copy-pasted code :)
> 
> Thanks for the tip. I wrote this code more than a year ago IIRC, and
> there might not be those facilities at the time.

Correct I hit the same problem with the INT33FE device and decided
to fix this properly :)  The i2c_acpi_new_device function is new
in 4.12 .

Regards,

Hans


  reply	other threads:[~2017-06-30 15:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 12:10 [PATCH v2] ACPI: surface3_power: MSHW0011 rev-eng implementation Benjamin Tissoires
2017-06-29 14:22 ` Andy Shevchenko
2017-06-29 20:22   ` Rafael J. Wysocki
2017-06-30 15:24     ` Benjamin Tissoires
2017-06-30 15:42       ` Hans de Goede
2017-06-30 12:49   ` Hans de Goede
2017-06-30 15:26     ` Benjamin Tissoires
2017-06-30 15:43       ` Hans de Goede [this message]
2017-06-30 15:57   ` Benjamin Tissoires
2017-06-30 16:37     ` Andy Shevchenko
2017-06-30 17:37       ` Hans de Goede
2017-06-30 17:40         ` Andy Shevchenko
2017-06-30 17:42           ` Hans de Goede
2017-06-30 17:55             ` Andy Shevchenko
2017-06-30 17:58               ` Andy Shevchenko
2018-08-31 14:54       ` Benjamin Tissoires
2018-09-06 14:43         ` Moore, Robert
2017-07-01  0:47 ` Sebastian Reichel
2017-07-01 19:53   ` Julia Lawall

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=f0feab26-a71f-522c-9a54-9e6ac03878a7@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=devel@acpica.org \
    --cc=hadess@hadess.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=sre@kernel.org \
    --cc=stephenjust@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).