From patchwork Mon Dec 7 21:40:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 7791291 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 686C2BEEE1 for ; Mon, 7 Dec 2015 21:41:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 954282052F for ; Mon, 7 Dec 2015 21:41:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B490C204FB for ; Mon, 7 Dec 2015 21:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932111AbbLGVlC (ORCPT ); Mon, 7 Dec 2015 16:41:02 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:36786 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755984AbbLGVlB (ORCPT ); Mon, 7 Dec 2015 16:41:01 -0500 Received: by lbblt2 with SMTP id lt2so232654lbb.3 for ; Mon, 07 Dec 2015 13:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :in-reply-to:references:mime-version:content-transfer-encoding :content-type; bh=gspSsAPZkTzWkJRm2+z0hZalk1DBiKXdhZnI7MZ+FPY=; b=r2YBa/Mk4LpLLuLAU4kLA4BMBIN67dkv3nUjs32UNz2d+BfDQSAFjC1aaQbAzeucFK 4GGFYXEuiS/8oHSl/twIvPoeRbz2mntS4pKAGPIM1n8tFXRBFKuP5j3Nb3NEdP8P3rB3 jkjWk+1DQ+sAuOd3ItLva+Idu2RZ3dqAKYH/WiMsuhtBTqLMekd39nO+yHelAlrbHS6Y VsmecvkVbvt4GeIwwuwSmANtPGD2oAtNQlyAUQ0G+wZu6mSPiX/ZmQbBLK6vxm9F4eQ8 psQPsfjIfmcEn27NT/ZRrLsEi55DWbTlJEWO9hnghs2wT8OnsJo6ozaz0yqo6G0zb98E jjvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=gspSsAPZkTzWkJRm2+z0hZalk1DBiKXdhZnI7MZ+FPY=; b=VmTExJ4SR1rZqwnXwGLr7o0DkrLwDt6ctVDGOKPqMtU0ecvPpx/9x87NOHXZjnBQi9 5BZw2WuzllbGOFnNgNxp/8BRSfac+sty0HxsMnyrCT1thr4kqc20Jez7IIpbFywREUY2 Ha853MFd3ISB6z4ZaeWMhoziite5CMdC7PWDEFh1k9BBHzGfmfN6cRQQesk+WhCy+hlD CLa4ovY2At49ls2xIeh95l1bQjJwrJZX5wP7RvZHL6zwIPPiSijkwybpc8o1vu5JLPYh H0LtqFV3uOOSCFSmxs9NyfsYjJQ142z3tc4YCdXzYMwChR25Cwu5YKxJijCxffGpYFqT CHBg== X-Gm-Message-State: ALoCoQkyaBU0eBaoEHfUkznYoU1ZhFCxAUYfq+R06AtXOUZTTDrxStaqsIGckfEq47gDQ0KTDuFJ X-Received: by 10.112.172.130 with SMTP id bc2mr9927235lbc.132.1449524459720; Mon, 07 Dec 2015 13:40:59 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.81.16]) by smtp.gmail.com with ESMTPSA id k14sm5273955lfb.49.2015.12.07.13.40.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Dec 2015 13:40:59 -0800 (PST) From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH 2/3] sh_eth: factor out common code from MDIO bitbang methods Date: Tue, 08 Dec 2015 00:40:57 +0300 Message-ID: <2708108.aPmlclaWv5@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.10 (Linux/4.2.6-201.fc22.x86_64; KDE/4.14.14; x86_64; ; ) In-Reply-To: <1582774.FcjyuztLtc@wasted.cogentembedded.com> References: <1582774.FcjyuztLtc@wasted.cogentembedded.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sh_mm[cd]_ctrl() and sh_set_mdio() all look mostly the same -- factor out their common code and put it into sh_mdio_ctrl(). Signed-off-by: Sergei Shtylyov Acked-by: Simon Horman --- drivers/net/ethernet/renesas/sh_eth.c | 35 +++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -1033,32 +1033,29 @@ static int bb_read(void *addr, u32 msk) return (ioread32(addr) & msk) != 0; } -/* Data I/O pin control */ -static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) +static void sh_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set) { struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); if (bitbang->set_gate) bitbang->set_gate(bitbang->addr); - if (bit) - bb_set(bitbang->addr, PIR_MMD); + if (set) + bb_set(bitbang->addr, mask); else - bb_clr(bitbang->addr, PIR_MMD); + bb_clr(bitbang->addr, mask); +} + +/* Data I/O pin control */ +static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) +{ + sh_mdio_ctrl(ctrl, PIR_MMD, bit); } /* Set bit data*/ static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit) { - struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); - - if (bitbang->set_gate) - bitbang->set_gate(bitbang->addr); - - if (bit) - bb_set(bitbang->addr, PIR_MDO); - else - bb_clr(bitbang->addr, PIR_MDO); + sh_mdio_ctrl(ctrl, PIR_MDO, bit); } /* Get bit data*/ @@ -1075,15 +1072,7 @@ static int sh_get_mdio(struct mdiobb_ctr /* MDC pin control */ static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit) { - struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); - - if (bitbang->set_gate) - bitbang->set_gate(bitbang->addr); - - if (bit) - bb_set(bitbang->addr, PIR_MDC); - else - bb_clr(bitbang->addr, PIR_MDC); + sh_mdio_ctrl(ctrl, PIR_MDC, bit); } /* mdio bus control struct */