Re: [PATCH RFT] platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2016-09-27 7:21 GMT+08:00 Li, Aubrey <aubrey.li@xxxxxxxxxxxxxxx>:
> On 2016/9/24 11:54, Axel Lin wrote:
>> Use platform_device_register_full() instead of open-coded.
>>
>> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
>> ---
>>  drivers/platform/x86/intel_pmc_ipc.c | 110 +++++++++++------------------------
>>  1 file changed, 33 insertions(+), 77 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
>> index b86e1bc..665a9a1 100644
>> --- a/drivers/platform/x86/intel_pmc_ipc.c
>> +++ b/drivers/platform/x86/intel_pmc_ipc.c
>> @@ -522,48 +522,36 @@ static struct resource telemetry_res[] = {
>>  static int ipc_create_punit_device(void)
>>  {
>>       struct platform_device *pdev;
>> -     int ret;
>> -
>> -     pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1);
>> -     if (!pdev) {
>> -             dev_err(ipcdev.dev, "Failed to alloc punit platform device\n");
>> -             return -ENOMEM;
>> -     }
>> -
>> -     pdev->dev.parent = ipcdev.dev;
>> -     ret = platform_device_add_resources(pdev, punit_res_array,
>> -                                         ARRAY_SIZE(punit_res_array));
>> -     if (ret) {
>> -             dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
>> -             goto err;
>> -     }
>> +     const struct platform_device_info pdevinfo = {
>> +             .parent = ipcdev.dev,
>> +             .name = PUNIT_DEVICE_NAME,
>> +             .id = -1,
>> +             .res = punit_res_array,
>> +             .num_res = ARRAY_SIZE(punit_res_array),
>> +             };
>> +
>
> Is it better to move the structure out of the routine?

Either is fine.

The struct platform_device_info is not very big as most of it's fields are
pointers. And this variable is for setup only so it's fine to use
local variable,
we don't need it once the function is done.
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux