Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3273910imm; Mon, 8 Oct 2018 00:48:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV61HRxoTfCNdDRVAojqU1s7NzIkzvs6mP5yo4X9DfvxNydBp3ik1EEKCVzL+6Coz7CUff21x X-Received: by 2002:a17:902:850b:: with SMTP id bj11-v6mr23195479plb.107.1538984936131; Mon, 08 Oct 2018 00:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538984936; cv=none; d=google.com; s=arc-20160816; b=UW+gpXRQleGw5TVM/SssVaj3uSbck+x5eXE1PbIICGuhbOUxRKK3K7XZxyYgPc2ejW ospl+1FrJB6++m4ZzMTZrlv5AYZ6rkcO2bZ5xOHPk3zYP1qmOigYzZ8jOBHrd7czbYIq CzMbvOWrdL1piGfo+gJBPSQheQVE0NUhxP/n2/oLupn8KVNCTdS3p7sHOTQYJYI+UI3H d/wJgPEHtumuEJxFZ0l6J1AydXpel04K+tDQQ8H93ehtU7BN57zVT13YnDt6udM2zUC5 /B6MxD2JvPCx1qfZxqnz39E3XJe+IVhZcSVX8TfixMuFEddrh9SaqVOTtYGbto3FZ2kI /dSw== 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=R+fbkg4RYlWwA7q6mZviQK+ZcL71dEBssjoOMdAqWBc=; b=TAVwN4vPgpWFz/fXrRvbx0D0KqELAvYCI34tVIpPFw0lc+WmcBzI4Dkkx5mWPn57kE 4UjHm5UOp5HrH0lksMC59O7qk+h3wqsysFWZRKjP0d0LTSrSTyi1/+4EkPxU7LtIuO0W dDwQMLTiWrSKgcQ7XqNkiX7GDg3R2x0QgrzBfzjf68PHRNPgvDdfzIa/xCmeCs0CevEW zuWQOzy3HYInCy0jwA4bvaq2gYp1y26l2Mr/yBSljQNNbs+m2EL9+0U9a0Abi53ogto6 pw2+roYnAs/HyBw1h1UcddIuGhShpIbr89QbATQjlJMdQ/sfZnrhh9QZXD/2qQWaZsfc 1uvw== 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 q137-v6si21275820pfq.178.2018.10.08.00.48.40; Mon, 08 Oct 2018 00:48:56 -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 S1727353AbeJHO6w (ORCPT + 99 others); Mon, 8 Oct 2018 10:58:52 -0400 Received: from inva021.nxp.com ([92.121.34.21]:46890 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbeJHO6w (ORCPT ); Mon, 8 Oct 2018 10:58:52 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 093B02000EE; Mon, 8 Oct 2018 09:48:27 +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 A1DAF2001F5; Mon, 8 Oct 2018 09:48: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 8892B40318; Mon, 8 Oct 2018 15:48:16 +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: [v3, 6/6] net: dpaa2: fix and improve dpaa2-ptp driver Date: Mon, 8 Oct 2018 15:44:30 +0800 Message-Id: <20181008074430.34379-6-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181008074430.34379-1-yangbo.lu@nxp.com> References: <20181008074430.34379-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. Changes for v3: - None. --- 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