From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nishanth Menon Subject: Re: [PATCH] PM / OPP: discard duplicate OPP additions Date: Wed, 14 May 2014 09:27:00 -0500 Message-ID: <53737D34.5040307@ti.com> References: <1399966890-22926-1-git-send-email-k.chander@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from bear.ext.ti.com ([192.94.94.41]:52050 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754857AbaENO1N (ORCPT ); Wed, 14 May 2014 10:27:13 -0400 In-Reply-To: Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Viresh Kumar , Chander Kashyap Cc: "linux-pm@vger.kernel.org" , lkml , "rjw@rjwysocki.net" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Chander Kashyap , Inderpal Singh On 05/14/2014 06:08 AM, Viresh Kumar wrote: > On 14 May 2014 15:01, Chander Kashyap wrote: >>> say we do at this point: >>> if (new_opp->rate == opp->rate) { >>> dev_err(dev, "%s: attempt to add duplicate OPP entry (rate=%ld)\n", >>> __func__, new_opp->rate) >>> kfree(new_opp); >>> return -EINVAL; >>> } >> >> Yes this is more cleaner. >> But instead of dev_err, we should use dev_warn and secondly > > Correct > >> return 0 rather than EINVAL, as there are independent users for this function > > Why? We should actually use EEXIST here instead of EINVAL though.. > Yep -EEXIST is the right return value here. As Viresh indicated, reporting back 0 when the requested operation actually was not performed is wrong. Caller is supposed to know when it makes an error - hiding it is not correct. -- Regards, Nishanth Menon