Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1631441imm; Sat, 29 Sep 2018 00:30:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV62rUNepvX0ESvi+jMOjRtxZKexwCVJCE/vP67K5iq/3JTlyWh9GNYU67bGzF0Cohn/aU/vD X-Received: by 2002:aa7:8191:: with SMTP id g17-v6mr1974935pfi.71.1538206254609; Sat, 29 Sep 2018 00:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538206254; cv=none; d=google.com; s=arc-20160816; b=ihLAQ5s+Wq4NhjeRl7j5RSaKOG/ueyu4qp5p64HvV8HVIr1t1Jw19qQosX4WJeAUvk q+aYy5fhTyD10td+c9ViWTxYCj77K7m3hyH9ouudP5x0fK6CQ/kWXMsiInsumr43vGlp K5qe5c9npPg9983u8tslSi9G/vC4aSt/P0J88aGKpCm7487CptzZDaNhUjttfHWDanI2 NHK/QFLmJOHUAFNFKLranVJD0fjaJTtOdNACnwBs/rOkZ4DRffMXbnvQnN1CU9NjfAy8 0QOHKxl0twF8v3cKDVQa/gBnvY7FNLxwB1WbmH+tAke+vJLQQa1jwLXxZ8qHKXn/gWat V58A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MieHX6bM3bGRq1uKnjvFzQVS8mNMpBZyhyfQ9n/dLKM=; b=PPxto6eqNf5fiQ+XdAhsujmBy3zrvJfl1vTtLB2F8IbpHqz7eT3dbKSixy9o855siG Aj/9EKRvSLNUXNebmtGLcrWarWvQb1BwfMenau3kJ/tXLOqk/1P7w0VexACx/kw0GnBu DycC1U8RSexQRyF7okDOVkDiaCv35C2ws2dos9snAuIx/P/B9IvOAn1Nv01bC9Q86p/V YVlPD8oGYjlPWpqLYvw4ZUO7wGfJEX0xnA3B+zFnFPfMc1oS26OYllBR+SrkZoGXlG6T EzkZ3JpDAMgL591q0Tf1wjj+y5oV4DBUjoiw2o75a2YAhpfzdGwWommoEfjpceSXblUu cSCQ== ARC-Authentication-Results: i=1; mx.google.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si6960056pln.415.2018.09.29.00.30.40; Sat, 29 Sep 2018 00:30:54 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727706AbeI2N5w (ORCPT + 99 others); Sat, 29 Sep 2018 09:57:52 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59326 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727581AbeI2N5v (ORCPT ); Sat, 29 Sep 2018 09:57:51 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id DCAC6200079; Sat, 29 Sep 2018 09:30:26 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 15E42200086; Sat, 29 Sep 2018 09:30:22 +0200 (CEST) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E447F40324; Sat, 29 Sep 2018 15:30:15 +0800 (SGT) From: Yangbo Lu To: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, netdev@vger.kernel.org, Richard Cochran , "David S . Miller" , Ioana Radulescu , Greg Kroah-Hartman , Andrew Lunn Cc: Yangbo Lu Subject: [v2, 5/5] net: dpaa2: fix and improve dpaa2-ptp driver Date: Sat, 29 Sep 2018 15:26:45 +0800 Message-Id: <20180929072645.20027-5-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180929072645.20027-1-yangbo.lu@nxp.com> References: <20180929072645.20027-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is to fix and improve dpaa2-ptp driver in some places. - Fixed the return for some functions. - Replaced kzalloc with devm_kzalloc. - Removed dev_set_drvdata(dev, NULL). - Made ptp_dpaa2_caps const. Signed-off-by: Yangbo Lu --- Changes for v2: - Added this patch. --- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 25 ++++++++-------------- 1 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c index c73eef2..84b942b 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c @@ -46,7 +46,7 @@ static int ptp_dpaa2_adjfreq(struct ptp_clock_info *ptp, s32 ppb) mc_dev->mc_handle, tmr_add); if (err) dev_err(dev, "dprtc_set_freq_compensation err %d\n", err); - return 0; + return err; } static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, s64 delta) @@ -61,17 +61,15 @@ static int ptp_dpaa2_adjtime(struct ptp_clock_info *ptp, s64 delta) err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &now); if (err) { dev_err(dev, "dprtc_get_time err %d\n", err); - return 0; + return err; } now += delta; err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, now); - if (err) { + if (err) dev_err(dev, "dprtc_set_time err %d\n", err); - return 0; - } - return 0; + return err; } static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) @@ -87,12 +85,12 @@ static int ptp_dpaa2_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) err = dprtc_get_time(mc_dev->mc_io, 0, mc_dev->mc_handle, &ns); if (err) { dev_err(dev, "dprtc_get_time err %d\n", err); - return 0; + return err; } ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); ts->tv_nsec = remainder; - return 0; + return err; } static int ptp_dpaa2_settime(struct ptp_clock_info *ptp, @@ -111,10 +109,10 @@ static int ptp_dpaa2_settime(struct ptp_clock_info *ptp, err = dprtc_set_time(mc_dev->mc_io, 0, mc_dev->mc_handle, ns); if (err) dev_err(dev, "dprtc_set_time err %d\n", err); - return 0; + return err; } -static struct ptp_clock_info ptp_dpaa2_caps = { +static const struct ptp_clock_info ptp_dpaa2_caps = { .owner = THIS_MODULE, .name = "DPAA2 PTP Clock", .max_adj = 512000, @@ -136,7 +134,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) u32 tmr_add = 0; int err; - ptp_dpaa2 = kzalloc(sizeof(*ptp_dpaa2), GFP_KERNEL); + ptp_dpaa2 = devm_kzalloc(dev, sizeof(*ptp_dpaa2), GFP_KERNEL); if (!ptp_dpaa2) return -ENOMEM; @@ -182,8 +180,6 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) err_free_mcp: fsl_mc_portal_free(mc_dev->mc_io); err_exit: - kfree(ptp_dpaa2); - dev_set_drvdata(dev, NULL); return err; } @@ -198,9 +194,6 @@ static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev) dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); fsl_mc_portal_free(mc_dev->mc_io); - kfree(ptp_dpaa2); - dev_set_drvdata(dev, NULL); - return 0; } -- 1.7.1