From patchwork Wed Nov 30 03:08:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tnhuynh@apm.com X-Patchwork-Id: 9453505 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 6F29260235 for ; Wed, 30 Nov 2016 03:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47EF41FF60 for ; Wed, 30 Nov 2016 03:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B247282EC; Wed, 30 Nov 2016 03:09:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 BC1691FF60 for ; Wed, 30 Nov 2016 03:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755240AbcK3DJ0 (ORCPT ); Tue, 29 Nov 2016 22:09:26 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:35273 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754994AbcK3DJZ (ORCPT ); Tue, 29 Nov 2016 22:09:25 -0500 Received: by mail-pg0-f51.google.com with SMTP id p66so76565731pga.2 for ; Tue, 29 Nov 2016 19:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=cpE+iP1I4qOyrlEjswr+/jOQ4C2UAURa0w1C2jtyHe0=; b=rNsV1wXqLMUEGJ8dZD31IxnXutt82dJeNNVT1xqff9//CkV2gBKtpgSSEfujDiKOBp eL+Cz3IPBraGu0jo8U6ykOq0JJEqJHq6/FuYEprncLfhKGFo9pTTL48jJ287RSpAO0UQ h35VUJXtS3UnAnb34HCppPD4j4HoxqyI98v/k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cpE+iP1I4qOyrlEjswr+/jOQ4C2UAURa0w1C2jtyHe0=; b=eM1P4Qb9hPPyKd+MrD0cFajeAA/XoAPwsEn6LPyNU6gvxFisE/d9ApRG7KGQgw9LPc l8tc7nXJoXgVGO4+qhByXm6B1C0HuLMNObSasUlKhxuLtMIr6f7TqQcSbUiifGy8/6/x c5OtPNGODnTnJAgMh7lClJ7LbYU/8CqUuRit/F/o02PWIdOc6qi5BLT+u4CnDzur0Vtx rz8Ah9hLqyHrKku6mW0eNkIGKaRdnyJ0JzyNrbJbTArqOvQwGPlxcDeiU+YNg25u8jeU S3HQLT2iNzkSRYlP3/nSe0pKCpSNT8pTAwpnOQgpB6FzSvlsUHJVSD9s3Ah3KKpE9ft4 ay9w== X-Gm-Message-State: AKaTC02ChD/a9n0813NUFqYYj95Mtw+q7QZ+bt5LCRUOA/w1CD5oxxB1WFAQR8YOOOcezpzF X-Received: by 10.84.137.1 with SMTP id 1mr67355286plm.8.1480475322336; Tue, 29 Nov 2016 19:08:42 -0800 (PST) Received: from localhost.localdomain ([118.69.219.197]) by smtp.gmail.com with ESMTPSA id w125sm98106805pfb.8.2016.11.29.19.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 19:08:41 -0800 (PST) From: Tin Huynh To: Mika Westerberg , "Rafael J. Wysocki" , Richard Purdie , Jacek Anaszewski Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Loc Ho , Thang Nguyen , Phong Vo , patches@apm.com, Tin Huynh Subject: [PATCH V3] leds: pca955x: Add ACPI support for pca955x Date: Wed, 30 Nov 2016 10:08:31 +0700 Message-Id: <1480475311-14385-1-git-send-email-tnhuynh@apm.com> X-Mailer: git-send-email 1.7.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch enables ACPI support for leds-pca955x driver. Signed-off-by: Tin Huynh --- drivers/leds/leds-pca955x.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) Change from V2: -Correct coding conventions. Change from V1: -Remove CONFIG_ACPI. diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 840401a..b168ebe 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -40,6 +40,7 @@ * bits the chip supports. */ +#include #include #include #include @@ -100,6 +101,15 @@ struct pca955x_chipdef { }; MODULE_DEVICE_TABLE(i2c, pca955x_id); +static const struct acpi_device_id pca955x_acpi_ids[] = { + { .id = "PCA9550", .driver_data = pca9550 }, + { .id = "PCA9551", .driver_data = pca9551 }, + { .id = "PCA9552", .driver_data = pca9552 }, + { .id = "PCA9553", .driver_data = pca9553 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, pca955x_acpi_ids); + struct pca955x { struct mutex lock; struct pca955x_led *leds; @@ -250,7 +260,16 @@ static int pca955x_probe(struct i2c_client *client, struct led_platform_data *pdata; int i, err; - chip = &pca955x_chipdefs[id->driver_data]; + if (id) { + chip = &pca955x_chipdefs[id->driver_data]; + } else { + const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(pca955x_acpi_ids, &client->dev); + if (!acpi_id) + return -ENODEV; + chip = &pca955x_chipdefs[acpi_id->driver_data]; + } adapter = to_i2c_adapter(client->dev.parent); pdata = dev_get_platdata(&client->dev); @@ -358,6 +377,7 @@ static int pca955x_remove(struct i2c_client *client) static struct i2c_driver pca955x_driver = { .driver = { .name = "leds-pca955x", + .acpi_match_table = ACPI_PTR(pca955x_acpi_ids), }, .probe = pca955x_probe, .remove = pca955x_remove,