From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbdEJSdh (ORCPT ); Wed, 10 May 2017 14:33:37 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59516 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753268AbdEJSdf (ORCPT ); Wed, 10 May 2017 14:33:35 -0400 Subject: Re: [PATCH v6 11/23] drivers/fsi: Add master unscan To: Joel Stanley References: <20170410194706.64280-1-cbostic@linux.vnet.ibm.com> <20170410194706.64280-12-cbostic@linux.vnet.ibm.com> Cc: Rob Herring , jk@ozlabs.org, Mark Rutland , Russell King , rostedt@goodmis.org, mingo@redhat.com, Greg KH , devicetree , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , Andrew Jeffery , Alistair Popple , Benjamin Herrenschmidt From: Christopher Bostic Date: Wed, 10 May 2017 13:33:27 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17051018-0020-0000-0000-00000BE9C8DD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007043; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000210; SDB=6.00858774; UDB=6.00425551; IPR=6.00638248; BA=6.00005342; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015399; XFM=3.00000015; UTC=2017-05-10 18:33:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051018-0021-0000-0000-00005C436970 Message-Id: <875f5079-0157-6f86-5020-7cfab891664f@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-10_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705100125 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/10/17 2:31 AM, Joel Stanley wrote: > On Tue, Apr 11, 2017 at 5:16 AM, Christopher Bostic > wrote: >> From: Chris Bostic >> >> Allow a master to undo a previous scan. Should a master scan a bus >> twice it will need to ensure it doesn't double register any >> previously detected device. >> >> Signed-off-by: Chris Bostic >> Signed-off-by: Joel Stanley >> --- >> drivers/fsi/fsi-core.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 40 insertions(+) >> >> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c >> index 4da0b030..75d2a88 100644 >> --- a/drivers/fsi/fsi-core.c >> +++ b/drivers/fsi/fsi-core.c >> @@ -69,6 +69,7 @@ struct fsi_slave { >> uint32_t size; /* size of slave address space */ >> }; >> >> +#define to_fsi_master(d) container_of(d, struct fsi_master, dev) >> #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) >> >> static int fsi_master_read(struct fsi_master *master, int link, >> @@ -491,6 +492,37 @@ static int fsi_master_scan(struct fsi_master *master) >> return 0; >> } >> >> +static int __fsi_slave_remove_device(struct device *dev, void *arg) >> +{ >> + device_unregister(dev); >> + return 0; >> +} >> + >> +static int __fsi_master_remove_slave(struct device *dev, void *arg) >> +{ >> + device_for_each_child(dev, NULL, __fsi_slave_remove_device); >> + device_unregister(dev); >> + return 0; >> +} > I can't see why the two above functions to have the __ prefix. Jeremy Kerr had introduced this convention. Jeremy can you comment on this? > >> + >> +static void fsi_master_unscan(struct fsi_master *master) >> +{ >> + device_for_each_child(&master->dev, NULL, __fsi_master_remove_slave); >> +} >> + >> +static ssize_t master_rescan_store(struct device *dev, >> + struct device_attribute *attr, const char *buf, size_t count) >> +{ >> + struct fsi_master *master = to_fsi_master(dev); >> + >> + fsi_master_unscan(master); >> + fsi_master_scan(master); > These function can return errors. Do you want to return those errors > to userspace? That would be the best approach yes... Will change. > >> + >> + return count; >> +} >> + >> +static DEVICE_ATTR(rescan, 0200, NULL, master_rescan_store); >> + >> int fsi_master_register(struct fsi_master *master) >> { >> int rc; >> @@ -507,7 +539,15 @@ int fsi_master_register(struct fsi_master *master) >> return rc; >> } >> >> + rc = device_create_file(&master->dev, &dev_attr_rescan); >> + if (rc) { >> + device_unregister(&master->dev); >> + ida_simple_remove(&master_ida, master->idx); >> + return rc; >> + } >> + >> fsi_master_scan(master); >> + >> return 0; >> } >> EXPORT_SYMBOL_GPL(fsi_master_register); >> -- >> 1.8.2.2 >>