Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754173AbbHGO6m (ORCPT ); Fri, 7 Aug 2015 10:58:42 -0400 Received: from 7of9.schinagl.nl ([88.159.158.68]:55209 "EHLO 7of9.schinagl.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753743AbbHGO6k (ORCPT ); Fri, 7 Aug 2015 10:58:40 -0400 X-Greylist: delayed 533 seconds by postgrey-1.27 at vger.kernel.org; Fri, 07 Aug 2015 10:58:40 EDT From: Olliver Schinagl To: Thierry Reding Cc: Olliver Schinagl , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] pwm: core: cleanup pointer tests Date: Fri, 7 Aug 2015 16:49:36 +0200 Message-Id: <1438958976-1821-1-git-send-email-oliver+list@schinagl.nl> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1628 Lines: 54 From: Olliver Schinagl pwm_set_polarity() checks if there's ops and polarity function pointers. Most of these pointers are actually checked when a chip is added via pwm_add, except for set_polarity. This patch adds set_polarity to the list of functions to test on pwmchip_add_with_polarity(); and removes these checks from pwm_set_polarity. The pwm should be valid, as it was checked during pwmchip_add_with_polarity(). Signed-off-by: Olliver Schinagl --- drivers/pwm/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 3a7769f..66fd5fd 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -239,7 +239,8 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip, int ret; if (!chip || !chip->dev || !chip->ops || !chip->ops->config || - !chip->ops->enable || !chip->ops->disable || !chip->npwm) + !chip->ops->set_polarity || !chip->ops->enable || + !chip->ops->disable || !chip->npwm) return -EINVAL; mutex_lock(&pwm_lock); @@ -449,12 +450,9 @@ int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity) { int err; - if (!pwm || !pwm->chip->ops) + if (!pwm) return -EINVAL; - if (!pwm->chip->ops->set_polarity) - return -ENOSYS; - if (test_bit(PWMF_ENABLED, &pwm->flags)) return -EBUSY; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/