{"id":815256,"url":"http://patchwork.ozlabs.org/api/patches/815256/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170919021947.8971-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":"<20170919021947.8971-6-f.fainelli@gmail.com>","list_archive_url":null,"date":"2017-09-19T02:19:40","name":"[net-next,v2,05/12] net: dsa: b53: Use a macro to define I/O operations","commit_ref":null,"pull_url":null,"state":"superseded","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/20170919021947.8971-6-f.fainelli@gmail.com/mbox/","series":[{"id":3767,"url":"http://patchwork.ozlabs.org/api/series/3767/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3767","date":"2017-09-19T02:19:35","name":"net: dsa: b53/bcm_sf2 cleanups","version":2,"mbox":"http://patchwork.ozlabs.org/series/3767/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815256/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815256/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=\"t69Y22Y4\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xx6F32Dw9z9s4s\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 12:26:15 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751365AbdISC0N (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 22:26:13 -0400","from mail-wr0-f194.google.com ([209.85.128.194]:38008 \"EHLO\n\tmail-wr0-f194.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751100AbdISC0J (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 22:26:09 -0400","by mail-wr0-f194.google.com with SMTP id p37so1359911wrb.5\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 19:26:09 -0700 (PDT)","from fainelli-desktop.broadcom.com ([192.19.255.250])\n\tby smtp.gmail.com with ESMTPSA id\n\tq19sm9332458wrb.17.2017.09.18.19.20.04\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Sep 2017 19:20:06 -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=JgS/xJt98FgFM1GWSfQnG1BGoYs/St9vYwbElU7aG6w=;\n\tb=t69Y22Y4EnTCGE4ChzDrFPsmN4zRlKFIDR0CS+db5qHJwYYsidpgWK5nD58551J/M6\n\tUONX8TcE7Q+APijQ2mDTjzrBUTrVUssA9NP8VbSYF0auttmANrw8OfkN2S7KVoG+pc+f\n\tXqu3OQQdVZbDk4IpyzQ0nTrUGuydblgfBTgMmFlkx0MYpWprGEngVG1Qhfs+eocTneug\n\tewZUseTfOA5ssFWwhv++izadZLDvpwp+rIULVse5L4YAyhLgilqMfVeuNrhwx8Zkklv6\n\tYOKACO+pN+Z+GNxZpoMHm9w1UVobUWEbMxrPJa2Y2W0aTnL8GyvTcQNqsvvd8ES2LR2G\n\tKRJQ==","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=JgS/xJt98FgFM1GWSfQnG1BGoYs/St9vYwbElU7aG6w=;\n\tb=a3G0Hput9gihNocwSF8DWc6SKbJybrzMm+VKwuznf3gapz0BC57hrj/LdOiJTXruE1\n\tSByA4RyU7lGYzBnvxz5oH3NN4B2ePc+i4TnYtX+bZnkfboT7MgQLdYhCj3pLP8s+x1GT\n\t0nRS2sADRKjZeMQiCxbm4WB9C5vqaiS7dMjaBQ0pd9fa2N4iuQeDIOJhU2I0nfUZTHUg\n\tjKC+EVtZR4yDsvHXAL0LsXijBn4mxE1ISshuP6/AG1dQm1C3VNRwL0gBCYF74lDKdIra\n\tz1+hXc4BOvVK28iigeFPBZiQxFFnOf8NwAAKpJdhFHB+luR1s6kW9TryKNTBAAj4SZwP\n\t8ByQ==","X-Gm-Message-State":"AHPjjUjLDUrq6MQt710LLol1r5msRobeMSrxWzr2Hil3cKs5SmwJkSBP\n\ty8Ukq2ysd+woYjF+h38=","X-Google-Smtp-Source":"ADKCNb5b08oOPd696KFnTxcDoj2NOsuVRjsB5hqKQOc+ZDaJEzVyQ+YtU/tVmN/dDcJQ+M2oObXQag==","X-Received":"by 10.223.176.133 with SMTP id i5mr31352644wra.17.1505787607076; \n\tMon, 18 Sep 2017 19:20:07 -0700 (PDT)","From":"Florian Fainelli <f.fainelli@gmail.com>","To":"netdev@vger.kernel.org","Cc":"andrew@lunn.ch, vivien.didelot@savoirfairelinux.com,\n\tdavem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>","Subject":"[PATCH net-next v2 05/12] net: dsa: b53: Use a macro to define I/O\n\toperations","Date":"Mon, 18 Sep 2017 19:19:40 -0700","Message-Id":"<20170919021947.8971-6-f.fainelli@gmail.com>","X-Mailer":"git-send-email 2.9.3","In-Reply-To":"<20170919021947.8971-1-f.fainelli@gmail.com>","References":"<20170919021947.8971-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,\nrelease mutex, define a macro: b53_build_op() which takes the type\n(read|write), I/O size, and value (scalar or pointer). This helps with\nfixing bugs that could exist (e.g: missing barrier, lock etc.).\n\nReviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\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","v2","05/12"]}