Re: [PATCH v3 3/7] misc: Add cros_ec_lpc driver for x86 devices

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

 



Hello Varka,

Thanks a lot for your feedback.

On 01/23/2015 04:57 AM, Varka Bhadram wrote:
> (...)
>> +static int cros_ec_lpc_probe(struct platform_device *pdev)
>> +{
>> +       struct device *dev = &pdev->dev;
>> +       struct cros_ec_device *ec_dev;
>> +       int err = -ENOTTY;
>> +
>> +       if (!request_region(EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE, MYNAME)) {
> 
> Why dont you use devres API for request_region()... Then maximum of
> your goto label regarding
> release region will gone...
>

Good point, I'll change that on next version.
 
>> +               dev_warn(dev, "couldn't reserve memmap region\n");
>> +               goto failed_memmap;
>> +       }
>> +
>> +       if ((inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID) != 'E') ||
>> +           (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1) != 'C')) {
>> +               dev_warn(dev, "EC ID not detected\n");
>> +               goto failed_ec_probe;
>> +       }
>> +
>> +       if (!request_region(EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION_SIZE,
>> +                           MYNAME)) {
> 
> same...
> 
>> +               dev_warn(dev, "couldn't reserve region0\n");
>> +               goto failed_region0;
>> +       }
>> +       if (!request_region(EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION_SIZE,
>> +                           MYNAME)) {
> 
> same ...
> 
>> +               dev_warn(dev, "couldn't reserve region1\n");
>> +               goto failed_region1;
>> +       }
>> +
>> +       ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);
>> +       if (!ec_dev) {
>> +               err = -ENOMEM;
>> +               goto failed_ec_dev;
>> +       }
>> +
>> +       platform_set_drvdata(pdev, ec_dev);
>> +       ec_dev->dev = dev;
>> +       ec_dev->ec_name = pdev->name;
>> +       ec_dev->phys_name = dev_name(dev);
>> +       ec_dev->parent = dev;
>> +       ec_dev->cmd_xfer = cros_ec_cmd_xfer_lpc;
>> +       ec_dev->cmd_readmem = cros_ec_lpc_readmem;
>> +
>> +       err = cros_ec_register(ec_dev);
>> +       if (err) {
>> +               dev_warn(dev, "couldn't register ec_dev\n");
>> +               goto failed_ec_dev;
>> +       }
>> +
>> +       return 0;
>> +
>> +failed_ec_dev:
>> +       release_region(EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION_SIZE);
>> +failed_region1:
>> +       release_region(EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION_SIZE);
>> +failed_region0:
>> +failed_ec_probe:
>> +       release_region(EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE);
> 
> All these goto labels will be gone if you use devres API..
> 

Yes, I'll wait a couple more days to see if I get more feedback and re-post.

Best regards,
Javier

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  Powered by Linux