From patchwork Tue May 10 05:27:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 67393 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1941685qge; Mon, 9 May 2016 22:27:35 -0700 (PDT) X-Received: by 10.66.136.41 with SMTP id px9mr55786780pab.80.1462858055566; Mon, 09 May 2016 22:27:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l74si620615pfb.194.2016.05.09.22.27.35; Mon, 09 May 2016 22:27:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbcEJF12 (ORCPT + 29 others); Tue, 10 May 2016 01:27:28 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:34946 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbcEJF10 (ORCPT ); Tue, 10 May 2016 01:27:26 -0400 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id u4A5QHtE023432; Tue, 10 May 2016 14:26:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com u4A5QHtE023432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1462857980; bh=sfmQNkpRsudkdCreEYXIIlAZAvGOs6zCG4JCq+bdvWI=; h=From:To:Cc:Subject:Date:From; b=aXDdA+nB+2AiyRyed50RweBNPvM4rmS6NGmsKB+cpUtw8I+sEbUjSRTm+djYLXPpn gORkquHvl93nAOOS1o9gY9+isuPLsZ+GvTpDwZgoZoJRnPohxReK98oqmQ3J5FdkCv PJgKQfCZABrXv0yB/olwfEHV6QcB/ogsyKNeweE1DG9yQY0Bkcw7lwslxRMypTQHof qy2sRBALI/4NX+nGrLLnYASlcDzTS+de+wivlKH85MWeWjgwYpt1NshkJ2twYHqhmU tPhlCZxiElyHV9zvKRW3uY3CFOUfyfIM3cPTcMHoJtEkzzE9CWyGnoFXUYgkuxk7Ed tr1FR2UmqwdQg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lee Jones Cc: Masahiro Yamada Subject: [PATCH] mfd: core: check existence of enable/disable callbacks Date: Tue, 10 May 2016 14:27:20 +0900 Message-Id: <1462858040-13174-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Child devices may not know if their MFD cells have enable/disable callbacks. Signed-off-by: Masahiro Yamada --- drivers/mfd/mfd-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 88bd1b1..95dbf3a 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -33,7 +33,7 @@ int mfd_cell_enable(struct platform_device *pdev) int err = 0; /* only call enable hook if the cell wasn't previously enabled */ - if (atomic_inc_return(cell->usage_count) == 1) + if (atomic_inc_return(cell->usage_count) == 1 && cell->enable) err = cell->enable(pdev); /* if the enable hook failed, decrement counter to allow retries */ @@ -50,7 +50,7 @@ int mfd_cell_disable(struct platform_device *pdev) int err = 0; /* only disable if no other clients are using it */ - if (atomic_dec_return(cell->usage_count) == 0) + if (atomic_dec_return(cell->usage_count) == 0 && cell->disable) err = cell->disable(pdev); /* if the disable hook failed, increment to allow retries */