All of lore.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Varka Bhadram <varkabhadram@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>, Olof Johansson <olof@lixom.net>,
	Arnd Bergmann <arnd@arndb.de>,
	Doug Anderson <dianders@chromium.org>,
	Bill Richardson <wfrichar@chromium.org>,
	Simon Glass <sjg@google.com>,
	Gwendal Grignou <gwendal@google.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-samsung-soc@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/7] misc: Add cros_ec_lpc driver for x86 devices
Date: Fri, 23 Jan 2015 10:55:10 +0100	[thread overview]
Message-ID: <54C21A7E.1050304@collabora.co.uk> (raw)
In-Reply-To: <CAEUmHyYQ_oOE0Bd2Qi++DdJ2OMg=SuESx_pEJug4Ci=N0uYF0g@mail.gmail.com>

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

  reply	other threads:[~2015-01-23  9:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22 19:16 [PATCH v3 0/7] platform/chrome: Add user-space dev inferface support Javier Martinez Canillas
2015-01-22 19:16 ` [PATCH v3 1/7] mfd: cros_ec: Use fixed size arrays to transfer data with the EC Javier Martinez Canillas
2015-01-22 19:16 ` [PATCH v3 2/7] mfd: cros_ec: Add char dev and virtual dev pointers Javier Martinez Canillas
2015-01-22 19:16 ` [PATCH v3 3/7] misc: Add cros_ec_lpc driver for x86 devices Javier Martinez Canillas
2015-01-23  3:57   ` Varka Bhadram
2015-01-23  9:55     ` Javier Martinez Canillas [this message]
2015-01-22 19:16 ` [PATCH v3 4/7] platform/chrome: Add Chrome OS EC userspace device interface Javier Martinez Canillas
2015-01-22 19:16 ` [PATCH v3 5/7] mfd: cros_ec: Instantiate ChromeOS EC character device Javier Martinez Canillas
2015-01-23 10:26   ` Lee Jones
2015-01-22 19:16 ` [PATCH v3 6/7] platform/chrome: Create sysfs attributes for the ChromeOS EC Javier Martinez Canillas
2015-01-22 19:16 ` [PATCH v3 7/7] platform/chrome: Expose Chrome OS Lightbar to users Javier Martinez Canillas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54C21A7E.1050304@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=dianders@chromium.org \
    --cc=gwendal@google.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=sjg@google.com \
    --cc=varkabhadram@gmail.com \
    --cc=wfrichar@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.