Received: by 10.192.165.148 with SMTP id m20csp4109295imm; Tue, 8 May 2018 03:08:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqfe2zzZA+y2TMq//X6gsZ24UYduSENpr47GdGPJUWz8udFNqK7N6UannQ88zsuLuDJzO3k X-Received: by 2002:a63:2a89:: with SMTP id q131-v6mr32060339pgq.379.1525774104534; Tue, 08 May 2018 03:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525774104; cv=none; d=google.com; s=arc-20160816; b=K8DECevrI1F590KeA6KlaTPVgSi17LOLT804CC0498F77TyUPWh+Nl8PVCmlpIqm8d JmiDT01dApGlrEgaaua1JQc8hIbV9Xx0QxUL8mS5bIpdzusr5sqnfQ0ginOklVdHmNob u9NyNSaRaoXjK74oa46BICxXeKG2VOky2wqXDtlC5IWPDrsSb20dyZ5jhhOpOOPFf1nZ 8MbApAoVhkHRGSEWfLWgMzCYKm7hXM3ipRbaPMXLmzI+R7PI++mg6mLns23hxiFantO+ okqWq/emCUcUsXIT3yt+sMw5nrTZ4nY3yDxfV0KsVJkOyBQfDjDdfvD605+whALhhMVN 1onA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0CjexkA+O1R/54oJNhvkVCalDyIU49X9S6UQ7m27mNY=; b=yoCPumfrtN03EU2s8v71TD5/ebvDR3J+HoPpoRLYpiwcY5U6tJjjf+b/tvK+TsCzMp YMVvLmsN5bOOoEv8EydnPyhgw355XNBqK31aKE6VEy1UNE4xv45ZnBi3O1qu7tcvtxs8 6wIDkI1+DOVdX2uObFvmNpt62OYxVs0fWOTL3ogAePMWtx3ohypcxMq3NrrKiGQ9WH9c Dtqfj1U+xqhEQA5d+PZhKwGtF/CD/c4ZAo32emFdyM8BmSMUr5Y9FjhuQnkoJuVKXEvc PT28VK7eQ4Ei2L98tgNZ4t5EBRsMjku0z7+7yMmqeU2nIRiq1gb5r1Lyg6/z5IiHKIIn B1nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7-v6si8085290pls.368.2018.05.08.03.08.10; Tue, 08 May 2018 03:08:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932468AbeEHKGE (ORCPT + 99 others); Tue, 8 May 2018 06:06:04 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:38987 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932200AbeEHKF5 (ORCPT ); Tue, 8 May 2018 06:05:57 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fFzVF-0001wb-Fc; Tue, 08 May 2018 12:05:49 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fFzVB-0004Fb-69; Tue, 08 May 2018 12:05:45 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Greg Kroah-Hartman , Jiri Slaby , Johan Hovold , Jacek Anaszewski , Pavel Machek Cc: linux-serial@vger.kernel.org, linux-leds@vger.kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, One Thousand Gnomes , Florian Fainelli , Mathieu Poirier , linux-kernel@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/3] can: simplify LED trigger handling Date: Tue, 8 May 2018 12:05:42 +0200 Message-Id: <20180508100543.12559-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508100543.12559-1-u.kleine-koenig@pengutronix.de> References: <20180508100543.12559-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new function led_trigger_register_format allows one to simplify LED trigger handling considerably. Signed-off-by: Uwe Kleine-König --- drivers/net/can/led.c | 30 +++++++----------------------- include/linux/can/dev.h | 3 --- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/net/can/led.c b/drivers/net/can/led.c index 2d7d1b0d20f9..111f9769e9da 100644 --- a/drivers/net/can/led.c +++ b/drivers/net/can/led.c @@ -81,19 +81,9 @@ void devm_can_led_init(struct net_device *netdev) return; } - snprintf(priv->tx_led_trig_name, sizeof(priv->tx_led_trig_name), - "%s-tx", netdev->name); - snprintf(priv->rx_led_trig_name, sizeof(priv->rx_led_trig_name), - "%s-rx", netdev->name); - snprintf(priv->rxtx_led_trig_name, sizeof(priv->rxtx_led_trig_name), - "%s-rxtx", netdev->name); - - led_trigger_register_simple(priv->tx_led_trig_name, - &priv->tx_led_trig); - led_trigger_register_simple(priv->rx_led_trig_name, - &priv->rx_led_trig); - led_trigger_register_simple(priv->rxtx_led_trig_name, - &priv->rxtx_led_trig); + led_trigger_register_format(&priv->tx_led_trig, "%s-tx", netdev->name); + led_trigger_register_format(&priv->rx_led_trig, "%s-rx", netdev->name); + led_trigger_register_format(&priv->rxtx_led_trig, "%s-rxtx", netdev->name); devres_add(&netdev->dev, res); } @@ -105,23 +95,17 @@ static int can_led_notifier(struct notifier_block *nb, unsigned long msg, { struct net_device *netdev = netdev_notifier_info_to_dev(ptr); struct can_priv *priv = safe_candev_priv(netdev); - char name[CAN_LED_NAME_SZ]; if (!priv) return NOTIFY_DONE; - if (!priv->tx_led_trig || !priv->rx_led_trig || !priv->rxtx_led_trig) - return NOTIFY_DONE; - if (msg == NETDEV_CHANGENAME) { - snprintf(name, sizeof(name), "%s-tx", netdev->name); - led_trigger_rename(priv->tx_led_trig, name); + led_trigger_rename(priv->tx_led_trig, "%s-tx", netdev->name); - snprintf(name, sizeof(name), "%s-rx", netdev->name); - led_trigger_rename(priv->rx_led_trig, name); + led_trigger_rename(priv->rx_led_trig, "%s-rx", netdev->name); - snprintf(name, sizeof(name), "%s-rxtx", netdev->name); - led_trigger_rename(priv->rxtx_led_trig, name); + led_trigger_rename(priv->rxtx_led_trig, + "%s-rxtx", netdev->name); } return NOTIFY_DONE; diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 055aaf5ed9af..ff358269aa9c 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -73,11 +73,8 @@ struct can_priv { #ifdef CONFIG_CAN_LEDS struct led_trigger *tx_led_trig; - char tx_led_trig_name[CAN_LED_NAME_SZ]; struct led_trigger *rx_led_trig; - char rx_led_trig_name[CAN_LED_NAME_SZ]; struct led_trigger *rxtx_led_trig; - char rxtx_led_trig_name[CAN_LED_NAME_SZ]; #endif }; -- 2.17.0