{"id":815184,"url":"http://patchwork.ozlabs.org/api/patches/815184/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918214128.27896-6-f.fainelli@gmail.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170918214128.27896-6-f.fainelli@gmail.com>","list_archive_url":null,"date":"2017-09-18T21:41:21","name":"[net-next,05/12] net: dsa: b53: Use a macro to define I/O operations","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"2ff8c0681807492f4983cb70ed34220966f100a9","submitter":{"id":2800,"url":"http://patchwork.ozlabs.org/api/people/2800/?format=json","name":"Florian Fainelli","email":"f.fainelli@gmail.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170918214128.27896-6-f.fainelli@gmail.com/mbox/","series":[{"id":3739,"url":"http://patchwork.ozlabs.org/api/series/3739/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3739","date":"2017-09-18T21:41:16","name":"net: dsa: b53/bcm_sf2 cleanups","version":1,"mbox":"http://patchwork.ozlabs.org/series/3739/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815184/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815184/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"jDjIKMJI\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwzx11Xzpz9ryv\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 07:41:57 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751517AbdIRVlz (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 17:41:55 -0400","from mail-wr0-f195.google.com ([209.85.128.195]:34533 \"EHLO\n\tmail-wr0-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751502AbdIRVlx (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 17:41:53 -0400","by mail-wr0-f195.google.com with SMTP id k20so1142110wre.1\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 14:41:52 -0700 (PDT)","from fainelli-desktop.broadcom.com ([192.19.255.250])\n\tby smtp.gmail.com with ESMTPSA id\n\te34sm9242761wre.15.2017.09.18.14.41.48\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Sep 2017 14:41:50 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=lYe5w7ypa/UDUPTSuKusxHROOsYmIGXZDsHQoKDT85s=;\n\tb=jDjIKMJIap7cBUdqtV1wasyMRy8UIvj6QB5IuaO5w+3rG7BGlPjg7UbKfs1jI9NJlj\n\tSzaYWtlK6CLbx4rqXljaJDr6ile5W1k9yPSlrzvZ/7mH/LCsE00UPkVGn8ZDMPwIcCfd\n\tXNwfb0dVfuSL1zGxI1uRTb0QNKM22pIYoqN0GNSThPvpps1JZ9vpzOA7bVMY0PaE/7by\n\t75UVtsepWHr1Nxt2YUfjg4umghNqviJgxhi2fXNeREZxt/NohAuGcJNTLDEQdNFc1gQJ\n\t6WbGwMw6RZEeweYT6mAQvwNpI4bCBbRaf9ACuT7ob9aB/C6m6LBeQt07YPDP8RngiMdS\n\tTvUA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=lYe5w7ypa/UDUPTSuKusxHROOsYmIGXZDsHQoKDT85s=;\n\tb=o/1+GhZx0f6UycDAQ5psixOaiEH8uTGPCZ+J0Vli0x8J/AOcYwC3xaMtZaOBGWtXsR\n\tuh9YYe3L/OKpTne5KebiIZTQr7a3XVQ4daeVJSU6mmD/VmepXFShCBKY/zPq/mQPSNZm\n\t37FXJYa7yqSXm7C5IUi8By8xtPgxXVxM/mecDNrgklyjFu4Y6clLvnY8o5PYtl0WvDsB\n\txQoG+7qDpANbQpiKjkIdM4zaY2a4jMl4Pxlb94QglP+uB4rPCsNiILiyTG5YjIzc2O27\n\tcO1epeBVH4/czODJz7NXkisyhQcHfV3BO+Tk3hMYY55MoLiVCuPdECpAvCNqGsLToAnG\n\th+sA==","X-Gm-Message-State":"AHPjjUgtBSO/B7Nya2afV78b7T4PcIN8u8wdhKIwSPRTU/ehN8/S32Hp\n\tFQ+AESzx4jZG3HhIeKI=","X-Google-Smtp-Source":"ADKCNb7pFBWIw059ObsIJhIJezUK+dIaRs3BW6PO/HzMTemf0DIG5r8Z210O8DBXUXAwl2H634rR6g==","X-Received":"by 10.223.141.235 with SMTP id\n\to98mr27577100wrb.242.1505770911680; \n\tMon, 18 Sep 2017 14:41:51 -0700 (PDT)","From":"Florian Fainelli <f.fainelli@gmail.com>","To":"netdev@vger.kernel.org","Cc":"davem@davemloft.net, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com,\n\tFlorian Fainelli <f.fainelli@gmail.com>","Subject":"[PATCH net-next 05/12] net: dsa: b53: Use a macro to define I/O\n\toperations","Date":"Mon, 18 Sep 2017 14:41:21 -0700","Message-Id":"<20170918214128.27896-6-f.fainelli@gmail.com>","X-Mailer":"git-send-email 2.9.3","In-Reply-To":"<20170918214128.27896-1-f.fainelli@gmail.com>","References":"<20170918214128.27896-1-f.fainelli@gmail.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Instead of repeating the same pattern: acquire mutex, read/write, release\nmutex, define a macro: b53_build_op() which takes the type (read|write), I/O\nsize, and value (scalar or pointer). This helps with fixing bugs that could\nexit (e.g: missing barrier, lock etc.).\n\nSigned-off-by: Florian Fainelli <f.fainelli@gmail.com>\n---\n drivers/net/dsa/b53/b53_priv.h | 133 +++++++----------------------------------\n 1 file changed, 22 insertions(+), 111 deletions(-)","diff":"diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h\nindex 7528b22aeb03..f1136619e0e4 100644\n--- a/drivers/net/dsa/b53/b53_priv.h\n+++ b/drivers/net/dsa/b53/b53_priv.h\n@@ -199,119 +199,30 @@ static inline void b53_switch_remove(struct b53_device *dev)\n \tdsa_unregister_switch(dev->ds);\n }\n \n-static inline int b53_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->read8(dev, page, reg, val);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->read16(dev, page, reg, val);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->read32(dev, page, reg, val);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->read48(dev, page, reg, val);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n+#define b53_build_op(type, op_size, val_type)\t\\\n+static inline int b53_##type##op_size(struct b53_device *dev, u8 page,\t\t\\\n+\t\t\t\t      u8 reg, val_type val)\t\t\t\\\n+{\t\t\t\t\t\t\t\t\t\t\\\n+\tint ret;\t\t\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\t\\\n+\tmutex_lock(&dev->reg_mutex);\t\t\t\t\t\t\\\n+\tret = dev->ops->type##op_size(dev, page, reg, val);\t\t\t\\\n+\tmutex_unlock(&dev->reg_mutex);\t\t\t\t\t\t\\\n+\t\t\t\t\t\t\t\t\t\t\\\n+\treturn ret;\t\t\t\t\t\t\t\t\\\n }\n \n-static inline int b53_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->read64(dev, page, reg, val);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_write8(struct b53_device *dev, u8 page, u8 reg, u8 value)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->write8(dev, page, reg, value);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_write16(struct b53_device *dev, u8 page, u8 reg,\n-\t\t\t      u16 value)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->write16(dev, page, reg, value);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_write32(struct b53_device *dev, u8 page, u8 reg,\n-\t\t\t      u32 value)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->write32(dev, page, reg, value);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_write48(struct b53_device *dev, u8 page, u8 reg,\n-\t\t\t      u64 value)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->write48(dev, page, reg, value);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n-\n-static inline int b53_write64(struct b53_device *dev, u8 page, u8 reg,\n-\t\t\t       u64 value)\n-{\n-\tint ret;\n-\n-\tmutex_lock(&dev->reg_mutex);\n-\tret = dev->ops->write64(dev, page, reg, value);\n-\tmutex_unlock(&dev->reg_mutex);\n-\n-\treturn ret;\n-}\n+b53_build_op(read, 8, u8 *);\n+b53_build_op(read, 16, u16 *);\n+b53_build_op(read, 32, u32 *);\n+b53_build_op(read, 48, u64 *);\n+b53_build_op(read, 64, u64 *);\n+\n+b53_build_op(write, 8, u8);\n+b53_build_op(write, 16, u16);\n+b53_build_op(write, 32, u32);\n+b53_build_op(write, 48, u64);\n+b53_build_op(write, 64, u64);\n \n struct b53_arl_entry {\n \tu8 port;\n","prefixes":["net-next","05/12"]}