LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	<xuwei5@huawei.com>, <mika.westerberg@linux.intel.com>,
	<lee.jones@linaro.org>
Cc: <rjw@rjwysocki.net>, <linux-kernel@vger.kernel.org>,
	<arnd@arndb.de>, <graeme.gregory@linaro.org>,
	<helgaas@kernel.org>, <z.liuxinliang@hisilicon.com>,
	<linuxarm@huawei.com>
Subject: Re: [PATCH 1/2] HISI LPC: Reference static MFD cells for ACPI support
Date: Fri, 4 May 2018 13:29:53 +0100	[thread overview]
Message-ID: <8c2627fa-a350-9a39-6a54-c789b6a3546a@huawei.com> (raw)
In-Reply-To: <1525366486.21176.653.camel@linux.intel.com>

On 03/05/2018 17:54, Andy Shevchenko wrote:
> On Thu, 2018-05-03 at 23:08 +0800, John Garry wrote:
>> Currently for ACPI support the driver models the host as
>> an MFD. For a device connected to the LPC bus, we dynamically
>> create an MFD cell for that device, configuring the cell
>> name and ACPI match parameters manually. This makes supporting
>> named devices and also special setup handling for certain devices
>> awkward, as we would need to introduce some special ACPI device
>> handling according to device HID.
>>
>> To avoid this, create reference static MFD cells for known
>> child devices, so when adding an MFD cell we can fix the cell
>> platform data as required. For this, a setup callback function
>> is added.

Hi Andy,

>>
>> For now, only the IPMI cell is added.
>
>> +static const struct mfd_cell *hisi_lpc_acpi_mfd_get_cell(const char
>> *hid)
>> +{
>> +	const struct hisi_lpc_acpi_mfd_cell *cell =
>> hisi_lpc_acpi_mfd_cells;
>> +
>> +	for (; cell && cell->mfd_cell.name; cell++) {
>> +		const struct mfd_cell *mfd_cell = &cell->mfd_cell;
>> +		const struct mfd_cell_acpi_match *acpi_match;
>> +
>> +		acpi_match = mfd_cell->acpi_match;
>> +		if (!strcmp(acpi_match->pnpid, hid))
>> +			return mfd_cell;
>> +	}
>> +
>> +	return NULL;
>> +}
>
> I'm not sure I understand why MFD core can't do it (as seen in lines
> drivers/mfd/core.c:105 and below).
>

Right, I think MFD core does the same.

>> +	/* allocate the mfd cells, one per child */
>> +	size = sizeof(*mfd_cells);
>>  	mfd_cells = devm_kcalloc(hostdev, cell_num, size,
>> GFP_KERNEL);
>>  	if (!mfd_cells)
>>  		return -ENOMEM;
>
> And since you have structures already, I'm not sure why you need another
> allocation for them. Only what you would need is to apply resources and
> call devm_mfd_add_devices() per each found device.

I was creating a copy as the originals are in the hisi_lpc_acpi_mfd_cell 
struct type, while we would require an array of mfd_cells.

>
>> +		cell = container_of(mfd_cell_ref, typeof(*cell),
>> mfd_cell);
>
> Why we can't iterate over inherited type of objects directly?
>

We could do.

Thanks,
John

  parent reply	other threads:[~2018-05-04 12:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 15:08 [PATCH 0/2] HISI LPC ACPI UART support John Garry
2018-05-03 15:08 ` [PATCH 1/2] HISI LPC: Reference static MFD cells for ACPI support John Garry
2018-05-03 16:54   ` Andy Shevchenko
2018-05-04  9:02     ` Lee Jones
2018-05-04  9:27       ` John Garry
2018-05-04 10:03         ` Lee Jones
2018-05-04 10:21           ` John Garry
2018-05-04 12:29     ` John Garry [this message]
2018-05-03 15:08 ` [PATCH 2/2] HISI LPC: Add ACPI UART support John Garry
2018-05-03 16:56   ` Andy Shevchenko
2018-05-04 12:33     ` John Garry

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=8c2627fa-a350-9a39-6a54-c789b6a3546a@huawei.com \
    --to=john.garry@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=graeme.gregory@linaro.org \
    --cc=helgaas@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=xuwei5@huawei.com \
    --cc=z.liuxinliang@hisilicon.com \
    --subject='Re: [PATCH 1/2] HISI LPC: Reference static MFD cells for ACPI support' \
    /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

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).