Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1370626 > unrolled thread
| Started by | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| First post | 2016-04-04 15:50 +0200 |
| Last post | 2016-04-04 16:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [RFC PATCH 4/4] pinctrl: Parse GpioInt/GpioIo resources Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-04-04 15:50 +0200
RE: [RFC PATCH 4/4] pinctrl: Parse GpioInt/GpioIo resources "Tirdea, Irina" <irina.tirdea@intel.com> - 2016-04-04 16:10 +0200
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2016-04-04 15:50 +0200 |
| Subject | Re: [RFC PATCH 4/4] pinctrl: Parse GpioInt/GpioIo resources |
| Message-ID | <rkd3b-3J0-1@gated-at.bofh.it> |
On Thu, Mar 31, 2016 at 02:44:45PM +0300, Irina Tirdea wrote:
> +static int acpi_parse_gpio_res(struct pinctrl *p,
> + struct pinctrl_map **map,
> + unsigned *num_maps,
> + struct pinctrl_dev ***pctldevs)
> +{
> + struct acpi_gpio_lookup lookup;
> + struct list_head res_list;
> + struct acpi_device *adev;
> + unsigned int index;
> + int ret;
> +
> + adev = ACPI_COMPANION(p->dev);
> +
> + *map = NULL;
> + *num_maps = 0;
> + memset(&lookup, 0, sizeof(lookup));
> +
> + /* Parse all GpioInt/GpioIo resources in _CRS and extract pin conf */
> + for (index = 0; ; index++) {
> + lookup.index = index;
> + lookup.n = 0;
> + lookup.found = false;
> +
> + INIT_LIST_HEAD(&res_list);
> + ret = acpi_dev_get_resources(adev, &res_list, acpi_gpio_to_map,
> + &lookup);
> + if (ret < 0)
> + goto exit_free;
> + acpi_dev_free_resource_list(&res_list);
> + if (!lookup.found)
> + break;
> + }
> +
> + *map = lookup.map;
> + *num_maps = lookup.num_maps;
> + *pctldevs = lookup.pctldevs;
This function has quite many stars in arguments and in the function
body. In particular pctldevs has three stars!
I wonder if this could be written in such way that avoids that. Like
create a structure holding the map information and pass that to the
function instead.
Other parts of the patch look good to me.
[toc] | [next] | [standalone]
| From | "Tirdea, Irina" <irina.tirdea@intel.com> |
|---|---|
| Date | 2016-04-04 16:10 +0200 |
| Message-ID | <rkdmz-47v-27@gated-at.bofh.it> |
| In reply to | #1370626 |
> -----Original Message-----
> From: Mika Westerberg [mailto:mika.westerberg@linux.intel.com]
> Sent: 04 April, 2016 16:48
> To: Tirdea, Irina
> Cc: Rafael J. Wysocki; Len Brown; Linus Walleij; linux-gpio@vger.kernel.org; linux-acpi@vger.kernel.org; Rob Herring; Heikki Krogerus;
> Andy Shevchenko; Purdila, Octavian; Ciocan, Cristina; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [RFC PATCH 4/4] pinctrl: Parse GpioInt/GpioIo resources
>
> On Thu, Mar 31, 2016 at 02:44:45PM +0300, Irina Tirdea wrote:
> > +static int acpi_parse_gpio_res(struct pinctrl *p,
> > + struct pinctrl_map **map,
> > + unsigned *num_maps,
> > + struct pinctrl_dev ***pctldevs)
> > +{
> > + struct acpi_gpio_lookup lookup;
> > + struct list_head res_list;
> > + struct acpi_device *adev;
> > + unsigned int index;
> > + int ret;
> > +
> > + adev = ACPI_COMPANION(p->dev);
> > +
> > + *map = NULL;
> > + *num_maps = 0;
> > + memset(&lookup, 0, sizeof(lookup));
> > +
> > + /* Parse all GpioInt/GpioIo resources in _CRS and extract pin conf */
> > + for (index = 0; ; index++) {
> > + lookup.index = index;
> > + lookup.n = 0;
> > + lookup.found = false;
> > +
> > + INIT_LIST_HEAD(&res_list);
> > + ret = acpi_dev_get_resources(adev, &res_list, acpi_gpio_to_map,
> > + &lookup);
> > + if (ret < 0)
> > + goto exit_free;
> > + acpi_dev_free_resource_list(&res_list);
> > + if (!lookup.found)
> > + break;
> > + }
> > +
> > + *map = lookup.map;
> > + *num_maps = lookup.num_maps;
> > + *pctldevs = lookup.pctldevs;
>
> This function has quite many stars in arguments and in the function
> body. In particular pctldevs has three stars!
>
> I wonder if this could be written in such way that avoids that. Like
> create a structure holding the map information and pass that to the
> function instead.
>
Yes, that would make the code more clear. I will rewrite it using a structure.
> Other parts of the patch look good to me.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web