From patchwork Tue Aug 1 22:38:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9875637 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 925AA60390 for ; Tue, 1 Aug 2017 22:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F7411FF1E for ; Tue, 1 Aug 2017 22:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1184428749; Tue, 1 Aug 2017 22:38:45 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265D42873A for ; Tue, 1 Aug 2017 22:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751775AbdHAWiI (ORCPT ); Tue, 1 Aug 2017 18:38:08 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33653 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166AbdHAWiG (ORCPT ); Tue, 1 Aug 2017 18:38:06 -0400 Received: by mail-pf0-f193.google.com with SMTP id c65so3830793pfl.0; Tue, 01 Aug 2017 15:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+FBmwUckqaXPvmDoYn5reo8iSEun8vUUAI9wUD+ib9o=; b=nwqturrj9XwvwiVCYe1ZP+UH3lHJpfiTm0C1itF+M9aUG+bscA9dirGKPb+JPN+po4 c+9h8uWIVD1lwAeAhKhlwMb9LCo6tp4oa3fjm+HodnmVkOEEoKFoL2GRz1uoxsDPuzIW EfecjsquwxXg2QkcuB5jbuehxNpsangiXFEy/ElPCtiZvtwXZpLvYKnw1vjKLsCFGo6B ctDiiIgst+T2G+028wy+j0KZ/6+b+uYO/GRANvCJViArxec4oi4UxDWMIRCS2f7WXetR 1E3iWd7CA8B/fCSWOdioYEgyAOufbvGZMm9xnXzgOXZRzR99kmoKlVwQ1+T0E94E2GK3 /N7w== 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:in-reply-to :references; bh=+FBmwUckqaXPvmDoYn5reo8iSEun8vUUAI9wUD+ib9o=; b=F1bRYFyt1zL/phebEQP2t1y5aboBnXZk2gTSVgmvj28/wZf7QXMPcui68tWSgcKWYo hIlXRo0TIZkDDFiZB4+/IqOP4F9KXwhgbVTAs9tC0YdvwTiraIBwx3TDjPnQnRBoDym2 DBcb8JzBXHVlZQyLIkTQG8cuZ94Yz6upDkDXwlHVgZEbiwCu/FcW493ZjCmDUyFZgJdl AfkMqOb8FLefpP40XS/55YrQzBZlSTHZHMrvdTjjwkesHXHfdJXKM8cRhjUZT1um6T/k yz0YLm4mF1ZQZJonW3l6gUAE/HBof43/TI0DbDD5sGbapbEx28UoPg3Ob8zHnhRZKJSl L9sw== X-Gm-Message-State: AIVw113vkwLZdPdy5CcyIcMpJqaEu0NPTHF/95jqeTG9rwM+XQILtHS/ JDp7IrTxQzBwSQ== X-Received: by 10.84.139.195 with SMTP id 61mr1355386plr.445.1501627085379; Tue, 01 Aug 2017 15:38:05 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([100.98.112.61]) by smtp.gmail.com with ESMTPSA id p62sm43174414pfg.66.2017.08.01.15.38.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Aug 2017 15:38:04 -0700 (PDT) From: Dmitry Torokhov To: Jiri Kosina Cc: Benjamin Tissoires , Jason Gerecke , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] HID: input: optionally use device id in battery name Date: Tue, 1 Aug 2017 15:38:02 -0700 Message-Id: <20170801223802.30521-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog In-Reply-To: <20170801223802.30521-1-dmitry.torokhov@gmail.com> References: <20170801223802.30521-1-dmitry.torokhov@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Manufacturers do not always populate serial number in their devices, so let's fall back to device ID when forming the battery device name. As a result, batteries in devices without serial number will be named like this: hid-0018:2D1F:510E.0001-battery (as opposed to hid--battery for the first one, and failing to create batteries for the subsequent ones). Signed-off-by: Dmitry Torokhov --- drivers/hid/hid-input.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 2158ec766dd5..27d8442b017d 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -456,7 +456,9 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, if (!psy_desc) return -ENOMEM; - psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", dev->uniq); + psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", + strlen(dev->uniq) ? + dev->uniq : dev_name(&dev->dev)); if (!psy_desc->name) { error = -ENOMEM; goto err_free_mem;