From patchwork Wed Nov 2 07:57:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 9408733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58CC0601C2 for ; Wed, 2 Nov 2016 08:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47A2028F8B for ; Wed, 2 Nov 2016 08:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3953A29DD1; Wed, 2 Nov 2016 08:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E230E28F8B for ; Wed, 2 Nov 2016 08:01:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1qSF-0003Y6-0e; Wed, 02 Nov 2016 07:59:27 +0000 Received: from 8.mo173.mail-out.ovh.net ([46.105.46.122]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1qRX-0003IZ-HW for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2016 07:58:44 +0000 Received: from player687.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 0A98F10702 for ; Wed, 2 Nov 2016 08:58:23 +0100 (CET) Received: from hermes.kaod.org.com (LFbn-1-2234-107.w90-76.abo.wanadoo.fr [90.76.55.107]) (Authenticated sender: clg@kaod.org) by player687.ha.ovh.net (Postfix) with ESMTPSA id ABAAD2C007B; Wed, 2 Nov 2016 08:58:14 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Corey Minyard , openipmi-developer@lists.sourceforge.net, Joel Stanley Subject: [PATCH 3/3] ipmi/bt-bmc: add a sysfs file to configure a maximum response time Date: Wed, 2 Nov 2016 08:57:06 +0100 Message-Id: <1478073426-3714-4-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478073426-3714-1-git-send-email-clg@kaod.org> References: <1478073426-3714-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11285457717659995003 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelvddrkedvgdduudejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161102_005843_811005_A800B600 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Arnd Bergmann , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We could also use an ioctl for that purpose. sysfs seems a better approach. Signed-off-by: Cédric Le Goater --- drivers/char/ipmi/bt-bmc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c index e751e4a754b7..d7146f0e900e 100644 --- a/drivers/char/ipmi/bt-bmc.c +++ b/drivers/char/ipmi/bt-bmc.c @@ -84,6 +84,33 @@ struct bt_bmc { static atomic_t open_count = ATOMIC_INIT(0); +static ssize_t bt_bmc_show_response_time(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct bt_bmc *bt_bmc = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE - 1, "%d\n", bt_bmc->response_time); +} + +static ssize_t bt_bmc_set_response_time(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct bt_bmc *bt_bmc = dev_get_drvdata(dev); + unsigned long val; + int err; + + err = kstrtoul(buf, 0, &val); + if (err) + return err; + bt_bmc->response_time = val; + return count; +} + +static DEVICE_ATTR(response_time, 0644, + bt_bmc_show_response_time, bt_bmc_set_response_time); + static u8 bt_inb(struct bt_bmc *bt_bmc, int reg) { return ioread8(bt_bmc->base + reg); @@ -572,6 +599,10 @@ static int bt_bmc_probe(struct platform_device *pdev) bt_bmc_config_irq(bt_bmc, pdev); bt_bmc->response_time = BT_BMC_RESPONSE_TIME; + rc = device_create_file(&pdev->dev, &dev_attr_response_time); + if (rc) + dev_warn(&pdev->dev, "can't create response_time file\n"); + if (bt_bmc->irq) { dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);