Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638615 > unrolled thread

Re: [PATCH v6 11/23] drivers/fsi: Add master unscan

Started byJoel Stanley <joel@jms.id.au>
First post2017-05-10 09:40 +0200
Last post2017-05-10 20:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v6 11/23] drivers/fsi: Add master unscan Joel Stanley <joel@jms.id.au> - 2017-05-10 09:40 +0200
    Re: [PATCH v6 11/23] drivers/fsi: Add master unscan Christopher Bostic <cbostic@linux.vnet.ibm.com> - 2017-05-10 20:40 +0200

#1638615 — Re: [PATCH v6 11/23] drivers/fsi: Add master unscan

FromJoel Stanley <joel@jms.id.au>
Date2017-05-10 09:40 +0200
SubjectRe: [PATCH v6 11/23] drivers/fsi: Add master unscan
Message-ID<tFuo2-6ge-13@gated-at.bofh.it>
On Tue, Apr 11, 2017 at 5:16 AM, Christopher Bostic
<cbostic@linux.vnet.ibm.com> wrote:
> From: Chris Bostic <cbostic@linux.vnet.ibm.com>
>
> 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 <cbostic@linux.vnet.ibm.com>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  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.

> +
> +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?

> +
> +       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
>

[toc] | [next] | [standalone]


#1639032

FromChristopher Bostic <cbostic@linux.vnet.ibm.com>
Date2017-05-10 20:40 +0200
Message-ID<tFEGK-49K-19@gated-at.bofh.it>
In reply to#1638615

On 5/10/17 2:31 AM, Joel Stanley wrote:
> On Tue, Apr 11, 2017 at 5:16 AM, Christopher Bostic
> <cbostic@linux.vnet.ibm.com> wrote:
>> From: Chris Bostic <cbostic@linux.vnet.ibm.com>
>>
>> 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 <cbostic@linux.vnet.ibm.com>
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> ---
>>   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
>>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web