From patchwork Thu Mar 21 08:23:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 2311461 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6E7EA40213 for ; Thu, 21 Mar 2013 08:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932306Ab3CUIYY (ORCPT ); Thu, 21 Mar 2013 04:24:24 -0400 Received: from mail-la0-f51.google.com ([209.85.215.51]:48668 "EHLO mail-la0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757920Ab3CUIXP (ORCPT ); Thu, 21 Mar 2013 04:23:15 -0400 Received: by mail-la0-f51.google.com with SMTP id fo13so4660169lab.10 for ; Thu, 21 Mar 2013 01:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=n/WJMjQeCioTqJrIvJqoQU+EoCMr55ql16BdUscM95g=; b=ex1ynMPJytQN24i25BKtSQNeaUbvnEcnANToOUEdL8GWaJyjCf/LW4LsRjfxzDKMTA 8qsyEHXQo/LEnQxKN632gGuhaY03ABuN8SQMSruOUYFov6+8UfIFvUiLoFk9OK58Sg/o OvTqjAWhfOwmPlLtP9JE4ZPM6WiWr1B+ObrV5skOOMNWCQqnLJ2upIFPGzDFGq1KKijz Rk3QzbUuT2iKhBHUtVbg2YfGGatekAIeLgDX2CpC+LK1lOiG6inaWue7zH8fpjQETaSc yg9Rp//BUgwTVPP4mQMSAfLQX/199jFJLCuzYjTlKKf13irlwiMZbi+EbKqo9kseMuPN 3hng== X-Received: by 10.152.116.45 with SMTP id jt13mr7234990lab.0.1363854193054; Thu, 21 Mar 2013 01:23:13 -0700 (PDT) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id iq6sm2099991lab.10.2013.03.21.01.23.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 21 Mar 2013 01:23:12 -0700 (PDT) Subject: [PATCH RFC 4/5] ptp: add stub function for ptp_clock_index() To: Michal Marek , Andrew Morton , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org From: Konstantin Khlebnikov Cc: Tejun Heo , Greg Kroah-Hartman , Richard Cochran Date: Thu, 21 Mar 2013 12:23:09 +0400 Message-ID: <20130321082309.21557.27838.stgit@zurg> In-Reply-To: <20130321082256.21557.68351.stgit@zurg> References: <20130321082256.21557.68351.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org After this patch function ptp_clock_index(struct ptp_clock *ptp) returns -1 if ptp is NULL or CONFIG_PTP_1588_CLOCK disabled. Signed-off-by: Konstantin Khlebnikov Cc: Richard Cochran --- drivers/net/ethernet/broadcom/tg3.c | 5 +---- drivers/net/ethernet/freescale/fec.c | 5 +---- drivers/net/ethernet/intel/e1000e/ethtool.c | 3 +-- drivers/net/ethernet/intel/igb/igb_ethtool.c | 5 +---- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +---- drivers/ptp/ptp_clock.c | 2 +- include/linux/ptp_clock_kernel.h | 12 ++++++++++++ 7 files changed, 18 insertions(+), 19 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 67d2663..9eafff7 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -5630,10 +5630,7 @@ static int tg3_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE; - if (tp->ptp_clock) - info->phc_index = ptp_clock_index(tp->ptp_clock); - else - info->phc_index = -1; + info->phc_index = ptp_clock_index(tp->ptp_clock); info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index e3f3937..4fde3c3 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -1240,10 +1240,7 @@ static int fec_enet_get_ts_info(struct net_device *ndev, SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE; - if (fep->ptp_clock) - info->phc_index = ptp_clock_index(fep->ptp_clock); - else - info->phc_index = -1; + info->phc_index = ptp_clock_index(fep->ptp_clock); info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index f91a8f3..b4f110c 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -2224,8 +2224,7 @@ static int e1000e_get_ts_info(struct net_device *netdev, (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | (1 << HWTSTAMP_FILTER_ALL)); - if (adapter->ptp_clock) - info->phc_index = ptp_clock_index(adapter->ptp_clock); + info->phc_index = ptp_clock_index(adapter->ptp_clock); return 0; } diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index a3830a8..924fd8d 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -2293,10 +2293,7 @@ static int igb_get_ts_info(struct net_device *dev, SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE; - if (adapter->ptp_clock) - info->phc_index = ptp_clock_index(adapter->ptp_clock); - else - info->phc_index = -1; + info->phc_index = ptp_clock_index(adapter->ptp_clock); info->tx_types = (1 << HWTSTAMP_TX_OFF) | diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index c3f1afd..71d4164 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -2723,10 +2723,7 @@ static int ixgbe_get_ts_info(struct net_device *dev, SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE; - if (adapter->ptp_clock) - info->phc_index = ptp_clock_index(adapter->ptp_clock); - else - info->phc_index = -1; + info->phc_index = ptp_clock_index(adapter->ptp_clock); info->tx_types = (1 << HWTSTAMP_TX_OFF) | diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index 79f4bce..f97d144 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -314,7 +314,7 @@ EXPORT_SYMBOL(ptp_clock_event); int ptp_clock_index(struct ptp_clock *ptp) { - return ptp->index; + return ptp ? ptp->index : -1; } EXPORT_SYMBOL(ptp_clock_index); diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h index 38a9935..4788943 100644 --- a/include/linux/ptp_clock_kernel.h +++ b/include/linux/ptp_clock_kernel.h @@ -148,12 +148,24 @@ struct ptp_clock_event { extern void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event); +#if IS_ENABLED(CONFIG_PTP_1588_CLOCK) + /** * ptp_clock_index() - obtain the device index of a PTP clock + * returns -1 if @ptp is NULL * * @ptp: The clock obtained from ptp_clock_register(). */ extern int ptp_clock_index(struct ptp_clock *ptp); +#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ + +static inline int ptp_clock_index(struct ptp_clock *ptp) +{ + return -1; +} + +#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ + #endif