lkml.org 
[lkml]   [2011]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 10/13] rtc: avoid to use hardcoding irq number in max8925
    From
    On 4/13/11, Haojian Zhuang <haojian.zhuang@marvell.com> wrote:
    > Avoid to use hardcoding irq number in max8925 rtc driver. Use irq number
    > from resources instead.
    >
    > Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
    Acked-by:Wanlong Gao<wanlong.gao@gmail.com>
    > Cc: Alessandro Zummo <a.zummo@towertech.it>
    > ---
    > drivers/rtc/rtc-max8925.c | 22 +++++++++++++---------
    > 1 files changed, 13 insertions(+), 9 deletions(-)
    >
    > diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
    > index 174036d..c460152 100644
    > --- a/drivers/rtc/rtc-max8925.c
    > +++ b/drivers/rtc/rtc-max8925.c
    > @@ -69,6 +69,7 @@ struct max8925_rtc_info {
    > struct max8925_chip *chip;
    > struct i2c_client *rtc;
    > struct device *dev;
    > + int irq;
    > };
    >
    > static irqreturn_t rtc_update_handler(int irq, void *data)
    > @@ -239,7 +240,7 @@ static int __devinit max8925_rtc_probe(struct
    > platform_device *pdev)
    > {
    > struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
    > struct max8925_rtc_info *info;
    > - int irq, ret;
    > + int ret = -EINVAL;
    >
    > info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL);
    > if (!info)
    > @@ -247,16 +248,22 @@ static int __devinit max8925_rtc_probe(struct
    > platform_device *pdev)
    > info->chip = chip;
    > info->rtc = chip->rtc;
    > info->dev = &pdev->dev;
    > - irq = chip->irq_base + MAX8925_IRQ_RTC_ALARM0;
    > + info->irq = platform_get_irq(pdev, 0);
    > + if (info->irq < 0) {
    > + dev_err(chip->dev, "Failed to get IRQ resource\n");
    > + goto out_irq;
    > + }
    >
    > - ret = request_threaded_irq(irq, NULL, rtc_update_handler,
    > + ret = request_threaded_irq(info->irq, NULL, rtc_update_handler,
    > IRQF_ONESHOT, "rtc-alarm0", info);
    > if (ret < 0) {
    > dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
    > - irq, ret);
    > + info->irq, ret);
    > goto out_irq;
    > }
    >
    > + dev_set_drvdata(&pdev->dev, info);
    > + platform_set_drvdata(pdev, info);
    > info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev,
    > &max8925_rtc_ops, THIS_MODULE);
    > ret = PTR_ERR(info->rtc_dev);
    > @@ -265,12 +272,9 @@ static int __devinit max8925_rtc_probe(struct
    > platform_device *pdev)
    > goto out_rtc;
    > }
    >
    > - dev_set_drvdata(&pdev->dev, info);
    > - platform_set_drvdata(pdev, info);
    > -
    > return 0;
    > out_rtc:
    > - free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info);
    > + free_irq(info->irq, info);
    > out_irq:
    > kfree(info);
    > return ret;
    > @@ -281,7 +285,7 @@ static int __devexit max8925_rtc_remove(struct
    > platform_device *pdev)
    > struct max8925_rtc_info *info = platform_get_drvdata(pdev);
    >
    > if (info) {
    > - free_irq(info->chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info);
    > + free_irq(info->irq, info);
    > rtc_device_unregister(info->rtc_dev);
    > kfree(info);
    > }
    Added the irq to the info , Hmm.........,seems like all good to me .
    Thanks
    Best regards
    > --
    > 1.5.6.5
    >
    > --
    > 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/
    >


    \
     
     \ /
      Last update: 2011-04-15 02:43    [W:0.052 / U:179.100 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site