Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3377379imm; Tue, 29 May 2018 06:18:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqEpomE5f2yKFVXURXS1tVdBJoGcqSP2FyePxzN6GjNZJNIEwQWoA4eSptElwrHLfA8hbxq X-Received: by 2002:a63:b54b:: with SMTP id u11-v6mr13845300pgo.365.1527599898667; Tue, 29 May 2018 06:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527599898; cv=none; d=google.com; s=arc-20160816; b=tvLtLwXRp6s9C2XLipJrrk8+Xq6mrStsIIvW0+UYlPCpHw6xhXOoSpWawOJjpFOjnH DT7C+AG1aVRpQt1dFpcUly/dz9alRdwekET2YwkoDmAsTBi5KstcdccxuLJOuO9pqLqs Mf3CpqJP7Zrf9dBBApTBqFLZD+1u2aIyQinBbyxlLLericruPP/86R7vfJgSCXqp79pv IODrlzBCSMcWjWXmiH000n59c1OhYNuEK1vlCRvkLiWd0GMfgY/Pozp0nWNSbz6QPI7I w5UGvi9AFF3WSzw8A40JN0h/kFJXy6OMsEuJikstun8cKAKZNrPTYKU+1vbq843g4BZQ vgsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9BNIpFb9eyHxnOZ1QLmuqWrGx9K63unXE/PWygDLncs=; b=LI/Zm/QpQzaRLcZp2lE9NLn3zBn4n1FNVrlTpTbIsik+9HXSgABGIFLZzgB2EB9YAr 5UD0A6TJL+ftMpq97aaOOVVDNIRwV3QlgcCMQl68dzukSL6qIDWGmgc7gJhiDgIf2rtP S7BqyVEDVWE3B16N/virtoW2A08J1XvyobdTndHrss4AMJxwvtiUbtGzl5oZIm9Y+Khh 0Ql9LNCAvKpCE/Ci9Mil7A6LW9JU1kHFk1YFbc3gw1WBRjqD56g5ES3JeNP1M25IKGFN px044nphDmzqVM/4FzWvy7x0VoK0XpIQQ9RN+8yzUANth+6DO95Vwxlsi9TMYvC/CveB f+Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=anE/8B+3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si24207700pgm.306.2018.05.29.06.18.04; Tue, 29 May 2018 06:18:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=anE/8B+3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934408AbeE2NPn (ORCPT + 99 others); Tue, 29 May 2018 09:15:43 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53417 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934505AbeE2NKn (ORCPT ); Tue, 29 May 2018 09:10:43 -0400 Received: by mail-wm0-f66.google.com with SMTP id a67-v6so40258074wmf.3; Tue, 29 May 2018 06:10:42 -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=9BNIpFb9eyHxnOZ1QLmuqWrGx9K63unXE/PWygDLncs=; b=anE/8B+39g5TFXh78Rl3j7PiK68fT3IAuR05gF24wfOkDl1nP5hw9MiPyVftNQ60CR iCtqh3yLoEyG4R643IvuthYtfav3ZXR2oyT2gCptD6xbPgimQldbV1RJ/bRKEvulguzF N7oLXN97bTXF6JYoR/s9GzFdpsnN4xZc4RZ56TUYn65X6Cf3xjLSxnC+zKXDCSit0AvY TxtdGaU8QpL8JCXmetuiIO2+tX7pfzuQPHk3kCZHvVw4f/vr60qgXuCKkFkFiqeGtYjh yiQj3QcVQdzfs7k1lCyL4pVGwjT12agaNG+a1W26IoV3aY9B9B5/3WB2fMkK6ZhGxK3b OzaQ== 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=9BNIpFb9eyHxnOZ1QLmuqWrGx9K63unXE/PWygDLncs=; b=Zl2pxX5ivp9cjuXxFX12aArp/nfuWrjzEaEO3uerWEqNNT8eeylFDFuAamyTY/YAGM v3zcPWw/Klk1Kf1cMaQoBFZbpsOIx1mtCwJ76AEJatx4aWGJJRxLu47E7SikcFo23NhR +svCZoyVfAXgMtSMDe8jT3QzKCkhH+U1GqVO+nVguyrrwfprT9Bro5RuhrSgUhLLsoBX XD77ulIRI3N7vvzHPpJ3P7rkVlxfLB5exwVOP1W2mnMA3yYAJ7dp9g+pt7VdyyxHMHcd o5sZ1nm4mhI36jgSa7tZyckhzyk712/AsLh41JB93D5Z+ZXqjsBBcsdRozMzlLtCiM8S Ctdg== X-Gm-Message-State: ALKqPwfLH+td5i6WqzMYLLmu/5gQQ0O2SyhLDANBhpJzNwiP0hZiHxWu RVsxIshTyfGdi0vCVVFUdc/6nIAL X-Received: by 2002:a50:9545:: with SMTP id v5-v6mr19802717eda.268.1527599441215; Tue, 29 May 2018 06:10:41 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id c15-v6sm17443220edr.78.2018.05.29.06.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 06:10:39 -0700 (PDT) From: Ricardo Ribalda Delgado To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Ricardo Ribalda Delgado , Rob Herring , Johan Hovold , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH 06/19] serdev: Support bus matching with modalias field Date: Tue, 29 May 2018 15:10:01 +0200 Message-Id: <20180529131014.18641-7-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529131014.18641-1-ricardo.ribalda@gmail.com> References: <20180529131014.18641-1-ricardo.ribalda@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Match devices to drivers by their modalias when the ACPI and the OF match fails. Cc: Rob Herring Cc: Johan Hovold Cc: Greg Kroah-Hartman Cc: Jiri Slaby Signed-off-by: Ricardo Ribalda Delgado --- drivers/tty/serdev/core.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index df93b727e984..2c79f47fc0db 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -79,8 +79,23 @@ static const struct device_type serdev_ctrl_type = { .release = serdev_ctrl_release, }; +static int serdev_match_id(const struct serdev_device_id *id, + const struct serdev_device *sdev) +{ + while (id->name[0]) { + if (!strcmp(sdev->modalias, id->name)) + return 1; + id++; + } + + return 0; +} + static int serdev_device_match(struct device *dev, struct device_driver *drv) { + const struct serdev_device *sdev = to_serdev_device(dev); + const struct serdev_device_driver *sdrv = to_serdev_device_driver(drv); + if (!is_serdev_device(dev)) return 0; @@ -88,7 +103,13 @@ static int serdev_device_match(struct device *dev, struct device_driver *drv) if (acpi_driver_match_device(dev, drv)) return 1; - return of_driver_match_device(dev, drv); + if (of_driver_match_device(dev, drv)) + return 1; + + if (sdrv->id_table) + return serdev_match_id(sdrv->id_table, sdev); + + return strcmp(sdev->modalias, drv->name) == 0; } /** -- 2.17.0