Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbdHRM36 (ORCPT ); Fri, 18 Aug 2017 08:29:58 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34457 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbdHRM3z (ORCPT ); Fri, 18 Aug 2017 08:29:55 -0400 MIME-Version: 1.0 In-Reply-To: <0699a0a5114ae563e6d51ab9352de591779452a4.1501610760.git.sathyanarayanan.kuppuswamy@linux.intel.com> References: <0699a0a5114ae563e6d51ab9352de591779452a4.1501610760.git.sathyanarayanan.kuppuswamy@linux.intel.com> From: Andy Shevchenko Date: Fri, 18 Aug 2017 15:29:53 +0300 Message-ID: Subject: Re: [RFC v1 3/6] platform/x86: intel_pmc_ipc: Use MFD framework to create dependent devices To: Kuppuswamy Sathyanarayanan Cc: "x86@kernel.org" , Ingo Molnar , Zha Qipeng , "H. Peter Anvin" , "dvhart@infradead.org" , Thomas Gleixner , Andy Shevchenko , "linux-kernel@vger.kernel.org" , Platform Driver , Sathyanarayanan Kuppuswamy Natarajan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1998 Lines: 55 On Tue, Aug 1, 2017 at 9:13 PM, wrote: > Currently, we have lot of repetitive code in dependent device resource > allocation and device creation handling code. This logic can be improved if > we use MFD framework for dependent device creation. This patch adds this > support. > +static int ipc_create_pmc_devices(struct platform_device *pdev) > { > - int ret; > - > - /* If we have ACPI based watchdog use that instead */ > + u8 n = 0; > + struct mfd_cell *pmc_mfd_cells; > + > + pmc_mfd_cells = devm_kzalloc(&pdev->dev, > + (sizeof(*pmc_mfd_cells) * PMC_IPC_MAX_MFD_BLOCK), > + GFP_KERNEL); > + if (!pmc_mfd_cells) > + return -ENOMEM; > + > + /* Create PUNIT IPC MFD cell */ > + pmc_mfd_cells[n].name = PUNIT_DEVICE_NAME; > + pmc_mfd_cells[n].id = -1; > + pmc_mfd_cells[n].num_resources = ARRAY_SIZE(punit_ipc_resources); > + pmc_mfd_cells[n].resources = punit_ipc_resources; > + pmc_mfd_cells[n].ignore_resource_conflicts = 1; Please, use static variables instead of allocated on a heap. > + n++; > + > + /* If we have ACPI based watchdog use that instead, othewise create > + * a MFD cell for iTCO watchdog*/ > if (!acpi_has_watchdog()) { > + pmc_mfd_cells[n].name = TCO_DEVICE_NAME; > + pmc_mfd_cells[n].id = -1; > + pmc_mfd_cells[n].platform_data = &tco_info; > + pmc_mfd_cells[n].pdata_size = sizeof(tco_info); > + pmc_mfd_cells[n].num_resources = > + ARRAY_SIZE(watchdog_ipc_resources); > + pmc_mfd_cells[n].resources = watchdog_ipc_resources; > + pmc_mfd_cells[n].ignore_resource_conflicts = 1; > + n++; > } ...and here you do mfd_add_devices() instead of this stuff. Check how lpc_ich.c designed. -- With Best Regards, Andy Shevchenko