Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754784AbbLAM56 (ORCPT ); Tue, 1 Dec 2015 07:57:58 -0500 Received: from mail-yk0-f170.google.com ([209.85.160.170]:35668 "EHLO mail-yk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754462AbbLAM5z (ORCPT ); Tue, 1 Dec 2015 07:57:55 -0500 MIME-Version: 1.0 In-Reply-To: <565D679A.6010303@samsung.com> References: <1448542190-19498-1-git-send-email-m.szyprowski@samsung.com> <1448542190-19498-3-git-send-email-m.szyprowski@samsung.com> <565D679A.6010303@samsung.com> Date: Tue, 1 Dec 2015 13:57:54 +0100 Message-ID: Subject: Re: [PATCH v2 2/4] driver core: handle -EPROBE_DEFER from bus_type.match() From: Ulf Hansson To: Marek Szyprowski Cc: Tomeu Vizoso , linux-samsung-soc , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Russell King - ARM Linux , Greg Kroah-Hartman , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1658 Lines: 57 [...] >>> @@ -500,8 +501,17 @@ static int __device_attach_driver(struct >>> device_driver *drv, void *_data) >>> if (dev->driver) >>> return -EBUSY; >>> >>> - if (!driver_match_device(drv, dev)) >>> + ret = driver_match_device(drv, dev); >>> + if (!ret) >>> return 0; >>> + else if (ret < 0) { >> >> Depending on what happens with the added dev_warn() below, perhaps a >> switch statement can make it a bit clearer, instead of these messy if >> clauses? > > > Frankly, I have no idea how to convert this to switch statement and make You are right! I was thinking that "1" was the only supported positive value, according to the documentation. > the code easier to read. Please note that we have the following 4 cases: > > ret > 0: positive match > ret == 0: negative match > ret == -EPROBE_DEFER: deferred probe > ret < 0: other, unknown error > > Another way to encode this logic is the following code: > > if (ret == 0) { > /* no match */ > return 0; > } else if (ret == -EPROBE_DEFER) { > dev_dbg(dev, "Device match requests probe deferral\n"); > driver_deferred_probe_add(dev); > return ret; > } else if (ret < 0) { > dev_dbg(dev, "Bus failed to match device: %d", ret); > return ret; > } /* ret > 0 means positive match */ Okay! To me this looks better! [...] Kind regards Uffe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/