lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 03 May 2018 19:54:46 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     John Garry <john.garry@...wei.com>, xuwei5@...wei.com,
        mika.westerberg@...ux.intel.com, lee.jones@...aro.org
Cc:     rjw@...ysocki.net, linux-kernel@...r.kernel.org, arnd@...db.de,
        graeme.gregory@...aro.org, helgaas@...nel.org,
        z.liuxinliang@...ilicon.com, linuxarm@...wei.com
Subject: Re: [PATCH 1/2] HISI LPC: Reference static MFD cells for ACPI
 support

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

> +	/* 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.

> +		cell = container_of(mfd_cell_ref, typeof(*cell),
> mfd_cell);

Why we can't iterate over inherited type of objects directly?

-- 
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Intel Finland Oy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ