Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1943108pxb; Mon, 18 Jan 2021 04:16:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJydXG7bpPI/r/CcTdUtj3a7wD1Rqjyg2cyZ4AFi8Bd7OkeOiy6NhhQmJBWQgw3yOMzJQZNv X-Received: by 2002:a17:906:16cc:: with SMTP id t12mr17445511ejd.476.1610972209058; Mon, 18 Jan 2021 04:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610972209; cv=none; d=google.com; s=arc-20160816; b=bBUH4MFd5QE+dc0G24Y/ThBBJpto6LYEBm787PKd3THmHXPB+ZGa/gPCARqI/XHHVc cyM7vohbagedAkwVj7F+yJl8r768v7J92ZcqiW5pOZtxrnExBOjQDVQosh74sBBb2Ar6 mw10RIyMsW2+HGSPptDqkdVEpbQmvC2Pcoqprf7ZooyLqqUP5GMav3L6MJtjGzY3Q/qZ 5SZdBzU8GuyZvnd5XbzqWvaoWYhy4PLTA/tjjRnJWsOvhxZE0DU7Omi/KS8tXSPd7OWE PUMfsp/147ehmjDyhFazDWfhwfDL193D5rWhvpP85DYu87cNHN7gfZCZAT8dKP2Zp4mI C44A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bekUkQFAhgR2QZLCVYSsef2aZeUwNBoiuL9ybwHmiio=; b=YV925CCX2NWBL9CAezf58QpWE6y8qrBHDb30Wp1GFA0fD9yChNFwzSsZozXbdTApaV RSfYp4onsJJNciz7QVn4bxvgoD/KAf+QKFc9DwIMRCfIJjlJIl3jxUP9JuBiXi8TPZgD FMHyFCs2EKKkqWy7sVbK0wJbgYVe0zRG1yJ6QiqHljLPsjw2QKudJFdq00GHuWrqTOQ5 q9q+0ww3rq//reU9RwrL1/BVVmuNkQQtgyCartAQGecvHP3DjkaYYY+1PN554Dd/iQsi x8zhLdxVc7pgAZctWu6bz+9vm2RbG0EFoRbGT1JGUEMVTXPiEf6UYqFZg64jCs+HKhQM zuNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VWQddsAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id bm19si5750927edb.525.2021.01.18.04.16.23; Mon, 18 Jan 2021 04:16:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VWQddsAF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2390149AbhARMOQ (ORCPT + 99 others); Mon, 18 Jan 2021 07:14:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390861AbhARLvg (ORCPT ); Mon, 18 Jan 2021 06:51:36 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DAAC061573 for ; Mon, 18 Jan 2021 03:50:56 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id p15so9262882pjv.3 for ; Mon, 18 Jan 2021 03:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bekUkQFAhgR2QZLCVYSsef2aZeUwNBoiuL9ybwHmiio=; b=VWQddsAFzbpSpQUIq3J6j6x9XgpGG/Ga/of9rwwoDXfZgrTL6sJe6gXAW+z+nsmXr6 c6qWsSjtv9YcSkdMV0uKBcd+AyL1XZezomb9WRy3efKHFxGPsYpYhVBPGmh+FAoB+CRw S9dpWBn0VXxLfdXcdWpTR7wSoWBYYQD6TEqU+0S8NuuUprFMslz0CgJwYeK3R6ucCdbI vv0mXXBSQzxZykhIRmQi70QzKAHATHrKXuXWqmLzkvAq5SRBTLkW6459e6bh5QeM9Roc YcSK6jYMDgzTV7msGQhiSMhHqtGG+HNruiyf74dwfjzN5uYsu8/CtXnFvmium0ZTrYpq jIRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bekUkQFAhgR2QZLCVYSsef2aZeUwNBoiuL9ybwHmiio=; b=hDtkomg+aYhPHEV36cX9NL2kG9+cFD7DFNmtfA59eghhrpa0EvOBKxB5GMTPsfnx/n RLMfUsl0SRXSPmoqF1jaEbTOAGClWsL8Gi6rc24sY7iIfYEVndgitaTCCNS3nLhfw17j W2q4EfGJg/RLYYQQYXKNhOd/OOoyHzG5Lkv5AkY8Cvw0N0E3F57effR1J9StJDRGN5xD HQpV4sR6G/YE2q/j5fXPBCnTfW0w4cnbsvVXz9Z2rfDita1M61p4YgCCPilxAuUrcJLK he/YLMvfdbBb5I1auwk2Wmd6sTXtq0tWK7veGW1V+KYSRwk0KOXMVdR33X3X3vtk492j E5Kg== X-Gm-Message-State: AOAM531tpoegC4lJtRfWGRGCD4wK9j6MzOD2Phw+zB4QF+UkPZs6Pt6I 6KH2zdd/EAgi3LRMliQ57o9xzB3J2hNLxsNdUGY= X-Received: by 2002:a17:90a:6c90:: with SMTP id y16mr26644109pjj.129.1610970655499; Mon, 18 Jan 2021 03:50:55 -0800 (PST) MIME-Version: 1.0 References: <20210117212252.206115-1-hdegoede@redhat.com> <20210117212252.206115-3-hdegoede@redhat.com> In-Reply-To: <20210117212252.206115-3-hdegoede@redhat.com> From: Andy Shevchenko Date: Mon, 18 Jan 2021 13:51:44 +0200 Message-ID: Subject: Re: [PATCH v3 2/5] mfd: arizona: Replace arizona_of_get_type() with device_get_match_data() To: Hans de Goede Cc: Lee Jones , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , patches@opensource.cirrus.com, Linux Kernel Mailing List , Charles Keepax , ALSA Development Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 17, 2021 at 11:23 PM Hans de Goede wrote: > > Replace the custom arizona_of_get_type() function with the generic > device_get_match_data() helper. Besides being a nice cleanup this > also makes it easier to add support for binding to ACPI enumerated > devices. > > While at it also fix a possible NULL pointer deref of the id > argument to the probe functions (this could happen on e.g. manual > driver binding through sysfs). Reviewed-by: Andy Shevchenko > Suggested-by: Andy Shevchenko > Signed-off-by: Hans de Goede > --- > Changes in v2: > - New patch in v2 of this patchset > --- > drivers/mfd/arizona-core.c | 11 ----------- > drivers/mfd/arizona-i2c.c | 10 ++++++---- > drivers/mfd/arizona-spi.c | 10 ++++++---- > drivers/mfd/arizona.h | 9 --------- > 4 files changed, 12 insertions(+), 28 deletions(-) > > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c > index 000cb82023e3..75f1bc671d59 100644 > --- a/drivers/mfd/arizona-core.c > +++ b/drivers/mfd/arizona-core.c > @@ -797,17 +797,6 @@ const struct dev_pm_ops arizona_pm_ops = { > EXPORT_SYMBOL_GPL(arizona_pm_ops); > > #ifdef CONFIG_OF > -unsigned long arizona_of_get_type(struct device *dev) > -{ > - const struct of_device_id *id = of_match_device(arizona_of_match, dev); > - > - if (id) > - return (unsigned long)id->data; > - else > - return 0; > -} > -EXPORT_SYMBOL_GPL(arizona_of_get_type); > - > static int arizona_of_get_core_pdata(struct arizona *arizona) > { > struct arizona_pdata *pdata = &arizona->pdata; > diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c > index 2a4a3a164d0a..5e83b730c4ce 100644 > --- a/drivers/mfd/arizona-i2c.c > +++ b/drivers/mfd/arizona-i2c.c > @@ -23,14 +23,16 @@ > static int arizona_i2c_probe(struct i2c_client *i2c, > const struct i2c_device_id *id) > { > + const void *match_data; > struct arizona *arizona; > const struct regmap_config *regmap_config = NULL; > - unsigned long type; > + unsigned long type = 0; > int ret; > > - if (i2c->dev.of_node) > - type = arizona_of_get_type(&i2c->dev); > - else > + match_data = device_get_match_data(&i2c->dev); > + if (match_data) > + type = (unsigned long)match_data; > + else if (id) > type = id->driver_data; > > switch (type) { > diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c > index 704f214d2614..798b88295c77 100644 > --- a/drivers/mfd/arizona-spi.c > +++ b/drivers/mfd/arizona-spi.c > @@ -23,14 +23,16 @@ > static int arizona_spi_probe(struct spi_device *spi) > { > const struct spi_device_id *id = spi_get_device_id(spi); > + const void *match_data; > struct arizona *arizona; > const struct regmap_config *regmap_config = NULL; > - unsigned long type; > + unsigned long type = 0; > int ret; > > - if (spi->dev.of_node) > - type = arizona_of_get_type(&spi->dev); > - else > + match_data = device_get_match_data(&spi->dev); > + if (match_data) > + type = (unsigned long)match_data; > + else if (id) > type = id->driver_data; > > switch (type) { > diff --git a/drivers/mfd/arizona.h b/drivers/mfd/arizona.h > index 995efc6d7f32..801cbbcd71cb 100644 > --- a/drivers/mfd/arizona.h > +++ b/drivers/mfd/arizona.h > @@ -50,13 +50,4 @@ int arizona_dev_exit(struct arizona *arizona); > int arizona_irq_init(struct arizona *arizona); > int arizona_irq_exit(struct arizona *arizona); > > -#ifdef CONFIG_OF > -unsigned long arizona_of_get_type(struct device *dev); > -#else > -static inline unsigned long arizona_of_get_type(struct device *dev) > -{ > - return 0; > -} > -#endif > - > #endif > -- > 2.28.0 > -- With Best Regards, Andy Shevchenko