From patchwork Sat Feb 24 22:45:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 129514 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2091385lja; Sat, 24 Feb 2018 14:48:07 -0800 (PST) X-Google-Smtp-Source: AG47ELttp9dsPoc18ptC7LMjJT76vKIEpT/6zFrjLVBBiG8jqLPuMRNJPi/yb7NAQhLTznPZJQqN X-Received: by 2002:a17:902:599b:: with SMTP id p27-v6mr1358851pli.289.1519512487061; Sat, 24 Feb 2018 14:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519512487; cv=none; d=google.com; s=arc-20160816; b=a9uZK46nQTmAnlw7+pqR/IH/UbO3X66HLuxZZv4bDg+43dXW5aWJsI5DbRrF1emv8Q V63LTkcGiiTtkKKvITCv3LBONtyPgvaHh8qRMxssAAVORsWSjOmD/BFYojTJh9Um3z/I 2jxxt0tzTBELMBQRBFfvoE5ZdIxfTcn9O0DesKu6I9tUmxEMvX8/Gu110m4mVnSdA13F I8Do7PoAEGhi94KSlyBeGfabFVajsoAVhM4oWkMPUIrC48m8ZDi3S1LbpWJHZH2iTGEX v0cyEGS3n+v/akbvadmDzkkxDrBgdV2W2GdP7faX4pEiI+HP9h5yayGzExkYRffzHGW9 sDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=4rd0FhNj8oVrCZh5qZgsogjhPTvKrtBBg099WOQu2gU=; b=g9Ud1n/RBwQH3sTHNVXNhFb4ldqLUfYIRiSLBYu0c43DqWDPBGx281M9iulh3V8q6n MBf70F40HR2m5elrcmFb6xuG9nk18UoY6fa9DJccnLydxWCj/CMfhw0fRmjJBXheqkmt cGpqWPgTFTIxzjWEtJKMqar3hYRrD+zy8n4cVmx8oVJvQO5oFUlqDBxjMk0PTfQwtXTG qpsBXxtza/YhMsUtkDlUfUOjpPydfwKG2MMY/SJIELTb0EzAITKd1HsHjSHyQGEJk3K0 NQ5RAKeuyMQ4xVH4MUt+wReMPyTjfnVP+crVQOlLg6nY8yJ9O0dvefzHJa0F4ZjHEX2e XIdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=biSAVjPz; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si3497021pgc.14.2018.02.24.14.48.06 for ; Sat, 24 Feb 2018 14:48:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=biSAVjPz; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751559AbeBXWsG (ORCPT ); Sat, 24 Feb 2018 17:48:06 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45809 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbeBXWsF (ORCPT ); Sat, 24 Feb 2018 17:48:05 -0500 Received: by mail-lf0-f65.google.com with SMTP id x196so17191808lfd.12 for ; Sat, 24 Feb 2018 14:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4rd0FhNj8oVrCZh5qZgsogjhPTvKrtBBg099WOQu2gU=; b=biSAVjPzsrUSgBxT9zkQ/AFhrJO3EC0i1ai6gaITFwXiuO/Eetjw+yFPpbHUKU2QNi WsS4O2hITuRDEezxvdAHS+n65iCFVPSTUPsFxvWiPEkDAlo6YPvfuQmfHz4hd1js00Xy XRqjDz3kI6C718CCiO0iCroFA/9XWp/GqEfJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4rd0FhNj8oVrCZh5qZgsogjhPTvKrtBBg099WOQu2gU=; b=Vh5A/hsbpgREuTLdXsVCj1NA+OV3Ray5/NwHPeOBKOQGf0O0Swr/l1z2sKr01Y+Egf nonrZxHx6lzDdsPn7IRvb30bd5um6jYSlRvLpOhOyIMs8gCFjJMRHr+Uxk983mHhbuiN +0+Po3oSG96ptIh8SOIcEDPEaNqlQylttuXZAJLoMvXlRzwkLsXADacNOCJv6rfZRVuh tTNK1r29P6vzdtTy6Odyjdo6ulOxxTGlAPdkRUxiZuDm0OfJ+rzqn3pPm1Tp7mrrzaUs riShIdPk2CIPvrK+k6LbFTDA8OozNeEeddjw3LiNgOielS7RfT4FxTz9QSYf0QzQ7ELl fG0A== X-Gm-Message-State: APf1xPCLFmSlHe3I1OShMVOKge2mPjceqMMggdhUHbwJvW5XfPZRa5hu wVEzzFPOKaxOSzpgm9KSCokatQ== X-Received: by 10.25.190.200 with SMTP id o191mr4473384lff.120.1519512483524; Sat, 24 Feb 2018 14:48:03 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id j63sm1163588lfi.22.2018.02.24.14.48.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Feb 2018 14:48:02 -0800 (PST) From: Linus Walleij To: Jacek Anaszewski , Pavel Machek , Tejun Heo , Bartlomiej Zolnierkiewicz Cc: linux-leds@vger.kernel.org, linux-ide@vger.kernel.org, Linus Walleij Subject: [PATCH] leds: Extends disk trigger for reads and writes Date: Sat, 24 Feb 2018 23:45:56 +0100 Message-Id: <20180224224556.24297-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org This adds two new disk triggers for triggering on reads and writes respectively, named "disk-read" and "disk-write". The use case comes from working on the D-Link DNS-313 NAS box. This features an RGB LED for disk activity. with these two triggers I can couple the green LED to read activity and the red LED to write activity, which gives the appropriate user feedback about what is happening on the disk. When tested it gave exactly the feedback desired. The in-kernel interface is simply changed to pass a bool indicating if the activity is write activity and update each trigger (and the composite "disk-activity" trigger) depending on what is passed in. This requires an ACK from the libata/IDE maintainers. Cc: Tejun Heo Cc: Bartlomiej Zolnierkiewicz Cc: Jacek Anaszewski Cc: Pavel Machek Signed-off-by: Linus Walleij --- drivers/ata/libata-core.c | 2 +- drivers/ide/ide-disk.c | 2 +- drivers/leds/trigger/ledtrig-disk.c | 12 +++++++++++- include/linux/leds.h | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) -- 2.14.3 Reviewed-by: Bartlomiej Zolnierkiewicz Acked-by: Pavel Machek Acked-by: David S. Miller diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3c09122bf038..fa75de6abbf1 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5219,7 +5219,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc) struct ata_port *ap = qc->ap; /* Trigger the LED (if available) */ - ledtrig_disk_activity(); + ledtrig_disk_activity(!!(qc->tf.flags & ATA_TFLAG_WRITE)); /* XXX: New EH and old EH use different mechanisms to * synchronize EH with regular execution path. diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 188d1b03715d..67bc72d78fbf 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -187,7 +187,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); BUG_ON(blk_rq_is_passthrough(rq)); - ledtrig_disk_activity(); + ledtrig_disk_activity(rq_data_dir(rq) == WRITE); pr_debug("%s: %sing: block=%llu, sectors=%u\n", drive->name, rq_data_dir(rq) == READ ? "read" : "writ", diff --git a/drivers/leds/trigger/ledtrig-disk.c b/drivers/leds/trigger/ledtrig-disk.c index cd525b4125eb..9816b0d60270 100644 --- a/drivers/leds/trigger/ledtrig-disk.c +++ b/drivers/leds/trigger/ledtrig-disk.c @@ -18,9 +18,11 @@ #define BLINK_DELAY 30 DEFINE_LED_TRIGGER(ledtrig_disk); +DEFINE_LED_TRIGGER(ledtrig_disk_read); +DEFINE_LED_TRIGGER(ledtrig_disk_write); DEFINE_LED_TRIGGER(ledtrig_ide); -void ledtrig_disk_activity(void) +void ledtrig_disk_activity(bool write) { unsigned long blink_delay = BLINK_DELAY; @@ -28,12 +30,20 @@ void ledtrig_disk_activity(void) &blink_delay, &blink_delay, 0); led_trigger_blink_oneshot(ledtrig_ide, &blink_delay, &blink_delay, 0); + if (write) + led_trigger_blink_oneshot(ledtrig_disk_write, + &blink_delay, &blink_delay, 0); + else + led_trigger_blink_oneshot(ledtrig_disk_read, + &blink_delay, &blink_delay, 0); } EXPORT_SYMBOL(ledtrig_disk_activity); static int __init ledtrig_disk_init(void) { led_trigger_register_simple("disk-activity", &ledtrig_disk); + led_trigger_register_simple("disk-read", &ledtrig_disk_read); + led_trigger_register_simple("disk-write", &ledtrig_disk_write); led_trigger_register_simple("ide-disk", &ledtrig_ide); return 0; diff --git a/include/linux/leds.h b/include/linux/leds.h index 5579c64c8fd6..b7e82550e655 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -346,9 +346,9 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev) /* Trigger specific functions */ #ifdef CONFIG_LEDS_TRIGGER_DISK -extern void ledtrig_disk_activity(void); +extern void ledtrig_disk_activity(bool write); #else -static inline void ledtrig_disk_activity(void) {} +static inline void ledtrig_disk_activity(bool write) {} #endif #ifdef CONFIG_LEDS_TRIGGER_MTD