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]
Message-ID: <CAHp75VcB=gBa01UJLYVzApZ-2g745zX=mEtE9nJUyfzFdk3-pw@mail.gmail.com>
Date:   Mon, 8 Apr 2019 20:07:19 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Rajat Jain <rajatja@...gle.com>
Cc:     Rajneesh Bhardwaj <rajneesh.bhardwaj@...el.com>,
        Vishwanath Somayaji <vishwanath.somayaji@...el.com>,
        Darren Hart <dvhart@...radead.org>,
        Andy Shevchenko <andy@...radead.org>,
        Platform Driver <platform-driver-x86@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Wysocki@...gle.com, Rafael J <rafael.j.wysocki@...el.com>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        furquan@...gle.com, evgreen@...gle.com,
        Rajat Jain <rajatxjain@...il.com>
Subject: Re: [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@...gle.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ