public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PM-WIP-OPP] [PATCH 2/2]: Change return value from ERR_PTR(..) to NULL in opp layer
Date: Fri, 15 Jan 2010 20:54:28 -0600	[thread overview]
Message-ID: <4B512A64.8060807@ti.com> (raw)
In-Reply-To: <B85A65D85D7EB246BE421B3FB0FBB59301E196B370@dbde02.ent.ti.com>

Dasgupta, Romit had written, on 01/15/2010 08:36 PM, the following:
>>> Returning NULL pointer from the OPP APIs instead of ERR_PTR where
>>> return struct omap_opp *. This is because there is no inherent value in
>>> returning ERR_PTR from the opp layer. Returning NULL serves the purpose.
> 
>> NAK.
> 
>> Using ERR_PTR allows returning different types of error conditions,
>> and is common practice across the kernel.
> Yes, it is true that it is a common practice but in case of the OPP layer I did not 
> see any purpose. The caller of the APIs returning struct omap_opp * can just
> check for NULL value for failure.
My initial intention of introducing ERR_PTR had the objective of being 
flexible:
I could not predict how each function would develop into - e.g. lists 
etc. They may prefer to return error values which could be independently 
handled. allow future flexibility. let me illustrate it - now that we 
are aligned that we are moving to enums:
The caller does not have an idea if mpu_opps was initialized or not.

opp_find_freq_exact can return: (examples ofcourse)
   -EDATA to say that the domain requested was not initialized
or
   -EAGAIN once we introduce locks to say that it is locked 
(non-blocking implementation)
or
   -ERANGE to say that the caller is asking for a frequency beyond the 
supported range.

Another example: opp_enable can now return -EEXIST to say that the the 
opp was already enabled etc..

The benefit I definitely see is that with an previously placed single 
pr_err of the return value by the caller, I can remotely debug an issue 
in code instead of having the developer to add printks/use lauterbach to 
debug.

ok, I might not have selected the best of return values, but I hope the 
idea is clear. NAK from myside too.

Regards,
Nishanth Menon

      reply	other threads:[~2010-01-16  2:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-15 11:03 [PM-WIP-OPP] [PATCH 2/2]: Change return value from ERR_PTR(..) to NULL in opp layer Romit Dasgupta
2010-01-15 18:12 ` Kevin Hilman
2010-01-16  2:36   ` Dasgupta, Romit
2010-01-16  2:54     ` Nishanth Menon [this message]

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=4B512A64.8060807@ti.com \
    --to=nm@ti.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox