lkml.org 
[lkml]   [2019]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 3/3] platform/x86: intel_pmc_core: Instantiate pmc_core device on legacy platforms
On Fri, Apr 5, 2019 at 11:36 PM Rajat Jain <rajatja@google.com> wrote:
>
> Add code to instantiate the pmc_core platform device and thus attach to
> the driver, if the ACPI device for the same ("INT33A1") is not present
> in a system where it should be. This was discussed here:
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1966991.html
>



> +#include <linux/acpi.h>
> +#include <linux/platform_device.h>
> +
> +#include <asm/cpu_device_id.h>
> +#include <asm/intel-family.h>
> +
> +static struct platform_device pmc_core_device = {
> + .name = "pmc_core",
> +};
> +

> +static int dummy;
> +/*
> + * INTEL_CPU_FAM6 macro won't take NULL for driver_data (uses &driver_data),
> + * thus provide a dummy driver_data.
> + */

You may use pmc_core_device instead, right?

> +static const struct x86_cpu_id intel_pmc_core_ids[] = {
> + INTEL_CPU_FAM6(SKYLAKE_MOBILE, dummy),
> + INTEL_CPU_FAM6(SKYLAKE_DESKTOP, dummy),
> + INTEL_CPU_FAM6(KABYLAKE_MOBILE, dummy),
> + INTEL_CPU_FAM6(KABYLAKE_DESKTOP, dummy),
> + INTEL_CPU_FAM6(CANNONLAKE_MOBILE, dummy),
> + INTEL_CPU_FAM6(ICELAKE_MOBILE, dummy),
> + {}
> +};
> +MODULE_DEVICE_TABLE(x86cpu, intel_pmc_core_ids);
> +
> +static int __init pmc_core_platform_init(void)
> +{
> + int ret;
> +
> + /* Skip creating the platform device if ACPI already has a device */
> + if (acpi_dev_present("INT33A1", NULL, -1) ||
> + !x86_match_cpu(intel_pmc_core_ids))
> + return -ENODEV;

Split it to one conditional per line.

> +
> + ret = platform_device_register(&pmc_core_device);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static void __exit pmc_core_platform_exit(void)
> +{

> + if (!acpi_dev_present("INT33A1", NULL, -1) &&
> + x86_match_cpu(intel_pmc_core_ids))

Redundant check.

> + platform_device_unregister(&pmc_core_device);
> +}

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2019-04-08 19:07    [W:0.124 / U:2.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site