Received: by 10.223.185.116 with SMTP id b49csp1634387wrg; Wed, 14 Feb 2018 22:06:19 -0800 (PST) X-Google-Smtp-Source: AH8x227ee1amiW/ES8UOsJ6QadWQhUi6z0jyJFvJCvng8hD5Qfmj/7npk+3L0MfVyeOVO+hRL/IY X-Received: by 10.98.143.1 with SMTP id n1mr1577085pfd.126.1518674779871; Wed, 14 Feb 2018 22:06:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518674779; cv=none; d=google.com; s=arc-20160816; b=JqQlW8CCS2mDTDU1AcPvwcK9FvP3J9iuYaRKwLy1R5+uNejvUrKD9eEXFl+mhQQ29f /jxFBhN/BNqu7chegFVOohKbfJwyRwGkP4eEPsDKQx9lpAerv2LQMy2+iDulFwErZSXU INVGzegw70cQ+C2AkeynPuPk3Gyo5fyFCCNbmgGNyqjSNiuhEceHkikmU7kMRY59qFVP lZu98ARj6mJw4sDj/imRH/BRJ+Z31Lu6c/2Y+yVod9wBn54yloTP/9rpbgJ7tjRljGGC 0iTS1uf5xt814mwB2RFstmbLXsDK+Yc6O3FeAo/knMP8EJZXurZIHkUCrE0L1OWmOTyA CHTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=L6GgX4MhDiTMoBasI2DK+t1A1skcyVdMIzGIWqvctc4=; b=a9NqUGc2lKEu6cIOFNqbcjAMJaxP123BeXhZJd2mtdwHWZwaOw+ocCA36i8EcsiB0Y mlU2t5/NRGFK7I8DFwOvX/rtqGE+Q5uTDGdu32LRNSGpzxhU5VThI6hRmIpPjMxBfq3b k40uKEBc5FL1R2xe9ibkHVMVca4V3tnnV1xKoTStXdZp5N8zdwxOgTgGfYX1mJDvp8It iqdI80ySCqXr5kzXWFPkza5JwuQ9f8DmmTZi6xgjrCQkRbUysmSdA4hwzKxha3xhRPZ1 N7pxTmECw6HFgbUNe2Enaj0jC/BaBv7Xat8uE9Ccqlmvr0dcIau6KzX0a/HofJPl3nDx EcHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Hw2ivUhY; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si4185175plr.660.2018.02.14.22.06.05; Wed, 14 Feb 2018 22:06:19 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b=Hw2ivUhY; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754934AbeBOGEm (ORCPT + 99 others); Thu, 15 Feb 2018 01:04:42 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:36970 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754884AbeBOGEf (ORCPT ); Thu, 15 Feb 2018 01:04:35 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1F63lUI014747; Thu, 15 Feb 2018 00:03:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518674627; bh=OBXZKIliAgsaWNJeyta+0RAjQKjI3h0sDExu1b13mEc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Hw2ivUhYcBcK+Wiu8zo6VA10FJY7Xlm8F+/4uagPyZ62NLiUybz3ZDjkIE3ULpheP QJxvheHvN8L5DqCNuiBaKAksuoKKHHTnGAHkzDTadn++lh4sZq7Q6PzByvNI/LOHta F04AB0HjkCn22vM/pf0Y5gheeAoCgzBNZ/PonI50= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1F63kvG009804; Thu, 15 Feb 2018 00:03:47 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 15 Feb 2018 00:03:46 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 15 Feb 2018 00:03:46 -0600 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1F62uf9020364; Thu, 15 Feb 2018 00:03:42 -0600 From: Keerthy To: , , , CC: , , , , , , , , , , , , Subject: [PATCH v11 09/10] pwm: pwm-omap-dmtimer: Adapt driver to utilize dmtimer pdata ops Date: Thu, 15 Feb 2018 11:31:50 +0530 Message-ID: <1518674511-26421-10-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1518674511-26421-1-git-send-email-j-keerthy@ti.com> References: <1518674511-26421-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adapt driver to utilize dmtimer pdata ops instead of pdata-quirks. Signed-off-by: Keerthy Acked-by: Neil Armstrong Reviewed-by: Claudiu Beznea --- drivers/pwm/pwm-omap-dmtimer.c | 68 ++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c index 5ad42f3..665da3c 100644 --- a/drivers/pwm/pwm-omap-dmtimer.c +++ b/drivers/pwm/pwm-omap-dmtimer.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ struct pwm_omap_dmtimer_chip { struct pwm_chip chip; struct mutex mutex; pwm_omap_dmtimer *dm_timer; - struct pwm_omap_dmtimer_pdata *pdata; + const struct omap_dm_timer_ops *pdata; struct platform_device *dm_timer_pdev; }; @@ -242,19 +243,35 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device_node *timer; + struct platform_device *timer_pdev; struct pwm_omap_dmtimer_chip *omap; - struct pwm_omap_dmtimer_pdata *pdata; + struct dmtimer_platform_data *timer_pdata; + const struct omap_dm_timer_ops *pdata; pwm_omap_dmtimer *dm_timer; u32 v; - int status; + int ret = 0; - pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - dev_err(&pdev->dev, "Missing dmtimer platform data\n"); - return -EINVAL; + timer = of_parse_phandle(np, "ti,timers", 0); + if (!timer) + return -ENODEV; + + timer_pdev = of_find_device_by_node(timer); + if (!timer_pdev) { + dev_err(&pdev->dev, "Unable to find Timer pdev\n"); + ret = -ENODEV; + goto put; } - if (!pdata->request_by_node || + timer_pdata = dev_get_platdata(&timer_pdev->dev); + if (!timer_pdata) { + dev_err(&pdev->dev, "dmtimer pdata structure NULL\n"); + ret = -EINVAL; + goto put; + } + + pdata = timer_pdata->timer_ops; + + if (!pdata || !pdata->request_by_node || !pdata->free || !pdata->enable || !pdata->disable || @@ -267,21 +284,26 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) !pdata->set_prescaler || !pdata->write_counter) { dev_err(&pdev->dev, "Incomplete dmtimer pdata structure\n"); - return -EINVAL; + ret = -EINVAL; + goto put; } - timer = of_parse_phandle(np, "ti,timers", 0); - if (!timer) - return -ENODEV; - if (!of_get_property(timer, "ti,timer-pwm", NULL)) { dev_err(&pdev->dev, "Missing ti,timer-pwm capability\n"); - return -ENODEV; + ret = -ENODEV; + goto put; } dm_timer = pdata->request_by_node(timer); - if (!dm_timer) - return -EPROBE_DEFER; + if (!dm_timer) { + ret = -EPROBE_DEFER; + goto put; + } + +put: + of_node_put(timer); + if (ret < 0) + return ret; omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL); if (!omap) { @@ -291,13 +313,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) omap->pdata = pdata; omap->dm_timer = dm_timer; - - omap->dm_timer_pdev = of_find_device_by_node(timer); - if (!omap->dm_timer_pdev) { - dev_err(&pdev->dev, "Unable to find timer pdev\n"); - omap->pdata->free(dm_timer); - return -EINVAL; - } + omap->dm_timer_pdev = timer_pdev; /* * Ensure that the timer is stopped before we allow PWM core to call @@ -322,11 +338,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) mutex_init(&omap->mutex); - status = pwmchip_add(&omap->chip); - if (status < 0) { + ret = pwmchip_add(&omap->chip); + if (ret < 0) { dev_err(&pdev->dev, "failed to register PWM\n"); omap->pdata->free(omap->dm_timer); - return status; + return ret; } platform_set_drvdata(pdev, omap); -- 1.9.1